Raised This Month: $ Target: $400
 0% 

Restricting weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SGT
Senior Member
Join Date: Sep 2011
Old 11-05-2011 , 13:53   Restricting weapons
Reply With Quote #1

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.
SGT is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 11-05-2011 , 22:14   Re: Restricting weapons
Reply With Quote #2

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
Devil259 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-05-2011 , 22:31   Re: Restricting weapons
Reply With Quote #3

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;

__________________

Last edited by Bugsy; 11-05-2011 at 22:31.
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-06-2011 , 04:26   Re: Restricting weapons
Reply With Quote #4

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

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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