AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Blocking all weapons picking up. (https://forums.alliedmods.net/showthread.php?t=120517)

reinert 03-05-2010 15:52

Blocking all weapons picking up.
 
hey, can someone give me a code that blocks all weapons pickup.

i got a code for only AWP, should i add other model ID's ? or there is another code :
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

#define CanGetAwp(%1)    ( get_user_flags(%1) & ADMIN_LEVEL_H )

new const VERSION[] = "1.0"

const MAX_PLAYERS 32

new gmsgTextMsg

new g_iLastTouchedBox[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_plugin("NO AWP BUY"VERSION"SOMEONE")

    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1)

    
register_touch("weaponbox""player""WeaponBox_Touch")

    
register_menucmd(register_menuid("T_BuyRifle"1), (1<<4), "BuyRifle")
    
register_menucmd(register_menuid("CT_BuyRifle"1), (1<<5), "BuyRifle")

    
gmsgTextMsg get_user_msgid("TextMsg")
}

public 
Player_Spawn_Postid )
{
    
g_iLastTouchedBox[id] = 0
}

public 
WeaponBox_Touch(iWpnBxid)
{
    if( 
is_user_alive(id) && entity_get_int(iWpnBxEV_INT_flags) & FL_ONGROUND )
    {
        const 
XTRA_OFS_WEAPONBOX 4
        
const m_rgpPlayerItems_wpnbx_slot1 35

        
static iWeapon
        iWeapon 
get_pdata_cbase(iWpnBxm_rgpPlayerItems_wpnbx_slot1XTRA_OFS_WEAPONBOX)
        if( 
iWeapon && cs_get_weapon_id(iWeapon) == CSW_AWP )
        {
            if( 
g_iLastTouchedBox[id] != iWpnBx )
            {
                if( !
user_has_weapon(idCSW_AWP))
                {
                    
Message_No_Awp(id)
                }
                
g_iLastTouchedBox[id] = iWpnBx
            
}
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE
}

public 
BuyRifle(id)
{
    if( !
CanGetAwpid ) )
    {
        
Message_No_Awp(id)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_command(id)
{
    static 
szCommand[8]

    if( 
read_argv(0szCommandcharsmax(szCommand)) < && bCheckArgAwp(idszCommand) )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
CS_InternalCommand(id, const szCommand[])
{
    if( 
strlen(szCommand) < && bCheckArgAwp(idszCommand) )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

bool:bCheckArgAwp(id, const szCommand[])
{
    static const 
awp[] = "awp"
    
static const magnum[] = "magnum"

    
if(    !CanGetAwpid )
    &&    ( 
equali(szCommandawp) || equali(szCommandmagnum) )    )
    {
        
Message_No_Awp(id)
        return 
true
    
}
    return 
false
}

Message_No_Awp(id)
{
    const 
HUD_PRINTCENTER    =    4
    
static const szOnlyVIP[] = "AWP tik VIP Žaidėjams" 

    
message_begin(MSG_ONE_UNRELIABLEgmsgTextMsg, .player=id)
    
write_byteHUD_PRINTCENTER )
    
write_stringszOnlyVIP )
    
message_end()



wrecked_ 03-05-2010 16:08

Re: Blocking all weapons picking up.
 
return PLUGIN_HANDLED;

at the end of WeaponBox_Touch

Bugsy 03-05-2010 16:24

Re: Blocking all weapons picking up.
 
This works but can be optimized to avoid reading the model name. Im on my phone now but can do it for you later if nobody has chimed in yet.

http://forums.alliedmods.net/showpos...97&postcount=4

ConnorMcLeod 03-05-2010 17:06

Re: Blocking all weapons picking up.
 
This is my code, and model name is not read.


Block All Weapons PickUP :

PHP Code:

#include <amxmodx>
#include <engine>

public plugin_init()
{
    
register_touch("weaponbox""player""lol")



reinert 03-06-2010 02:36

Re: Blocking all weapons picking up.
 
like:

PHP Code:

public WeaponBox_Touch(iWpnBxid)
{
    return 
PLUGIN_CONTINUE


???

lazarev 03-06-2010 04:32

Re: Blocking all weapons picking up.
 
http://forums.alliedmods.net/showpos...14&postcount=4

hleV 03-06-2010 05:11

Re: Blocking all weapons picking up.
 
Advanced version:
PHP Code:

#include <amxmodx>
#include <engine>
 
public plugin_init()
{
        
register_plugin("No Weapon Pickup""1.0""hleV");
 
        new const 
szPlayer[] = "player";
 
        
register_touch("weaponbox"szPlayer"");
        
register_touch("armoury_entity"szPlayer"");
        
register_touch("weapon_shield"szPlayer"");



ConnorMcLeod 03-06-2010 06:30

Re: Blocking all weapons picking up.
 
Final version, remove those weapons will prevent fonctions from being caled a lot.

PHP Code:

#define REMOVE_WEAPONS

#include <amxmodx>
#if defined REMOVE_WEAPONS
    #include <fakemeta>
#endif
#include <hamsandwich>

new const VERSION[] = "0.0.1"

new g_iMaxPlayers
#define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

public plugin_init()
{
    
register_plugin("No Weapons Pickup"VERSION"ConnorMcLeod")

    
RegisterHam(Ham_Touch"weaponbox""GroundWeaponTouch")
    
RegisterHam(Ham_Touch"armoury_entity""GroundWeaponTouch")
    
RegisterHam(Ham_Touch"weapon_shield""GroundWeaponTouch")

    
g_iMaxPlayers get_maxplayers()
}

public 
GroundWeaponTouch(iEntid)
{
    if( 
IsPlayer(id) )
    {
        
#if defined REMOVE_WEAPONS
            
set_pev(iEntpev_flagsFL_KILLME)
            
dllfunc(DLLFunc_ThinkiEnt)
        
#endif
        
return HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED



hleV 03-06-2010 06:52

Re: Blocking all weapons picking up.
 
PHP Code:

#include <amxmodx>
#include <engine>
 
public plugin_init()
{
        
register_plugin("No Weapon Pickup""1.1""hleV");
 
        new const 
szPlayer[] = "player";
 
        
#if defined REMOVE_WEAPONS
                
new const szTouch[] = "fwdTouch";
        
#else
                
new const szTouch[] = "";
        
#endif
 
        
register_touch("weaponbox"szPlayerszTouch);
        
register_touch("armoury_entity"szPlayerszTouch);
        
register_touch("weapon_shield"szPlayerszTouch);
}
 
#if defined REMOVE_WEAPONS
public fwdTouch(iEntity)

        if (!
is_valid_ent(iEntity))
                return 
PLUGIN_CONTINUE;
 
        
call_think(iEntity);
 
        return 
PLUGIN_HANDLED;
}
#endif 


ConnorMcLeod 03-06-2010 07:05

Re: Blocking all weapons picking up.
 
Quote:

Originally Posted by hleV (Post 1109306)
PHP Code:

#include <amxmodx>
#include <engine>
 
public plugin_init()
{
        
register_plugin("No Weapon Pickup""1.1""hleV");
 
        new const 
szPlayer[] = "player";
 
        
#if defined REMOVE_WEAPONS
                
new const szTouch[] = "fwdTouch";
        
#else
                
new const szTouch[] = "";
        
#endif
 
        
register_touch("weaponbox"szPlayerszTouch);
        
register_touch("armoury_entity"szPlayerszTouch);
        
register_touch("weapon_shield"szPlayerszTouch);
}
 
#if defined REMOVE_WEAPONS
public fwdTouch(iEntityiClient)
{
        if (!
is_valid_ent(iEntity))
                return 
PLUGIN_CONTINUE;
 
        
call_think(iEntity);
 
        return 
PLUGIN_HANDLED;
}
#endif 


Lol @ stupidity


All times are GMT -4. The time now is 08:43.

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