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

Phil Assignment 1

3 posters

Go down  Message [Page 1 of 1]

1Phil Assignment 1 Empty Phil Assignment 1 Wed May 04, 2011 12:19 am

PhilSmith



Code:
//#CLIENTSIDE
function onPlayerTouchsMe(){
  if (player.nick in {"Phil Smith", "David K?", "Zeus Condero"}){
    this.chat="Scripting Class is the bomb!";
    sleep(2);
    player.chat= "I know!!";
  }
  else {
    player.SendPm("Do you Know about Scripting Class?");
  }
}

I didn't really want to go that far out of the assignment, but I needed the creativity and I was kinda bored. jocolor

2Phil Assignment 1 Empty Re: Phil Assignment 1 Wed May 04, 2011 5:46 am

David K?



PhilSmith wrote:
Code:
//#CLIENTSIDE
function onPlayerTouchsMe(){
  if (player.nick in {"Phil Smith", "David K?", "Zeus Condero"}){
    this.chat="Scripting Class is the bomb!";
    sleep(2);
    player.chat= "I know!!";
  }
  else {
    player.SendPm("Do you Know about Scripting Class?");
  }
}

I didn't really want to go that far out of the assignment, but I needed the creativity and I was kinda bored. jocolor


It's good to go that extra limit, it helps us learn. ^.^; I thought in was only for like player.x in |,| ... didn't know about any other uses for in..

And I recently learned it.. so it works for arrays too? Anything else? study

3Phil Assignment 1 Empty Re: Phil Assignment 1 Wed May 04, 2011 11:51 am

Deas



PhilSmith wrote:
Code:
//#CLIENTSIDE
function onPlayerTouchsMe(){
  if (player.nick in {"Phil Smith", "David K?", "Zeus Condero"}){
    this.chat="Scripting Class is the bomb!";
    sleep(2);
    player.chat= "I know!!";
  }
  else {
    player.SendPm("Do you Know about Scripting Class?");
  }
}

I didn't really want to go that far out of the assignment, but I needed the creativity and I was kinda bored. jocolor

I don't suggest using "foo in |var,var2|" in this example, because "|var,var2|" is considered "between", such as "if number10 is between 0, and 20".

for your example, using brackets would be alot better (normal array), such as
Code:

this.array = { "me", "you", "hello", "something" };
if (var in this.array)

// or...

if (var in {"me", "you", "hello", "something"} )


edit: jeeze, find the PHP tag's already, i can't even tab to make it look better...

4Phil Assignment 1 Empty Re: Phil Assignment 1 Wed May 04, 2011 1:46 pm

David K?



Deas wrote:
I don't suggest using "foo in |var,var2|" in this example, because "|var,var2|" is considered "between", such as "if number10 is between 0, and 20".

No worries, I was asking if there were any other ways to use it in general, and stating that was the only way I was taught. ^.^

But in this case I can see it being used in a good way.. if player touchs me this.chat = ???; then a statement using while player.x or player.y in |x1,x2| and such, the npc could keep talking..

If I were creating a level I'd like the npc to be as interactive as possible.. if the npc was showcharacter it would say more than one thing, would talk if hit, thrown at, or possibly grabbed..

Most levels I go into I slash or throw something at the npc character to test it out. :3 Sadly no one does anything that far.. D:


Either way, I'd still like to know... are there any other ways to use 'in'? I don't quite understand 'with' either..

5Phil Assignment 1 Empty Re: Phil Assignment 1 Wed May 04, 2011 3:54 pm

Deas



David K? wrote:No worries, I was asking if there were any other ways to use it in general, and stating that was the only way I was taught. ^.^

But in this case I can see it being used in a good way.. if player touchs me this.chat = ???; then a statement using while player.x or player.y in |x1,x2| and such, the npc could keep talking..

If I were creating a level I'd like the npc to be as interactive as possible.. if the npc was showcharacter it would say more than one thing, would talk if hit, thrown at, or possibly grabbed..

Most levels I go into I slash or throw something at the npc character to test it out. :3 Sadly no one does anything that far.. D:


Either way, I'd still like to know... are there any other ways to use 'in'? I don't quite understand 'with' either..

i am not aware of all the uses of "in" but i do know the two basic ones, and that is the array and "between" (as i'd like to call it), i've heard that there are a few more, but i don't know the uses of those, and therefor i'm not going to speculate in what those does.

about throwing a bush at a npc, AFAIK; there is no way to detect if a npc been hit by a bush or a stone, unless there is some undocumented event that i've never heard of.
showcharacter should be showcharacter(); too, as without the (); it is GS1.

the best way to detect if someone is "in-range" using the "between-method" is in a timeout event, where you are checking if there is anyone close to it endlessly.

6Phil Assignment 1 Empty Re: Phil Assignment 1 Wed May 04, 2011 4:57 pm

David K?



Deas wrote:
i am not aware of all the uses of "in" but i do know the two basic ones, and that is the array and "between" (as i'd like to call it), i've heard that there are a few more, but i don't know the uses of those, and therefor i'm not going to speculate in what those does.

Ahh I see.. hopefully Phil know.. D:

Deas wrote:
about throwing a bush at a npc, AFAIK; there is no way to detect if a npc been hit by a bush or a stone, unless there is some undocumented event that i've never heard of.
showcharacter should be showcharacter(); too, as without the (); it is GS1.

Slightly unsure why the conversion was listed, but I know it's under GS1, I suppose it could work in GS2 as well:

peltwithblackstone the npc was pelt with a blackstone
peltwithbush the npc was pelt with a bush
peltwithnpc the npc was pelt with another npc
peltwithsign the npc was pelt with a sign
peltwithstone the npc was pelt with a stone
peltwithvase the npc was pelt with a vase

I can't say I've tried them but they are listed in the command list I posted. I'll have to try it thursday... Rolling Eyes
Can't now..

Deas wrote:
the best way to detect if someone is "in-range" using the "between-method" is in a timeout event, where you are checking if there is anyone close to it endlessly.

I guess it depends what you are doing Surprised..
Someone may want to use a while to only check endlessly once until they are out of the 'area'. But even with timeout you can have an 'off and on' switch so it turns off out of range, and after the playertouchs npc it could set it back on until they leave again.. Personal preferences lol Could even use an infinite for loop.. D:

Sponsored content



Back to top  Message [Page 1 of 1]

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