Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-09-2011, 03:46 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
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
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #2  
Old 04-09-2011, 03:52 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
PHP Code:
if (! (element in array)) { 
This will work fine. Note that it is case-sensitive.
__________________
Reply With Quote
  #3  
Old 04-09-2011, 03:53 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
Your second example should work, you might need to post more of your script...you probably have an error somewhere else.
__________________

Reply With Quote
  #4  
Old 04-09-2011, 03:54 AM
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
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.
__________________
Quote:
Reply With Quote
  #5  
Old 04-09-2011, 03:56 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
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 (
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(codekeyscancode)
  {
  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
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 04-09-2011 at 03:59 AM.. Reason: fixd PHP tags
Reply With Quote
  #6  
Old 04-09-2011, 04:15 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
Reply


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 09:47 PM.


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