AlliedModders

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

SGT 11-05-2011 13:53

Restricting weapons
 
How do I restrict only one player from picking up weapons if a condition is met?

Basically what I'm trying to do is restrict weapon pickup to the person that buys an item from a shop plugin I have. Buyzones are already blocked, I just need the player to not be able to pick up weapons.

Devil259 11-05-2011 22:14

Re: Restricting weapons
 
Code:
#include <amxmodx> #include <hamsandwich> public plugin_init() {     register_plugin( "Block Weapon Pickup", "1.0", "Wrecked" )         RegisterHam( Ham_Touch, "weaponbox", "HamTouchPre", 0 )     RegisterHam( Ham_Touch, "armoury_entity", "HamTouchPre", 0 ) } public HamTouchPre( weapon ) {     if( /* condition */ )     {         return HAM_SUPERCEDE; // blocks function call     } }

http://forums.alliedmods.net/showthr...ghlight=common

Bugsy 11-05-2011 22:31

Re: Restricting weapons
 
Other things can touch weapons besides a player. With register_touch you can hook only a weapon\player touch.

You can hook only one or the other of these or both:
weaponbox = dropped weapons
armoury_entity = weapons that sit on ground at map start (fy_iceworld, fy_snow etc).

PHP Code:

#include <amxmodx>
#include <engine>

public plugin_init() 
{
    
register_touch"weaponbox" "player" "WeaponTouch" );
    
register_touch"armoury_entity" "player" "WeaponTouch" );
}

public 
WeaponTouchiWeapon iPlayer )
{
    return ( 
/* condition */ ) ? PLUGIN_HANDLED PLUGIN_CONTINUE;



ConnorMcLeod 11-06-2011 04:26

Re: Restricting weapons
 
If you use Hamsandwich's way (both are fine), check player range :

PHP Code:

#include <amxmodx>
#include <hamsandwich>

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

public plugin_init()
{
    
RegisterHamHam_Touch"weaponbox""Weapon_Touch")
    
RegisterHamHam_Touch"armoury_entity""Weapon_Touch")
    
RegisterHamHam_Touch"weapon_shield""Weapon_Touch")
    
g_iMaxPlayers get_maxplayers()
}

public 
Weapon_TouchiWeaponid )
{
    if( 
IsPlayer(id) && is_user_alive(id) && /* condition */ )
    {
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED




All times are GMT -4. The time now is 14:16.

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