AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with Flag's within this script! (https://forums.alliedmods.net/showthread.php?t=89133)

Kitami 04-02-2009 17:30

Help with Flag's within this script!
 
Hey guys when I try to change the FLAG used to give the admin this ability it doesnt register all the admins get the boost regardless of if they have the flag or not.

This was done by a member of the community requested here,
http://forums.alliedmods.net/showthread.php?t=88521

Code:

    #include <amxmodx>
    #include <fakemeta>
    #include <hamsandwich>
   
    const MAX_CLIENTS = 32;
    new bool:gCanSpeed[ MAX_CLIENTS + 1 ];
   
    new pCvarKnifeSpeed;
    new pCvarKnifeFlags;
   
    public plugin_init()
    {
        register_plugin( "Knife Speed", "1.0.0", "Arkshine" );
       
        pCvarKnifeSpeed = register_cvar( "knife_speed", "400" );
        pCvarKnifeFlags = register_cvar( "knife_flags", "a" );
       
        RegisterHam( Ham_CS_Item_GetMaxSpeed, "weapon_knife", "Event_ChangeKnifeSpeed" );
    }

    public client_putinserver( Client )
    {
        gCanSpeed[ Client ] = !!( get_user_flags( Client ) & GetFlagsFromCvar() );
    }
   
    public Event_ChangeKnifeSpeed ( const Entity )
    {
        if ( gCanSpeed[ pev( Entity, pev_owner ) ] )
        {
            SetHamReturnFloat( get_pcvar_float( pCvarKnifeSpeed ) );
            return HAM_SUPERCEDE;
        }
       
        return HAM_IGNORED;
    }
   
    GetFlagsFromCvar ()
    {
        static Flags[ 26 ];
        get_pcvar_string( pCvarKnifeFlags, Flags, charsmax( Flags ) );

        return read_flags( Flags );
    }

Thanks guys :)

Arkshine 04-02-2009 19:39

Re: Help with Flag's within this script!
 
What flags did you write ?

Kitami 04-05-2009 14:44

Re: Help with Flag's within this script!
 
I used M and T

Arkshine 04-06-2009 08:50

Re: Help with Flag's within this script!
 
You have written knife_flags "mt" ? Are you sure that the cvar well changed ?

Kitami 04-07-2009 11:33

Re: Help with Flag's within this script!
 
No I mean I tried m, and then I tried t.
Not both of those flags together.

I changed it correctly and I checked it 3 or 4 times.

pCvarKnifeSpeed = register_cvar( "knife_speed", "335" );
pCvarKnifeFlags = register_cvar( "knife_flags", "m" );

YamiKaitou 04-07-2009 11:49

Re: Help with Flag's within this script!
 
PHP Code:

gCanSpeedClient ] = !!( get_user_flagsClient ) & GetFlagsFromCvar() ); 

Why the double ! mark?

Arkshine 04-07-2009 11:53

Re: Help with Flag's within this script!
 
@YamiKaitou : To get 0 or 1.

a & b ;
if true : will give a, then '!' will give 0 and the second '!' will give 1.
if false: will give 0, then '!' will give 1 and the second '!' will give 0.

edit : @Kitami : just tested, it works fine for me. I've removed 'm' in users.ini ; changed 'a' to 'm' in the plugin, and when I'm on the server, I don't have the speed. I've debugged too, nothing wrong.


All times are GMT -4. The time now is 02:20.

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