Raised This Month: $ Target: $400
 0% 

Make it so user can not drop given weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
taheri6
Member
Join Date: Mar 2006
Old 12-24-2007 , 14:17   Make it so user can not drop given weapon
Reply With Quote #1

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.
taheri6 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 12-24-2007 , 14:28   Re: Make it so user can not drop given weapon
Reply With Quote #2

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".
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
taheri6
Member
Join Date: Mar 2006
Old 12-24-2007 , 17:26   Re: Make it so user can not drop given weapon
Reply With Quote #3

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

Last edited by taheri6; 12-24-2007 at 17:41.
taheri6 is offline
taheri6
Member
Join Date: Mar 2006
Old 12-31-2007 , 18:17   Re: Make it so user can not drop given weapon
Reply With Quote #4

Alka - I tried it and it doesnt seem to work, can anyone offer any suggestions plz?
taheri6 is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 01-01-2008 , 02:37   Re: Make it so user can not drop given weapon
Reply With Quote #5

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 

__________________
M249-M4A1 is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 01-01-2008 , 10:54   Re: Make it so user can not drop given weapon
Reply With Quote #6

Take a look at the way gungame deals with this. It covers all the aspects of your problem.
_Master_ is offline
taheri6
Member
Join Date: Mar 2006
Old 01-05-2008 , 17:27   Re: Make it so user can not drop given weapon
Reply With Quote #7

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.
__________________
http://www.yaur.com -=[Yaur]=- Clan Website
taheri6 is offline
taheri6
Member
Join Date: Mar 2006
Old 01-11-2008 , 12:48   Re: Make it so user can not drop given weapon
Reply With Quote #8

"hookdrop" with a little customization to fit my needs worked like a charm, thank you!
__________________
http://www.yaur.com -=[Yaur]=- Clan Website
taheri6 is offline
pharse
Senior Member
Join Date: Jan 2008
Location: Germany, BW
Old 01-12-2008 , 15:13   Re: Make it so user can not drop given weapon
Reply With Quote #9

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" ;)
pharse is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 01-12-2008 , 16:49   Re: Make it so user can not drop given weapon
Reply With Quote #10

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.
Lee is offline
Reply


Thread Tools
Display Modes

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 11:06.


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