PDA

View Full Version : No nades on certain maps


Eleven0
03-15-2008, 12:46 AM
I want to get rid of nades on certain maps. Is there a plugin to restrict nades?

I have "One weapon mod", but this gets rid of knife and pistol too.

Vet
04-15-2008, 10:20 AM
Try this...

#include <amxmisc>
#include <fakemeta>
#include <dodfun>

#define PLUGIN "DOD_NoNades"
#define VERSION "0.9"
#define AUTHOR "Vet(3TT3V)"

#define HAND_BIT (1 << DODW_HANDGRENADE)
#define STICK_BIT (1 << DODW_STICKGRENADE)

new g_enabled = 0
new g_mapnames[][] = {
"dod_frenzy",
"dod_crazyjump",
"dod_rennes_b2"
}

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("ResetHUD", "player_spawn", "be")

new mapname[32]
get_mapname(mapname, 31)
for (new i = 0; i < sizeof g_mapnames; i++) {
if (equali(mapname, g_mapnames[i])) {
g_enabled = 1
break
}
}
}

public player_spawn(id)
{
if (g_enabled) {
new pevdata = pev(id, pev_weapons)
if (get_user_team(id) == ALLIES) {
set_pev(id, pev_weapons, pevdata & ~HAND_BIT)
dod_set_user_ammo(id, DODW_HANDGRENADE, 0)
client_cmd(id, "weapon_handgrenade;lastinv")
} else {
set_pev(id, pev_weapons, pevdata & ~STICK_BIT)
dod_set_user_ammo(id, DODW_STICKGRENADE, 0)
client_cmd(id, "weapon_stickgrenade;lastinv")
}
}
}

Just replace/add the maps (varable g_mapnames) with the ones you want.

Wilson [29th ID]
04-15-2008, 12:11 PM
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
04-15-2008, 12:51 PM
I have trouble getting that bit shi(f)t stuff through my thick skull. But one question, wouldn't
wpnbits & ~DODW_HANDGRENADE
clear bits 8, 4 and 1 (13)? Shouldn't I use something like...
#DEFINE HAND_BIT (1 << DODW_HANDGRENADE)
wpnbits & ~HAND_BIT ???
Not sure. Like I said, bits give me headaches.

Also, 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 ...
dod_set_user_ammo(id, DODW_HANDGRENADE, 0) and
dod_set_user_ammo(id, DODW_STICKGRENADE, 0)
to the routines. I know that if you use my dod_deathnades plugin with this, it will still drop the nades.

I'll whip up a version that uses a .cfg for the applicable maps too. Make it sweeter.

Vet
04-15-2008, 09:01 PM
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. ;)

EDIT:
Subsequent 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]
04-15-2008, 09:54 PM
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?

This is just semantics - the plugin works fine I'm sure...just interested in the most efficient way as it seems you are :P

Vet
04-15-2008, 11:17 PM
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.

Why not just send the CurWeapon?Would that be faster? If so, I'd gladly do it that way.

This is just semantics - the plugin works fine I'm sure...just interested in the most efficient way as it seems you are :P
Always. 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.

Also, I figure it might be wise to leave those pev_weapons statements in there, 'just in case'.

Vet
04-16-2008, 12:40 AM
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]
04-16-2008, 11:53 AM
If you check out my Custom Supply plugin, which was quite effective at removing nades and making them unselectable, it does:

1. A basic dod_set_user_ammo() for nades to 0
2. Sends an AmmoX message to have 0 backpack ammo (pretty sure this is done when you do the client_cmd() we were takling about)
message_begin(MSG_ONE,get_user_msgid("AmmoX"),{0,0,0},id);
write_byte(AMMO_GREN);
write_byte(0);
message_end();
3. Uses a remove_weapon() stock to stop nades from being selected

stock remove_weapon( id, wpnid ) {
new m_bitmask = pev( id, pev_weapons );
m_bitmask &= ~(1<<wpnid);

set_pev( id, pev_weapons, m_bitmask );
}

Vet
04-16-2008, 03:00 PM
Oh OK. I thought you meant to send a CurWeapon message. I'll do the Ammox thing and see how it goes.

Vet
04-16-2008, 07:54 PM
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.

Eleven0
04-27-2008, 02:37 PM
I tried with the compiler on amxmodx.org

It gave these errors

Welcome to the AMX Mod X 1.76-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : error 017: undefined symbol "pevdata"
/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : error 001: expected token: ";", but found ")"
/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpvTcKCI.sma(39) : fatal error 107: too many error messages on one line

Compilation aborted.
4 Errors.

Wilson [29th ID]
04-27-2008, 04:36 PM
On line 37, change

new wpnbits = pev(id, pev_weapons)

to

new pevdata = pev(id, pev_weapons)

Vet
04-28-2008, 12:41 AM
Ouch, my bad. Updated code.

Tabor
05-09-2008, 04:04 PM
hi all
I keep getting this error all the time using amx online compiler
temp.sma(17) : error 001: expected token: "}", but found "-string-"

1 Error.
Could not locate output file ../amxx/.DOD_NoNades1.80.amx (compile failed).


Any ideas

diamond-optic
05-09-2008, 09:51 PM
it compiles fine for me locally on amxx 1.8.1

also fine on the dodplugins online compiler for 1.8.0

and fine on the amxmodx.org online compiler (which i believe is 1.76d)

Tabor
05-11-2008, 08:22 AM
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
05-11-2008, 10:45 AM
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.

Just a thought.

Vet
05-15-2008, 01:06 PM
For a quick/easy way, just change the line:
new g_enabled = 0to...
new g_enabled = 1
and recompile it.

Or compile this one...
#include <amxmisc>
#include <fakemeta>
#include <dodfun>

#define PLUGIN "DOD_NoNades"
#define VERSION "0.9x"
#define AUTHOR "Vet(3TT3V)"

#define HAND_BIT (1 << DODW_HANDGRENADE)
#define STICK_BIT (1 << DODW_STICKGRENADE)

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("ResetHUD", "player_spawn", "be")
}

public player_spawn(id)
{
new pevdata = pev(id, pev_weapons)
if (get_user_team(id) == ALLIES) {
set_pev(id, pev_weapons, pevdata & ~HAND_BIT)
dod_set_user_ammo(id, DODW_HANDGRENADE, 0)
client_cmd(id, "weapon_handgrenade;lastinv")
} else {
set_pev(id, pev_weapons, pevdata & ~STICK_BIT)
dod_set_user_ammo(id, DODW_STICKGRENADE, 0)
client_cmd(id, "weapon_stickgrenade;lastinv")
}
}
Either way should work.

[SOL] Psycho
05-15-2008, 03:05 PM
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.

zak1212
10-13-2008, 12:04 PM
should this only work for one side as i notice the code says

if (get_user_team(id) == ALLIES)

and no mention of axis

Tank
10-13-2008, 01:19 PM
if (get_user_team(id) == ALLIES)


If is part of something called the If, Then, Else statement.

If "answer to question is yes"
Then "do this"
Else "so if the question is no, it uses this coding"

So to answer your question it should work for both teams. No time to check the coding though.

[SOL] Psycho
10-13-2008, 03:20 PM
It works for both teams.

anders
10-18-2008, 10:43 PM
Hey psycho its stryker ha ha ha, i really need the hook...
I cant find it :(