Scripting School
Would you like to react to this message? Create an account in a few clicks or log in to continue.

New to scripting? We want you!

Official Ventrilo: Host:Apollo.MaxFrag.net Port:3840
TestBed needs our help! Please donate a few dollars to keep it running here!
Have you mastered a specific part of GS2? Create a guide and help others!

You are not connected. Please login or register

Assignment 2 - Kavan

2 posters

Go down  Message [Page 1 of 1]

1Assignment 2 - Kavan Empty Assignment 2 - Kavan Thu May 05, 2011 1:12 pm

Kavan



Part 1 - Formatting the script:

Code:
for(i = 0; i < passdefects.tokenize(",").size(); i ++){
 temp.effect = passdefects.tokenize(",")[i].tokenize(":");
 temp.effectroll = random(0,100);
 if(effectroll <= effect[0] && effect[1] == "cause"){
  BuffSystem.addbuff(effect[2],effect[3],effect[4],effect[5],effect[6]);
 }
}

Part 2 - Changing player attrs using vars:

Code:
function onCreated(){
 this.heartvar = 3;
 this.apvar = 99;
}

function onPlayerEnters(){
 player.hearts = this.heartvar;
 player.ap = this.apvar;
}

Part 3 - Setting hats depending on subscription:

Code:
function onCreated(){
 setimg("block.png");
 setshape(1,32,32);
 onTimeout();
}

function onTimeout(){
 if(player.x in |this.x-3,this.x+5| && player.y in |this.y-3,this.y+5|){
  if(player.ani == "grab"){
  if(player.subscription == "gold"){
    player.attr[1] = "hat13.png";
  }
  else if(player.subscription == "classic"){
    player.attr[1] = "hat2.png";
  }
  player.chat = "You have received a new hat!";
  }
 }
 setTimer(.5);
}

Part 4 - Hat Setter:

Code:
function onPlayerChats(){
 if(player.chat.starts("/sethat")){
  player.attr[1] = player.chat.substring(8);
  player.chat = "Hat set to "@player.chat.substring(8)@"!";
 }
}

Yup. So there you have it... cheers

2Assignment 2 - Kavan Empty Re: Assignment 2 - Kavan Thu May 05, 2011 11:33 pm

David K?



Other then the fact you probably shouldn't do a simple timeout or sleep serverside... "I didn't even know you could do it serverside but it looks like you can" I suppose it is bad for the server and could create lag if there are many..

It all looks good ^.^, and I have probably just learned about .subscription lmao..

-edit-
It isn't working for me though Surprised..

3Assignment 2 - Kavan Empty Re: Assignment 2 - Kavan Fri May 06, 2011 3:40 am

Kavan



I did it serverside because I couldn't remember if player.attrs could be changed clientside.
If it doesn't work, then the top of your Graalian's head is not in the tiny square, or it just doesn't work LOL

4Assignment 2 - Kavan Empty Re: Assignment 2 - Kavan Fri May 06, 2011 4:08 am

David K?



Oh believe me, I was grabbing all up on that block. ;]
Lol I'll figure out what is wrong with it later, but anything on a player can be set clientside I believe, unless you are setting another player..

Either way depending if it is level or not, you could use triggeraction or triggerserver... We should go over those later. ^.^

Also, that was a :0 face, not a smile that it seems like up there.. Surprised

-edit-
I believe I was told player.attrs and such are all serverside, but if you are setting someone other then your owns, they must be serverside.

Npc's clientside will only work for the client, for instance if you touch it, and it talks only you will see it.

5Assignment 2 - Kavan Empty Re: Assignment 2 - Kavan Fri May 06, 2011 12:47 pm

Kavan



I would have gone and checked a load of things on the testbed before I put it up here, but I've managed to get myself blacklisted by Graal's SMS provider by sending for codes too often, so I'm a trial and I can't check or test anything. Sad

6Assignment 2 - Kavan Empty Re: Assignment 2 - Kavan Sat May 07, 2011 4:00 am

David K?



That's fine, I'll still try to help you when I can. ^.^
The more I help others, the more I learn.

-edit-
So far I haven't been able to correct / explain anything in here though, I've been slightly busy trying to get together some threads to help out.

Also, as we get into harder things, it may be very hard without an RC to check. =x

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum