AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] How to get this Event? (https://forums.alliedmods.net/showthread.php?t=143392)

foxxx 11-19-2010 06:00

[Help] How to get this Event?
 
Sometimes player will get a pistol at roundstart,
(like: T get a glock with 40bpammo; CT get a usp with 24bpammo.)
How to get this Event?
Can the glock/usp be changed to other pistol?

SaM.ThE.MaN 11-19-2010 12:38

Re: [Help] How to get this Event?
 
yeah u can change it , using hamspawn ... first : if user team is CT and if user weapon = usp , then do ur func
else if user team is T and if user weapon = glock
do ur func

Bugsy 11-19-2010 13:27

Re: [Help] How to get this Event?
 
Try something like this, check the weapon in addplayeritem fwd.

Untested, written mostly on my phone. You will need to add additional checks to see if player was just spawned.

PHP Code:

RegisterHam(Ham_AddPlayerItem"player""AddPlayerItem");

public 
AddPlayerItem(ClEnt)
{
        new 
iWeapID cs_get_weapon_idEnt );

        
//prevent item from being given
        
if ( condition )
        {
               
SetHamReturnInteger(false);
 
               return 
HAM_SUPERCEDE;
        }

        return 
HAM_IGNORED;



hleV 11-20-2010 03:30

Re: [Help] How to get this Event?
 
Quote:

Originally Posted by Bugsy (Post 1352489)
Try something like this, check the weapon in addplayeritem fwd.

Untested, written mostly on my phone. You will need to add additional checks to see if player was just spawned.

PHP Code:

RegisterHam(Ham_AddPlayerItem"player""AddPlayerItem");
 
public 
AddPlayerItem(ClEnt)
{
        new 
iWeapID cs_get_weapon_idEnt );
 
        
//prevent item from being given
        
if ( condition )
        {
               
SetHamReturnInteger(false);
 
               return 
HAM_SUPERCEDE;
        }
 
        return 
HAM_IGNORED;



You should also kill the entity
Code:
entity_set_int(Ent, EV_INT_flags, FL_KILLME);

Bugsy 11-20-2010 11:43

Re: [Help] How to get this Event?
 
Quote:

Originally Posted by hleV (Post 1352790)
You should also kill the entity
Code:
entity_set_int(Ent, EV_INT_flags, FL_KILLME);

Buy or pickup a primary weapon and then say "hi". Test again with SetHamReturnInteger( 0 ) and return HAM_SUPERCEDE commented out.

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new g_iWeaponEnt;

public 
plugin_init()
{
    
RegisterHamHam_AddPlayerItem "player" "fw_HamAddPlayerItem" );
    
    
register_clcmd"say hi" "TestFunc" );
}

public 
fw_HamAddPlayerItemid iWeapon )
{
    if( 
ExecuteHamHam_Item_ItemSlot iWeapon ) == )
    {
        
g_iWeaponEnt iWeapon;
        
        
client_printid print_chat "Primary weapon blocked" );
        
        
SetHamReturnInteger);
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}  

public 
TestFuncid )
{
    
client_printid print_chat "Weapon Exists ? %s" pev_validg_iWeaponEnt ) ? "true" "false" );




All times are GMT -4. The time now is 11:22.

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