AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Make it so user can not drop given weapon (https://forums.alliedmods.net/showthread.php?t=64781)

taheri6 12-24-2007 14:17

Make it so user can not drop given weapon
 
Hello,

I was wondering if any one knew of a good way to do this.

When the client is affected by a particular status, they are given a weapon which replaces their primary weapon. While that status is lasting, I do not want them to be able to drop that weapon so they could just then re-pickup their dropped weapon again.

in the search:
Code:

[...blah...]
UsedDepower[id] = 1;
depower_replace(id);
new parm[1];
parm[0] = id;
set_task( fcooldownTime, "reset_depowered", 50+id, parm, 1);
[...blah...]

in depower_replace
Code:

[...blah...]
        get_user_weapons( id , wpnList , number );

        for ( new i = 0; i < number; i++)
        {
                //Skip pistols, grenades, knife - only go for primary weapons
                if ( !IsWeaponPrimary( wpnList[i] ) )
                {
                        continue;
                }

                //Get the weapon name
                get_weaponname( wpnList[i] , wpname , 31 );
                //and make them drop it
                engclient_cmd( id , "drop" , wpname );

        }
        give_item( id , "weapon_tmp" );
        give_item( id , "ammo_9mm" );

        return PLUGIN_CONTINUE;
}

So basically when afflicted they drop their weapon and are given a TMP instead. But right now there is nothing stopping them from picking it back up right away.

Is there a good way (perhaps a native?) that wont cause a lag ?

Thank you in advance.

Alka 12-24-2007 14:28

Re: Make it so user can not drop given weapon
 
Make a global boolean "bool:BlockPickup[33]" then when you give tmp make boolean true "BlockPickup[id] = true" then hook Touch and block it.

Code:

#include <amxmodx>
#include <fakemeta>
 
#define PLUGIN "Block Pickup"
#define VERSION "1.0"
#define AUTHOR "Alka"

public plugin_init() {
 
 register_plugin(PLUGIN, VERSION, AUTHOR);
 
 register_forward(FM_Touch, "Fwd_Touch");
}
 
public Fwd_Touch(Ent, id)
{
 static model[32], classname[32];
 
 pev(Ent, pev_classname, classname , sizeof classname - 1);
 pev(Ent, pev_model, model, sizeof model - 1);
 
 if(containi(classname, "weapon_") != -1 && containi(model, "w_") != -1 && BlockPickup[id])
  return FMRES_SUPERCEDE;
 
 return FMRES_IGNORED;
}

And when you want that player be able to pickup weapons just make the boolean false "BlockPickup[id] = false".

taheri6 12-24-2007 17:26

Re: Make it so user can not drop given weapon
 
Thank you for your response, and forgive this noob question - but if changed to this:

Code:

public Fwd_Touch(Ent, id)
{
        static model[32], classname[32];

        pev(Ent, pev_classname, classname , sizeof classname - 1);
        pev(Ent, pev_model, model, sizeof model - 1);
       
        if( !equali( classname, "weapon_tmp" ) && BlockPickup[id] )
        {
                //message to client telling them of the blocked pickup
                client_print ( id, print_chat, "%L", id, "Message" );
                return FMRES_SUPERCEDE;
        }

        return FMRES_IGNORED;
}

Would that then allow them to not pick up any weapon except the TMP (or what ever weapon) I already gave them. In case they drop it trying to pick up their old weapon and now have nothing :)

taheri6 12-31-2007 18:17

Re: Make it so user can not drop given weapon
 
Alka - I tried it and it doesnt seem to work, can anyone offer any suggestions plz?

M249-M4A1 01-01-2008 02:37

Re: Make it so user can not drop given weapon
 
This is a pretty straightforward way to stop a user from dropping the USP. You could toy around with this:

PHP Code:

public plugin_init() { 
    
register_clcmd("drop""hookDrop"0


public 
hookDrop(id) { 
    if (
get_user_weapon(id) == CSW_USP) { 
        
client_print(idprint_chat"[AMXX] You are not allowed to drop the USP!"
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 



_Master_ 01-01-2008 10:54

Re: Make it so user can not drop given weapon
 
Take a look at the way gungame deals with this. It covers all the aspects of your problem.

taheri6 01-05-2008 17:27

Re: Make it so user can not drop given weapon
 
if I remember correctly gungame doesnt allow you to pick up a gun, I want to stop them from dropping it.

I'll check out what M249-M4A1 posted and let you guys know how it goes.

taheri6 01-11-2008 12:48

Re: Make it so user can not drop given weapon
 
"hookdrop" with a little customization to fit my needs worked like a charm, thank you!

pharse 01-12-2008 15:13

Re: Make it so user can not drop given weapon
 
PHP Code:

register_clcmd("drop""hookDrop"0

Does this work also with other client commands? At least I tried it with "name" which didn't work. How do I know which command works and which not?

pls don't say "trying" ;)

Lee 01-12-2008 16:49

Re: Make it so user can not drop given weapon
 
Yes - but not all - i.e. you can't block commands that don't send any information to the server. I believe it does work with 'name'. You need to return PLUGIN_HANDLED to block the engine call.


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

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