AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weapon Pickup Block (https://forums.alliedmods.net/showthread.php?t=134460)

GXLZPGX 08-04-2010 22:32

Weapon Pickup Block
 
How would I go about blocking anyone from picking up a weapon if a bool is true?

DarkGod 08-04-2010 22:34

Re: Weapon Pickup Block
 
I saw you looked into it before (I stalked your profile) so you should know how to just block it. Loop through all players and if player has the bool set true, block, else don't.

Simple as that. I'm just too lazy to check up the actual code.


Edit: You could try this:
PHP Code:

#include < amxmodx >
#include < hamsandwich >

public plugin_init( ) {
    
register_plugin"No Weapon Pickup""1.0""xPaw" );
    
    
RegisterHamHam_Touch"weaponbox""FwdHamPlayerWeaponTouch" );
    
RegisterHamHam_Touch"armoury_entity""FwdHamPlayerWeaponTouch" );
}

public 
FwdHamPlayerWeaponTouch( const iEntity, const id )
    return 
g_LastRequest HAM_SUPERCEDE HAM_IGNORED


GXLZPGX 08-04-2010 22:40

Re: Weapon Pickup Block
 
Quote:

Originally Posted by DarkGod (Post 1261985)
I saw you looked into it before (I stalked your profile) so you should know how to just block it. Loop through all players and if player has the bool set true, block, else don't.

Simple as that. I'm just too lazy to check up the actual code.

I'm not exactly sure how to go about it. If someone could possibly "help" me (give me the code) i would love them.

DarkGod 08-04-2010 22:41

Re: Weapon Pickup Block
 
Updated my post.

GXLZPGX 08-04-2010 22:47

Re: Weapon Pickup Block
 
Quote:

Originally Posted by DarkGod (Post 1261985)
I saw you looked into it before (I stalked your profile) so you should know how to just block it. Loop through all players and if player has the bool set true, block, else don't.

Simple as that. I'm just too lazy to check up the actual code.


Edit: You could try this:
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new bool:CanPickup[33] = true

public plugin_init()
{
    
register_plugin"Block Weapon Pickup""1.0""Wrecked" )
    
    new 
classname[20// weapon_smokegrenade (19) + 1
    
    
for( new CSW_P228<= CSW_P90i++ )
    {
        if ( 
get_weaponnameiclassnamecharsmaxclassname ) ) )
        {
            
RegisterHamHam_Item_Deployclassname"HamItemDeployPre")
            
/* Other forwards that you could've used:
                * Ham_AddPlayerItem
                * Ham_Item_CanDeploy
                * Ham_Touch
            */
        
}
    }
}

public 
HamItemDeployPreweapon )
{
    new 
players[32], numindex
    get_players
(playersnum)
    
    for(new 
inumi++)
    {
        
index players[i]
        
        if(!
CanPickup[index])
            return 
HAM_SUPERCEDE// blocks function call
    
}
    
    return 
HAM_IGNORED



Nothing I've tried has worked. It's pissing me off.

PHP Code:

public HamItemDeployPreweapon )
{
    new 
players[32], num;
    
get_players(playersnum)
    
    for(new 
inumi++)
    {
        if( 
gLastRequest )
        {
            return 
HAM_SUPERCEDE;
        }
    }
    
    return 
HAM_IGNORED



DarkGod 08-04-2010 22:57

Re: Weapon Pickup Block
 
My bad on that. It was wrecked who coded it wrong from the start. This just fucked things up, lol. Sec, I'll see if I can find some other way.

Edit: Updated first post. Tested and works.

wrecked_ 08-04-2010 23:12

Re: Weapon Pickup Block
 
Fixed it in the tutorial as well.

GXLZPGX 08-05-2010 00:22

Re: Weapon Pickup Block
 
I've tried like 6 methods and it still hasn't worked. The bool doesn't have an index, but I'm sure thats not the problem. I have it set the bool to true whenever an LR(last request) is in progress. So it SHOULD block it if gLastRequest is true. I don't have a clue whats wrong.

DarkGod 08-05-2010 00:23

Re: Weapon Pickup Block
 
Quote:

Originally Posted by GXLZPGX (Post 1262030)
I've tried like 6 methods and it still hasn't worked. The bool doesn't have an index, but I'm sure thats not the problem. I have it set the bool to true whenever an LR(last request) is in progress. So it SHOULD block it if gLastRequest is true. I don't have a clue whats wrong.

I tested it myself and that last method definitely works.

GXLZPGX 08-05-2010 00:28

Re: Weapon Pickup Block
 
Quote:

Originally Posted by DarkGod (Post 1262031)
I tested it myself and that last method definitely works.

If you'd like I'll give you the whole code on pastebin. Hold on.


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

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