AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Reading single char from string (https://forums.alliedmods.net/showthread.php?t=11545)

xiiph 03-22-2005 14:59

Reading single char from string
 
This is what I want to do:
I want to make a script that check if someone is regged on a forum. It will do this by checking for a specific access flag, lets say "n".

And if the server is full, it should kick one of the unregistred players when a registred player try to connect (this should therefore also give access to a reserved slot).

_Any_ other tips that might help me do this is Greaty appreciated. But to the main question:

How do I check the value I get from get_user_flags() (<--- think thats the one with access flags...?) for a specific flag, in this case, "n".

All flags for a normal registred user (not admin, or immune) would be bmn.

All help appreciated, thank you.

Twilight Suzuka 03-22-2005 15:15

try containi, contain, or regex.

XxAvalanchexX 03-22-2005 17:05

Actually, in this case, you wouldn't search a string.

Code:
#include <amxmisc> .. if(access(id,ADMIN_LEVEL_B)) {    ... }

xeroblood 03-22-2005 17:09

Re: Reading single char from string
 
Quote:

Originally Posted by xiiph
How do I check the value I get from get_user_flags() (<--- think thats the one with access flags...?) for a specific flag, in this case, "n".

From amxconst.inc:
Code:
#define ADMIN_LEVEL_B       (1<<13) /* flag "n" */

So, use:

Code:
if( get_user_flags( id ) & ADMIN_LEVEL_B ) {     // the user 'id' has flag 'n' }

Edit: the access() function that Avalanche posted is the exact same thing as what I wrote above, but it requires you include <amxmisc>

Remember tho, get_user_flags() returns a BitSum of the flags, not actual characters... to convert it to the character flags (and vice-versa), use these from amxmodx.inc:

Code:
/* Converts string to sum of bits. * Example: "abcd" is a sum of 1, 2, 4 and 8. */ native read_flags(const flags[]); /* Converts sum of bits to string. * Example: 3 will return "ab". */ native get_flags(flags,output[],len);

Edit: :P Avalanche, you posted just b4 me..


All times are GMT -4. The time now is 09:56.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.