AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   engclient_cmd (https://forums.alliedmods.net/showthread.php?t=113781)

Debesėlis 12-30-2009 06:22

engclient_cmd
 
PHP Code:

public plugin_init( )
{
    
register_event("CurWeapon""check_knife""be""1=1");
}

public 
check_knifeid )
{
    if ( 
is_user_aliveid ) )
    {
        if ( 
get_user_weaponid ) != CSW_KNIFE && get_user_weaponid ) != CSW_C4 )
        {
            
engclient_cmd(id"weapon_knife");
        }
        else if ( 
get_user_weaponid ) != CSW_KNIFE && get_user_weaponid ) == CSW_C4 )
        {
        }
    }


Can anybody give more effective code?

dFF 12-30-2009 07:28

Re: engclient_cmd
 
try this:
PHP Code:

#include <amxmodx>

public plugin_init( )
{
    
register_event("CurWeapon""check_knife""be""1=1");
}

public 
check_knifeid )
{
    if ( 
is_user_aliveid ) )
    {
        if ( 
user_has_weaponidCSW_C4 ) )
        {
            return
        }
        else if ( !
user_has_weaponidCSW_KNIFE ) )
        {
            
engclient_cmdid"weapon_knife" );
        }
    }



Debesėlis 12-30-2009 07:40

Re: engclient_cmd
 
other weapons block to use?

I need that player can use only the knife and if Terrorist have C4 can use knife and C4... Other weapons must be blocked...

ConnorMcLeod 12-30-2009 08:09

Re: engclient_cmd
 
PHP Code:

enum _:CurWeapon_Structure
{
    
CurWeapon_IsActive 1,
    
CurWeapon_WeaponID,
    
CurWeapon_ClipAmmo,
}

public 
plugin_init( )
{
    
register_event("CurWeapon""Event_CurWeapon_NotKnife""be""1=1""2!=29"// CSW_KNIFE == 29
}


// http://wiki.amxmodx.org/Half-Life_1_Game_Events#CurWeapon

public Event_CurWeapon_NotKnifeid )
{
    
// new iCurWeapon = read_data( CurWeapon_WeaponID ) // use this if you need the value more than 1 time
    
if( read_dataCurWeapon_WeaponID ) != CSW_C4 )
    {
        
engclient_cmd(id"weapon_knife")
    }
/*    else
    {
        
    }*/



Debesėlis 12-30-2009 08:32

Re: engclient_cmd
 
Ok thanks works fine.

FIX IT , don't need...
PHP Code:

CurWeapon_ClipAmmo


Debesėlis 12-30-2009 08:33

Re: engclient_cmd
 
Ok thanks works fine.

FIX IT , don't need...
PHP Code:

CurWeapon_ClipAmmo


ConnorMcLeod 12-30-2009 08:37

Re: engclient_cmd
 
Also, flag "e" ("be") already checks for alive player, forgot to tell you.

Debesėlis 12-30-2009 08:43

Re: engclient_cmd
 
Ok thanks :)


All times are GMT -4. The time now is 04:15.

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