Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin
Archive › Old Forum Threads › Help › Scripting Help › Why don't I get nades?
7 posts, 3 people · 899 views Thread Rating: ★★★★★
closedWhy don't I get nades?
Started by Tank on 12-29-2008, 02:18 PM
Tank
started this thread
Posts: 581
Threads: 59
Joined: Jan 2007
12-29-2008, 02:18 PM #1

Am I doing something wrong here?nn

new amm_grenades[8]	// contains the amount grenades
nn
// Saving current player's ammount of grenadesn	amm_grenades[id] = dod_get_user_ammo(id, DODW_HANDGRENADE) + dod_get_user_ammo(id, DODW_STICKGRENADE)
nn
//=========================================================n// Nade menun//=========================================================npublic display_menu_nade(id)n{n	new szMenuBody[512]n	// new mkeys = 0b0000000011n	new mkeys = 3n	new Len = format(szMenuBody,511,NADE_MENU)n	n	Len += format( szMenuBody[Len], 511, "^n
1. wAxis Stickgrenade")n	Len += format( szMenuBody[Len], 511, "^n
2. wAllied Handgrenade")n	//Len += format( szMenuBody[Len], 511, "^n
3. wBritish Millsgrenade")n	n	show_menu(id,mkeys,szMenuBody,25)n}nn//=========================================================n// Choices Nade menu, this is also where the menu stopsn//=========================================================npublic control_choice_nade(id,key)n{n	if(!is_user_alive(id))n		return PLUGIN_CONTINUEn		n	switch (key)n	{n		case 0: give_grenade(id, "weapon_stickgrenade")n		case 1: give_grenade(id, "weapon_handgrenade")n	}n	return PLUGIN_HANDLEDn}nn//=========================================================n// Giving to player old amount of grenadesn//=========================================================npublic give_grenade(id, type[])n{n	for(new i=0; i<amm_grenades[id]; i++)n		give_item(id, type)n}
Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
12-29-2008, 02:42 PM #2

Try this maybe (not tested!):rnrn

//=========================================================rn// Choices Nade menu, this is also where the menu stopsrn//=========================================================rnpublic control_choice_nade(id,key)rn{    rn	if(!is_user_alive(id))        rn		return PLUGIN_HANDLED          rn	switch (key)    rn	{        rn		case 0: give_grenade1(id)        rn		case 1: give_grenade2(id)    rn		}    rn	return PLUGIN_CONTINUErn}rn//=========================================================rn// Give nadern//=========================================================rnrnpublic give_grenade1(id)rn{    rn	if(is_user_alive(id))               rn		give_item(id,"weapon_stickgrenade") rn} rnpublic give_grenade2(id)rn{    rn	if(is_user_alive(id))               rn		give_item(id,"weapon_handgrenade") rn} 
Tank
started this thread
Posts: 581
Threads: 59
Joined: Jan 2007
12-29-2008, 02:50 PM #3

Im giving the player a custom weapon loadout, so I save the amount of nades they have before stripping everything and after the stripping I want to return them to them in the nade class they choose.rnrnThe only problem is that I don't get a single nade. Your way would work would that would just always give them a nade. I figure once my players find out I can change my name to 24/7 nade fest.

H h0_noMan
posted here
Posts: 80
Threads: 11
Joined: Dec 2007
12-29-2008, 03:18 PM #4

Tank, i tried your plugin (that i corrected) and it worked fine on my server.rnGrenades where given without any problems.rnrnEDIT : Replace your return PLUGIN_HANDLED by a PLUGIN_CONTINUE in your control_choice_nade function.

Tank
started this thread
Posts: 581
Threads: 59
Joined: Jan 2007
12-29-2008, 04:14 PM #5

EDIT:nnIm sorry, I always play Allies and I forgot to check for Axis. Funny thing, it seems to work perfectly for Axis, I get both my nades, however Allies don't get any.

H h0_noMan
posted here
Posts: 80
Threads: 11
Joined: Dec 2007
12-29-2008, 11:35 PM #6

While testing Tank's Plugin, i found some errors in the dod_get_user_ammo() function. (Only on linux server)rnrnThis plugin works now very well.rn- Axis grenades are in the DODW_HANDGRENADE (instead of DODW_STICKGRENADE)rn- Allies grenades are in DODW_BAR (and all heavy weapons) instead of DODW_HANDGRENADErnrnSee here : https://www.dodplugins.net/forums/showthread.php?p=11535

Tank
started this thread
Posts: 581
Threads: 59
Joined: Jan 2007
12-30-2008, 02:15 PM #7

I have to say, this plugin works as a blast now thanks to h0 noMan, awesome stuff :D Tres Bien.rnrnAll which is left is to find a way to store options chosen in the menu and this plugin is ready to be used :D

Archive › Old Forum Threads › Help › Scripting Help › Why don't I get nades?
DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC