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

onPlayerTouchsme assignment

3 posters

Go down  Message [Page 1 of 1]

1onPlayerTouchsme assignment Empty onPlayerTouchsme assignment Tue May 03, 2011 12:07 am

ZeusCondero


Admin

Here is my script!

This is just an example of how you should post your assignment. Please post it to the proper week.


Code:

//#CLIENTSIDE
function onPlayerTouchsme () {
 if(player.account == "padpajchris"){
  this.chat = ("Put me down now");
}
}


Be sure to let me know if anything is not done correctly!

2onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 3:56 am

David K?



Sorry, I don't have testbed at my grandparents house and I will be here until Weds.
I will make it in here but I cannot test it..


Code:

//#CLIENTSIDE
function onCreated(){
  this.awesomeThingieChat = {
  "You hate me?", "Why are you touching me?", " You wouldn't touch your mom with that finger!",
  "Sometimes I think I can fly!", "There was once a demon in my nose!", "Hey David K? :D"
  };

  showcharacter;
}

function onPlayerTouchesMe(){
  if (player.account != "Devil_Lord2"){
    temp.thingieChat = int(random(1,5.99));
    this.chat = this.awesomeThingieChat[thingieChat];
  }
  else {
    this.chat = this.awesomeThingieChat[6];
  }
}

Codes seem to look better in the Graal Forums.. it may be better to ask to have our own private room. D:




Also,
ZeusCondero wrote:Here is my script!

This is just an example of how you should post your assignment. Please post it to the proper week.


Code:

//#CLIENTSIDE
function onPlayerTouchsme () {
 if(player.account == "padpajchris"){
  this.chat = ("Put me down now");
}
}


Be sure to let me know if anything is not done correctly!

This isn't incorrect, but you do not need the ()'s around "Put me down now"; and the bracket closing off the if statement could be spaced once or twice to look like it goes to the if statement, it could confuse people if there were longer lines of code. Idea

3onPlayerTouchsme assignment Empty Heres mine Tue May 03, 2011 9:38 am

Rave



Ok if ur account in the script and they npc will be nice and it will hit u and u take damage.
if ur account is not in the script it will owned u. will talk for u and make me feel like a nub i guess.

Code:
function onPlayerTouchsme () {
 if (player.account == "Rave_J") {
  this.chat = "Hey" SPC player.nick SPC "!";
  sleep (3);
  this.chat = "";
Hurt (0.5);
player.hearts = 0.5;
player.chat = ("You Hurt Me");
}
 else {
  this.chat = ("Put me down now");
  sleep(3);
  this.chat = ("You Fuck up");
  sleep (3);
  player.chat = ("Im Stefan Bish");
  this.chat = "";
 }
}[code][/code]

4onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 10:25 am

ZeusCondero


Admin

In your script you are setting the players health to .5. What you want to do is remove .5 health, try player.hearts = -.5;

5onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 10:29 am

Rave



ZeusCondero wrote:In your script you are setting the players health to .5. What you want to do is remove .5 health, try player.hearts = -.5;
oh thats y it kept setting my health to 0.5 hearts lol

6onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 11:22 am

David K?



ZeusCondero wrote:In your script you are setting the players health to .5. What you want to do is remove .5 health, try player.hearts = -.5;

Again, I can't test it here, but I believe that would be setting health to -.5 ... which I assume would kill you.. or I'm not even sure what it would do lol...
Code:

You could do either:
player.hearts = player.hearts + -.5;
player.hearts = player.hearts - .5;
player.hearts -= .5;
player.hearts += -.5;


7onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 12:05 pm

ZeusCondero


Admin

David K? wrote:
ZeusCondero wrote:In your script you are setting the players health to .5. What you want to do is remove .5 health, try player.hearts = -.5;

Again, I can't test it here, but I believe that would be setting health to -.5 ... which I assume would kill you.. or I'm not even sure what it would do lol...
Code:

You could do either:
player.hearts = player.hearts + -.5;
player.hearts = player.hearts - .5;
player.hearts -= .5;
player.hearts += -.5;





Ahh thats what i meant to do

Code:
player.hearts -= .5;



Thanks!

8onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 2:27 pm

David K?



ZeusCondero wrote:
Thanks!

No problem, we are all here to learn. ^.^,

9onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 4:30 pm

Rave



ZeusCondero wrote:
David K? wrote:
ZeusCondero wrote:In your script you are setting the players health to .5. What you want to do is remove .5 health, try player.hearts = -.5;

Again, I can't test it here, but I believe that would be setting health to -.5 ... which I assume would kill you.. or I'm not even sure what it would do lol...
Code:

You could do either:
player.hearts = player.hearts + -.5;
player.hearts = player.hearts - .5;
player.hearts -= .5;
player.hearts += -.5;




