| closedNo nades on certain maps |
| Started by Eleven0 on 03-14-2008, 11:46 PM |
Threads: 7
Joined: Apr 2007
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.
Threads: 24
Joined: Oct 2006
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.Threads: 57
Joined: Oct 2005
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?
Threads: 24
Joined: Oct 2006
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.
Threads: 24
Joined: Oct 2006
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.
Threads: 57
Joined: Oct 2005
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
Threads: 24
Joined: Oct 2006
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 :PrnAlways. 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'.
Threads: 24
Joined: Oct 2006
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.
Threads: 57
Joined: Oct 2005
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 selectednnstock 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}Threads: 24
Joined: Oct 2006
Oh OK. I thought you meant to send a CurWeapon message. I'll do the Ammox thing and see how it goes.
Threads: 24
Joined: Oct 2006
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.
Threads: 7
Joined: Apr 2007
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.
Threads: 57
Joined: Oct 2005
On line 37, changennnew wpnbits = pev(id, pev_weapons)nntonnnew pevdata = pev(id, pev_weapons)
Threads: 24
Joined: Oct 2006
Ouch, my bad. Updated code.
Threads: 0
Joined: Feb 2007
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
Threads: 103
Joined: May 2005
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)
Threads: 0
Joined: Feb 2007
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
Threads: 5
Joined: Dec 2007
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.
Threads: 24
Joined: Oct 2006
For a quick/easy way, just change the line:rn
new g_enabled = 0to...rnnew g_enabled = 1rnand 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.Threads: 5
Joined: Dec 2007
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.
Threads: 2
Joined: Jul 2005
should this only work for one side as i notice the code saysrnrnif (get_user_team(id) == ALLIES)rnrnand no mention of axis
Threads: 59
Joined: Jan 2007
if (get_user_team(id) == ALLIES)rnrnrnIf 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.Threads: 5
Joined: Dec 2007
It works for both teams.
Threads: 0
Joined: Oct 2008
Hey psycho its stryker ha ha ha, i really need the hook...rnI cant find it :(

