Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   check if player is staff (https://forums.graalonline.com/forums/showthread.php?t=134261608)

cbk1994 01-08-2011 09:11 PM

Quote:

Originally Posted by Skyld (Post 1621373)
PHP Code:

function isStaff(temp.account)
{
  return 
temp.account in serveroptions.staff;


... just to save you from all that ridiculous index() nonsense.

I use index because it's case-insensitive and therefore better for player input. You can use in if you want but it would have to be

PHP Code:

function isStaff(account) {
  return 
account in serveroptions.staff.tokenize(",");



DustyPorViva 01-08-2011 09:22 PM

Try:
PHP Code:

temp.acc "salesman";
echo(
temp.acc in (serveroptions.staff));
echo((
serveroptions.staff).size()); 


salesman 01-08-2011 09:26 PM

Quote:

Originally Posted by DustyPorViva (Post 1621381)
Try:
PHP Code:

temp.acc "salesman";
echo(
temp.acc in (serveroptions.staff));
echo((
serveroptions.staff).size()); 


Still zero for both.

DustyPorViva 01-08-2011 09:28 PM

Well I did notice it won't create an array if there are any spaces/improper formatting. You have to enclose anything like that(say, a staff member with spaces in their account) in quotes for it to work right.

Crow 01-08-2011 09:31 PM

Strangely, this stuff works for me now. I had to use tokenize() in the past, but I just tried simple array operations, and they work. Strange :confused:

cbk1994 01-08-2011 09:32 PM

Quote:

Originally Posted by Crow (Post 1621385)
Strangely, this stuff works for me now. I had to use tokenize() in the past, but I just tried simple array operations, and they work. Strange :confused:

This is probably why:
Quote:

Originally Posted by DustyPorViva (Post 1621383)
Well I did notice it won't create an array if there are any spaces/improper formatting. You have to enclose anything like that(say, a staff member with spaces in their account) in quotes for it to work right.

Nice find Dusty.

Crow 01-08-2011 09:44 PM

Quote:

Originally Posted by cbk1994 (Post 1621386)
This is probably why:

None of the items in the "list" here on Atlantis ever had spaces, and it didn't work just a while ago. Now it does. We also had a server restart recently, maybe something was changed in the way how this thing works.

xXziroXx 01-08-2011 10:14 PM

PHP Code:

function isStaff(account)
  return 
account in serveroptions.staff.tokenize(","); 

If anything, this looks best.


All times are GMT +2. The time now is 11:39 PM.

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