Ahh thats what i meant to do

Code:
player.hearts -= .5;



Thanks!

so y is it - or T before the =

10onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 4:41 pm

ZeusCondero


Admin

Rave wrote:
ZeusCondero wrote:
David K? wrote:
ZeusCondero wrote:In your script you are setting the players health to .5. What you want to do is remove .5 health, try player.hearts = -.5;

Again, I can't test it here, but I believe that would be setting health to -.5 ... which I assume would kill you.. or I'm not even sure what it would do lol...
Code:

You could do either:
player.hearts = player.hearts + -.5;
player.hearts = player.hearts - .5;
player.hearts -= .5;
player.hearts += -.5;




Ahh thats what i meant to do

Code:
player.hearts -= .5;



Thanks!

so y is it - or T before the =

Look at David's example again.
Code:
player.hearts = player.hearts - .5;
is the same as
Code:
player.hearts -= .5;

In English, the first option is doing
health = health - .5
. Do you see that? Now the second one is doing the exact same thing. Here is an example from Jerret's Guide.

a += b is basically the same as doing
a = a + b


a -= b is basically the same as doing
a = a - b

Not only can you use plus and minus signs, you can use the following:

+ Addition
- Subtraction
/ Division
* Multiplication
^ Exponents
% Mod (Gives you the remainder of a division I.e: 5 % 2 = 1)

11onPlayerTouchsme assignment Empty made another npc Tue May 03, 2011 5:53 pm

Rave



i havent test it yet but pretty sure it will work. I have it where it heals my account if anybody else touch it they wont get heal just drop some money

Code:
function onPlayerTouchsme () {
 if (player.account == "Rave_J") {
  this.chat = "You are heal" SPC player.account SPC "!"; 
  sleep (0.5);
  this.chat = "";
  player.hearts = player.fullhearts;
  player.chat = ("YES Im Heal");
}
 else {
  this.chat = "No i cant heal you but i can give you this." SPC player.nick SPC "!";
  sleep (0.5);
  lay2("goldrupee",34,24);
  sleep(1)
  this.chat = "";
  player.chat = ("Oh Man");
}

12onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 7:58 pm

ZeusCondero


Admin

I can double check in a little bit but for rupees you would want to do player.rupees += 100;

13onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 9:37 pm

Rave



it drops the rupees thought
lay2("goldrupee",34,24);
the 2 numbers thats the x and y
cant u also do it like
lay2*
("goldrupee",playerx,playery);

14onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 9:55 pm

ZeusCondero


Admin

player.x and player.y

When you grab the rupee the way you have it now is your money increasing?

15onPlayerTouchsme assignment Empty Re: onPlayerTouchsme assignment Tue May 03, 2011 10:26 pm

David K?



Rave wrote:i havent test it yet but pretty sure it will work. I have it where it heals my account if anybody else touch it they wont get heal just drop some money

Code:
function onPlayerTouchsme () {
 if (player.account == "Rave_J") {
  this.chat = "You are heal" SPC player.account SPC "!"; 
  sleep (0.5);
  this.chat = "";
  player.hearts = player.fullhearts;
  player.chat = ("YES Im Heal");
}
 else {
  this.chat = "No i cant heal you but i can give you this." SPC player.nick SPC "!";
  sleep (0.5);
  lay2("goldrupee",34,24);
  sleep(1)
  this.chat = "";
  player.chat = ("Oh Man");
}

I don't remember how vecx and vecy works but I like to make my own small system anyway..


Code:
function onPlayerTouchsme () {
 if (player.account == "Rave_J") {
  this.chat = "You are heal" SPC player.account SPC "!"; 
  sleep (0.5);
  this.chat = "";
  player.hearts = player.fullhearts;
  player.chat = ("YES Im Heal");
}
 else {
  this.chat = "No i cant heal you but i can give you this." SPC player.nick SPC "!";
  sleep (0.5);
  layDirection();                                  // <- means comment and isn't in the code. 
  lay2("goldrupee",this.dirx,this.diry);    //  The layDirection function I created makes the gralat go behind   
  sleep(1)                                        //  the player.  I'm sure someone could make it simpler.
  this.chat = "";
  player.chat = ("Oh Man");
}


function layDirection(){
  this.dirx = player.x;
  this.diry = player.y;
  if (player.dir = 0){
    diry += 1;
  }
  if (player.dir = 1){
    dirx += 1;
 }
 if (player.dir = 2){
    diry -= 1;
  }
  if (player.dir = 3){
    dirx -= 1;
  }
}


:'[ It looks so bad on here... I miss Graal Forums posting..

Sponsored content



Back to top  Message [Page 1 of 1]

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