Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Everyone with client.var.... (https://forums.graalonline.com/forums/showthread.php?t=134260702)

ZeroG 10-02-2010 10:32 PM

Everyone with client.var....
 
I'm trying to make a script that kicks everyone in a level who has a client.chance variable of 2, for example. I'm not sure how to make it so that whoever says /kick 2, everyone with client.chance=2 gets kicked. Right now it only kicks you if yourself. What I mean is, it only kicks you, no one else. How can I make it kick everyone what has client.chance=2?

Here is the script:
PHP Code:

if (created) {
setshape 1,128,128
}
if (
playertouchsme){
  
player.client.chance=2;
}
function 
onPlayerChats(){
  if (
player.chat=="/kick 2"){
  if (
player.client.chance==2){
    
setlevel2 chance.nw,25,45;
  }}


Oh, and I have another script that makes it so that everyone who enters the level gets the client.chance variable, so that isn't the problem.

xXziroXx 10-02-2010 10:36 PM

You have to loop through the current players in the level and check each individual players client.chance value.

MrDumbledore 10-02-2010 10:36 PM

You need to loop through each player.

PHP Code:

function onPlayerChats() { // player chats in the level
  
if (player.guild == "Events Team") {
    if (
player.chat.starts("/kick")) { // chat starts with /kick
      
temp.num player.chat.substring(6).trim(); // find the number the ET said
      
      
for (temp.pl players) { // loop through each player
        
if (pl.client.chance == num) { // it's the number the ET called
          
pl.setLevel2("chance.nw"2545); // warp that player (note "pl."setLevel2)
        
}
      }
    }
  }


You should also consider using clientr variables, or even player. variables serverside (this is preferable for something like this).

Keep in mind you should only use the above script in the level once.

ZeroG 10-02-2010 10:43 PM

Thanks:)


All times are GMT +2. The time now is 10:58 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.