Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin
Archive › Old Forum Threads › General › Requests for DoD Plugins › No nades on certain maps
24 posts, 9 people · 11,887 views Thread Rating: ★★★★★
closedNo nades on certain maps
Started by Eleven0 on 03-14-2008, 11:46 PM
E Eleven0
started this thread
Posts: 22
Threads: 7
Joined: Apr 2007
03-14-2008, 11:46 PM #1

I want to get rid of nades on certain maps. Is there a plugin to restrict nades?rnrnI have "One weapon mod", but this gets rid of knife and pistol too.

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
04-15-2008, 09:20 AM #2

Try this...rnrn

#include <amxmisc>rn#include <fakemeta>rn#include <dodfun>rnrn#define PLUGIN "DOD_NoNades"rn#define VERSION "0.9"rn#define AUTHOR "Vet(3TT3V)"rnrn#define HAND_BIT (1 << DODW_HANDGRENADE)rn#define STICK_BIT (1 << DODW_STICKGRENADE)rnrnnew g_enabled = 0rnnew g_mapnames[][] = {rn   "dod_frenzy",rn   "dod_crazyjump",rn   "dod_rennes_b2"rn}rnrnpublic plugin_init()rn{rn	register_plugin(PLUGIN, VERSION, AUTHOR)rn	register_event("ResetHUD", "player_spawn", "be")rnrn	new mapname[32]rn	get_mapname(mapname, 31)rn	for (new i = 0; i < sizeof g_mapnames; i++) {rn		if (equali(mapname, g_mapnames[i])) {rn			g_enabled = 1rn			breakrn		}rn	}rn}rnrnpublic player_spawn(id)rn{rn	if (g_enabled) {rn		new pevdata = pev(id, pev_weapons)rn		if (get_user_team(id) == ALLIES) {rn			set_pev(id, pev_weapons, pevdata & ~HAND_BIT)rn			dod_set_user_ammo(id, DODW_HANDGRENADE, 0)rn			client_cmd(id, "weapon_handgrenade;lastinv")rn		} else {rn			set_pev(id, pev_weapons, pevdata & ~STICK_BIT)rn			dod_set_user_ammo(id, DODW_STICKGRENADE, 0)rn			client_cmd(id, "weapon_stickgrenade;lastinv")rn		}rn	}rn}
rnrnJust replace/add the maps (varable g_mapnames) with the ones you want.

Wilson [29th ID]
posted here
Posts: 623
Threads: 57
Joined: Oct 2005
04-15-2008, 11:11 AM #3

Great plugin Vet. Interesting that you have it subtracting the bit though. I've always used wpnbits & ~DODW_HANDGRENADE etc. Did you know about that and just find this a better method?

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
04-15-2008, 11:51 AM #4

I have trouble getting that bit shi(f)t stuff through my thick skull. But one question, wouldn'trnwpnbits & ~DODW_HANDGRENADErnclear bits 8, 4 and 1 (13)? Shouldn't I use something like...rn#DEFINE HAND_BIT (1 << DODW_HANDGRENADE)rnwpnbits & ~HAND_BIT ???rnNot sure. Like I said, bits give me headaches.rnrnAlso, I was thinking it may be wise to clear the pdata for the nades too, just in case. Because this method doesn't eliminate the nades, it only keeps you from selecting them. So I should probably add ...rndod_set_user_ammo(id, DODW_HANDGRENADE, 0) andrndod_set_user_ammo(id, DODW_STICKGRENADE, 0)rnto the routines. I know that if you use my dod_deathnades plugin with this, it will still drop the nades.rnrnI'll whip up a version that uses a .cfg for the applicable maps too. Make it sweeter.

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
04-15-2008, 08:01 PM #5

Found and fixed a couple glitches, You DO have to set the grenade ammo pdata to 0. Otherwise a clever player could still select a grenade by using the command weapon_handgrenade or weapon_stickgrenade. Also, while this prevented using grenades, it still produced a 'no-weapon' screen if the player used those commands. So I stuck in a quick-switch to update the game info. The above code has been updated to reflect these changes as well as implementing Wilson's weapon bit manipulation. ;)rnrnEDIT:rnSubsequent testing showed that when using a quick-switch to update the game info, you don't need to set the pev_weapons. Just setting the ammo and switching is good enough.

