Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   How do you use NOT in an array (https://forums.graalonline.com/forums/showthread.php?t=134262755)

Astram 04-09-2011 03:46 AM

How do you use NOT in an array
 
I am trying to make a script and this doesnt work
PHP Code:

if (p.guild ! in this.admins) 

or even
PHP Code:

if (!(p.guild in this.admins)) 

But nothing seems to be working >_<

cbk1994 04-09-2011 03:52 AM

PHP Code:

if (! (element in array)) { 

This will work fine. Note that it is case-sensitive.

oo_jazz_oo 04-09-2011 03:53 AM

Your second example should work, you might need to post more of your script...you probably have an error somewhere else.

fowlplay4 04-09-2011 03:54 AM

The second way is the right way to do it.

PHP Code:

temp.staffguilds = serveroptions.staffguilds.tokenize(",");
temp.guild = "Not Cool";
if (!(
temp.guild in temp.staffguilds)) {
  echo(
temp.guild);
} 

Your 'this.admins' probably isn't a proper array.

Astram 04-09-2011 03:56 AM

Okay im going to post my stealth script here, because it needs the work on it.
PHP Code:

function onActionServerSide()
  {
  if (
params[0] == "stealth")
    {
    for (
p : players)
      {
      if (
p.guild != "Owner")
      {
      
p.triggerclient("gui",this.name,"stealth",params[2],params[1]);
      }
      else
      {
      if (
findplayer(params[2]).this.on = 1)
      {
      
p.triggerclient("gui",this.name,"stealth",params[2],0.75);
      }
      else
      {
      
p.triggerclient("gui",this.name,"stealth",params[2],1);
      }
      }
    }
    }
  }
//#CLIENTSIDE
function onKeyPressed(code, key, scancode)
  {
  if (
key == "5")
    {
     if (
player.guild in this.admins)
      {
    if (
this.on == false)
      {
      
this.on = true;
      
triggerserver("gui",this.name,"stealth",0,player.account);
      
sleep(0.5);
      
player.alpha = 0.75;
      
client.message.add("Stealth Mode On");
      }
    else
      {
      
this.on = false;
      
triggerserver("gui",this.name,"stealth",1,player.account);
      
sleep(0.5);
      
player.alpha = 1;
      
client.message.add("Stealth Mode Off");
      }
    }
  }
  }
function 
onActionClientSide()
  {
  if (
params[0] == "stealth")
    {
    
findplayer(params[1]).alpha = params[2];
    }
  }
this.admins = {"Owner","Events Team"}; 

This is added to all players
and
I want to change
PHP Code:

 if (p.guild != "Owner")
      { 

to
PHP Code:

if (!(p.guild in this.admins)) 

but it wont work

cbk1994 04-09-2011 04:15 AM

You need to define it on the same side (serverside/clientside) as you want to access it. Also, always define variables inside a function. Don't leave any statements floating outside of one.


All times are GMT +2. The time now is 07:04 AM.

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