Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-19-2012, 12:55 PM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Best way for this....

I am making a Chance event and everything is good except how to check if the chosen number of the box has any players inside it, right now I have this

Graal Script Code:
  for (temp.plallplayers) {
    if (
temp.pl.level.name == this.level.name && playersInLevel >= 2) {
      {
        if (
temp.pl.x in coords[box 1][0], coords[box 1][1] | && temp.pl.y in coords[box 1][2], coords[box 1][3] | ) {
          
playerInBox true
Now this works but it is very buggy (wont cycle through different boxes, it chooses a player and no matter how many times you grab the block it still chooses the same box), can someone help me with the best way to do this event?
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #2  
Old 10-19-2012, 04:01 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Use players (local to the levels) instead of allplayers (entire server).

Graal Script Code:
temp.boxes = {
  {
001010}, // x, y, width, height
  
{10101010},
};
temp.box temp.boxes[int(random(0,temp.boxes.size()))];
for (
temp.plplayers) {
  if (
temp.pl.x in |temp.box[0], temp.box[0] + temp.box[2]| && temp.pl.y in |temp.box[1],temp.box[1]+temp.box[3]|) {
    
temp.pl.setlevel2("warpout.nw"3030);
  }

__________________
Quote:
Reply With Quote
  #3  
Old 10-19-2012, 09:09 PM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Thanks for that but I am still having a problem, what if the random box chosen has no players in it? I don't see a way to avoid an overflow when theres nobody in the boxes...
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #4  
Old 10-19-2012, 09:40 PM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
The way I did Chance on UN was to go through each box before selecting the losing box and check if it has player in it's boundaries. If it did, I added it's number to an array. Then picked randomly from this array, so you always get a box with at least one player in it.
__________________
-Ph8
Reply With Quote
  #5  
Old 10-19-2012, 09:43 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Vatec View Post
Thanks for that but I am still having a problem, what if the random box chosen has no players in it? I don't see a way to avoid an overflow when theres nobody in the boxes...
What do you even mean? If there's nobody in the selected box, it will just end up looping through all the players in the level once and do nothing to any of them.
__________________
Reply With Quote
  #6  
Old 10-19-2012, 10:12 PM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Quote:
Originally Posted by Starfire2001 View Post
The way I did Chance on UN was to go through each box before selecting the losing box and check if it has player in it's boundaries. If it did, I added it's number to an array. Then picked randomly from this array, so you always get a box with at least one player in it.
Great idea, did it and its working, thanks for the help
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #7  
Old 10-19-2012, 10:42 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Mind showing how the chance area looks?
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #8  
Old 10-19-2012, 10:44 PM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Quote:
Originally Posted by Fulg0reSama View Post
Mind showing how the chance area looks?
I don't think I am allowed to post screenshots of the server, and the level is ugly right now
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #9  
Old 10-19-2012, 10:46 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Quote:
Originally Posted by Vatec View Post
I don't think I am allowed to post screenshots of the server, and the level is ugly right now
Should I just assume a tic-tact-toe square then?
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #10  
Old 10-19-2012, 10:57 PM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Quote:
Originally Posted by Fulg0reSama View Post
Should I just assume a tic-tact-toe square then?
Yes, why do you want to know that?
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #11  
Old 10-20-2012, 12:54 AM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
You can draw a cute little picture?
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:51 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.