Wilson [29th ID]
posted here
Posts: 623
Threads: 57
Joined: Oct 2005
04-15-2008, 08:54 PM #6

hmm..the client_cmd() stuff seems a bit unreliable because lag will delay it..isn't sending those cmd's simply activating a CurWeapon that tells the client he "ain't got no nades"? Why not just send the CurWeapon?nnThis is just semantics - the plugin works fine I'm sure...just interested in the most efficient way as it seems you are :P

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
04-15-2008, 10:17 PM #7
isn't sending those cmd's simply activating a CurWeapon that tells the client he "ain't got no nades"?
I don't know. You would probably know better then me. I didn't notice any detectable lag when testing it. But in the interest of saving a few mils, I included the 'lastinv' with the command.rnrn
Why not just send the CurWeapon?
Would that be faster? If so, I'd gladly do it that way.rnrn
This is just semantics - the plugin works fine I'm sure...just interested in the most efficient way as it seems you are :P
rnAlways. And I appreciate the input. If you come up with anything else, let me know. I'll dink around with it a little more and see what happens.rnrnAlso, I figure it might be wise to leave those pev_weapons statements in there, 'just in case'.

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
04-15-2008, 11:40 PM #8

I tried it by sending CurWeapon message(s). But it only updated the HUD. It didn't actually switch the weapons. Either that or I didn't do it right.

Wilson [29th ID]
posted here
Posts: 623
Threads: 57
Joined: Oct 2005
04-16-2008, 10:53 AM #9

If you check out my Custom Supply plugin, which was quite effective at removing nades and making them unselectable, it does:nn1. A basic dod_set_user_ammo() for nades to 0n2. Sends an AmmoX message to have 0 backpack ammo (pretty sure this is done when you do the client_cmd() we were takling about)n

	message_begin(MSG_ONE,get_user_msgid("AmmoX"),{0,0,0},id);n	write_byte(AMMO_GREN);n	write_byte(0);n	message_end();
n3. Uses a remove_weapon() stock to stop nades from being selectednn
stock remove_weapon( id, wpnid ) {n	new m_bitmask = pev( id, pev_weapons );n	m_bitmask &= ~(1<<wpnid);n	n	set_pev( id, pev_weapons, m_bitmask );n}
Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
04-16-2008, 02:00 PM #10

Oh OK. I thought you meant to send a CurWeapon message. I'll do the Ammox thing and see how it goes.

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
04-16-2008, 06:54 PM #11

That work for the most part. But it didn't prevent the glitch I mentioned in post #5. If a player plays normally, there's no glitch. But if a player uses 'weapon_handgrenade' in console (or in a script), it will produce a blank screen. Once a player switches away from the blank screen, everythings OK after that. And repeating the command fails. Granted, its a very rare scenerio. But its still a glitch I'd just as soon avoid. Seems like something else internal to the game needs to get updated. Or maybe its something client-side that forcing the player to do a quick-switch takes care of.

E Eleven0
started this thread
Posts: 22
Threads: 7
Joined: Apr 2007
04-27-2008, 01:37 PM #12

I tried with the compiler on amxmodx.orgrnrnIt gave these errorsrnrn

Welcome to the AMX Mod X 1.76-300 Compiler.rnCopyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Teamrnrn/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : error 017: undefined symbol "pevdata"rn/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : warning 215: expression has no effectrn/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : error 001: expected token: ";", but found ")"rn/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : error 029: invalid expression, assumed zerorn/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : fatal error 107: too many error messages on one linernrnCompilation aborted.rn4 Errors.
Wilson [29th ID]
posted here
Posts: 623
Threads: 57
Joined: Oct 2005
04-27-2008, 03:36 PM #13

On line 37, changennnew wpnbits = pev(id, pev_weapons)nntonnnew pevdata = pev(id, pev_weapons)

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
04-27-2008, 11:41 PM #14

Ouch, my bad. Updated code.

T Tabor
posted here
Posts: 7
Threads: 0
Joined: Feb 2007
05-09-2008, 03:04 PM #15

hi all nI keep getting this error all the time using amx online compiler ntemp.sma(17) : error 001: expected token: "}", but found "-string-"nn1 Error.nCould not locate output file ../amxx/.DOD_NoNades1.80.amx (compile failed).nnnAny ideas

diamond-optic
posted here
Posts: 2,068
Threads: 103
Joined: May 2005
05-09-2008, 08:51 PM #16

it compiles fine for me locally on amxx 1.8.1nnalso fine on the dodplugins online compiler for 1.8.0nnand fine on the amxmodx.org online compiler (which i believe is 1.76d)

T Tabor
posted here
Posts: 7
Threads: 0
Joined: Feb 2007
05-11-2008, 07:22 AM #17

ok i can get it to compile fine now with 3 maps . but when i add any more maps to it and try compile it that is when it starts thowing up the errors

[ [SOL] Psycho
posted here
Posts: 60
Threads: 5
Joined: Dec 2007
05-11-2008, 09:45 AM #18

Is there a way to make this non map specific, so it can be enabled, disabled in the amxmodx/configs/maps/plugins-mapname.ini? This would save recompiling when one wanted to add a map. rnrnJust a thought.

Vet
posted here
Posts: 229
Threads: 24
Joined: Oct 2006
05-15-2008, 12:06 PM #19

For a quick/easy way, just change the line:rn

new g_enabled = 0
to...rn
new g_enabled = 1
rnand recompile it.rnrnOr compile this one...rn
#include <amxmisc>rn#include <fakemeta>rn#include <dodfun>rnrn#define PLUGIN "DOD_NoNades"rn#define VERSION "0.9x"rn#define AUTHOR "Vet(3TT3V)"rnrn#define HAND_BIT (1 << DODW_HANDGRENADE)rn#define STICK_BIT (1 << DODW_STICKGRENADE)rnrnpublic plugin_init()rn{rn	register_plugin(PLUGIN, VERSION, AUTHOR)rn	register_event("ResetHUD", "player_spawn", "be")rn}rnrnpublic player_spawn(id)rn{rn	new pevdata = pev(id, pev_weapons)rn	if (get_user_team(id) == ALLIES) {rn		set_pev(id, pev_weapons, pevdata & ~HAND_BIT)rn		dod_set_user_ammo(id, DODW_HANDGRENADE, 0)rn		client_cmd(id, "weapon_handgrenade;lastinv")rn	} else {rn		set_pev(id, pev_weapons, pevdata & ~STICK_BIT)rn		dod_set_user_ammo(id, DODW_STICKGRENADE, 0)rn		client_cmd(id, "weapon_stickgrenade;lastinv")rn	}rn}
rnEither way should work.

[ [SOL] Psycho
posted here
Posts: 60
Threads: 5
Joined: Dec 2007
05-15-2008, 02:05 PM #20

Thank you Vet. This should come in handy. I tried the first way already and it works fine. I am sure the second will also. For what it is worth, I also took the map names from between the "" before compiling.

Z zak1212
posted here
Posts: 12
Threads: 2
Joined: Jul 2005
10-13-2008, 11:04 AM #21

should this only work for one side as i notice the code saysrnrnif (get_user_team(id) == ALLIES)rnrnand no mention of axis

Tank
posted here
Posts: 581
Threads: 59
Joined: Jan 2007
10-13-2008, 12:19 PM #22
if (get_user_team(id) == ALLIES)rn
rnrnIf is part of something called the If, Then, Else statement.rnrnIf "answer to question is yes"rnThen "do this"rnElse "so if the question is no, it uses this coding"rnrnSo to answer your question it should work for both teams. No time to check the coding though.

[ [SOL] Psycho
posted here
Posts: 60
Threads: 5
Joined: Dec 2007
10-13-2008, 02:20 PM #23

It works for both teams.

A anders
posted here
Posts: 2
Threads: 0
Joined: Oct 2008
10-18-2008, 09:43 PM #24

Hey psycho its stryker ha ha ha, i really need the hook...rnI cant find it :(

Archive › Old Forum Threads › General › Requests for DoD Plugins › No nades on certain maps
DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC