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 › Custom Nades
4 posts, 2 people · 1,181 views Thread Rating: ★★★★★
closedCustom Nades
Started by Merrill on 06-30-2010, 10:46 AM
M Merrill
started this thread
Posts: 38
Threads: 6
Joined: Sep 2005
06-30-2010, 10:46 AM #1

HellonnI'm trying to create a custom nade plugin allowing me to give rifles 3 nades vs 2. I took DO nade for all plugin and edited it. It complies correctly. I need help as I don't know where in the code or what to add to the code in order for the rifle class to have 3 nades.nnHere is Diamond Optics original worknn

//////////////////////////////////////////////////////////////////////////////////n//n//	DoD Nade For Alln//		- Version 1.1n//		- 08.06.2006n//		- diamond-optic (original code by FireStorm)n//n//////////////////////////////////////////////////////////////////////////////////n//n// Credit:n//n//   - Original Code by FireStorm (dod_nadeforall v0.5beta)n//n// Information:n//n//   - This will allow you to give snipers, mgs, and rocketsn//     a grenade when they spawn.n//n// CVARs:n//n//   dod_nadeforall "1" //Turn on(1)/off(0)n//n//   dod_nadeforall_snipers "1" //Turn on(1)/off(0) nade for snipersn//   dod_nadeforall_mgs "1" //Turn on(1)/off(0) nade for mgsn//   dod_nadeforall_rockets "1" //Turn on(1)/off(0) nade for rocketsn//n// Changelog:n//n//   - 05.27.2005 Version 0.5betan//	  Initial Release by FireStormn//n//   - 08.04.2006 Version 1.0 	****** FIX THIS DATE!!!!! ******n//  	  Modification of FireStorms original coden//n//   - 08.06.2006 Version 1.1n//  	  Changed some returnsn//	  Corrected Changelog mistaken//n//////////////////////////////////////////////////////////////////////////////////nn#include <amxmodx>n#include <fun>n#include <dodx>nnnew p_dod_nadeforall, p_dod_nadeforall_snipers, p_dod_nadeforall_mgs, p_dod_nadeforall_rocketsnnpublic plugin_init(){n	register_plugin("DoD NadeForAll","1.1","AMXX DoD Team")n	n	p_dod_nadeforall = register_cvar("dod_nadeforall","1")n	n	p_dod_nadeforall_snipers = register_cvar("dod_nadeforall_snipers","1")n	p_dod_nadeforall_mgs = register_cvar("dod_nadeforall_mgs","1")n	p_dod_nadeforall_rockets = register_cvar("dod_nadeforall_rockets","1")	nn	register_event("ResetHUD","check_class","be")n}nnpublic check_class(id){n	if((get_pcvar_num(p_dod_nadeforall) != 1) || !is_user_alive(id) || !is_user_connected(id) || is_user_hltv(id))n		return PLUGIN_CONTINUEn		n	new pclass = dod_get_user_class(id)n	n	if((get_pcvar_num(p_dod_nadeforall_snipers) == 1) && (pclass == DODC_SCHARFSCHUTZE || pclass == DODC_SNIPER || pclass == DODC_MARKSMAN)){n		set_task(0.1,"give_nade",id)n		return PLUGIN_CONTINUEn	}n	else if((get_pcvar_num(p_dod_nadeforall_mgs) == 1) && (pclass == DODC_MG34 || pclass == DODC_MG42 || pclass == DODC_30CAL)){n		set_task(0.1,"give_nade",id)n		return PLUGIN_CONTINUEn	}n	else if((get_pcvar_num(p_dod_nadeforall_rockets) == 1) && (pclass == DODC_PANZERJAGER || pclass == DODC_BAZOOKA || pclass == DODC_PIAT)){n		set_task(0.1,"give_nade",id)n		return PLUGIN_CONTINUEn	}nn	return PLUGIN_CONTINUEn}nnpublic give_nade(id){n	if(is_user_connected(id) == 1 && is_user_alive(id) == 1){ n		if(get_user_team(id) == 2){n			give_item(id, "weapon_stickgrenade")n		}n		else if(get_user_team(id) == 1){n			give_item(id, "weapon_handgrenade")n		}n	}n	return PLUGIN_HANDLEDn}nn
nnHere is the edited version I worked on.nn
//////////////////////////////////////////////////////////////////////////////////n//n//	DoD Nade For Alln//		- Version 1.1n//		- 08.06.2006n//		- diamond-optic (original code by FireStorm)n//n//////////////////////////////////////////////////////////////////////////////////n//n// Credit:n//n//   - Original Code by FireStorm (dod_nadeforall v0.5beta)n//n// Information:n//n//   - This will allow you to give snipers, mgs, and rocketsn//     a grenade when they spawn.n//n// CVARs:n//n//   dod_nadeforall "1" //Turn on(1)/off(0)n//n//   dod_nadeforall_snipers "1" //Turn on(1)/off(0) nade for snipersn//   dod_nadeforall_mgs "1" //Turn on(1)/off(0) nade for mgsn//   dod_nadeforall_rockets "1" //Turn on(1)/off(0) nade for rocketsn//n// Changelog:n//n//   - 05.27.2005 Version 0.5betan//	  Initial Release by FireStormn//n//   - 08.04.2006 Version 1.0 	****** FIX THIS DATE!!!!! ******n//  	  Modification of FireStorms original coden//n//   - 08.06.2006 Version 1.1n//  	  Changed some returnsn//	  Corrected Changelog mistaken//n//////////////////////////////////////////////////////////////////////////////////nn#include <amxmodx>n#include <fun>n#include <dodx>nnnew p_dod_nadeforall, p_dod_nadeforall_snipers, p_dod_nadeforall_mgs, p_dod_nadeforall_rockets, p_dod_nadeforall_riflesnnpublic plugin_init(){n	register_plugin("DoD NadeForAll","1.1","AMXX DoD Team")n	n	p_dod_nadeforall = register_cvar("dod_nadeforall","1")n	n	p_dod_nadeforall_snipers = register_cvar("dod_nadeforall_snipers","1")n	p_dod_nadeforall_mgs = register_cvar("dod_nadeforall_mgs","1")n	p_dod_nadeforall_rockets = register_cvar("dod_nadeforall_rockets","1")n	p_dod_nadeforall_rifles = register_cvar("dod_nadeforall_rifles","1")	nn	register_event("ResetHUD","check_class","be")n}nnpublic check_class(id){n	if((get_pcvar_num(p_dod_nadeforall) != 1) || !is_user_alive(id) || !is_user_connected(id) || is_user_hltv(id))n		return PLUGIN_CONTINUEn		n	new pclass = dod_get_user_class(id)n	n	if((get_pcvar_num(p_dod_nadeforall_snipers) == 1) && (pclass == DODC_SCHARFSCHUTZE || pclass == DODC_SNIPER || pclass == DODC_MARKSMAN)){n		set_task(0.1,"give_nade",id)n		return PLUGIN_CONTINUEn	}n	else if((get_pcvar_num(p_dod_nadeforall_mgs) == 1) && (pclass == DODC_MG34 || pclass == DODC_MG42 || pclass == DODC_30CAL)){n		set_task(0.1,"give_nade",id)n		return PLUGIN_CONTINUEn	}n	else if((get_pcvar_num(p_dod_nadeforall_rockets) == 1) && (pclass == DODC_PANZERJAGER || pclass == DODC_BAZOOKA || pclass == DODC_PIAT)){n		set_task(0.1,"give_nade",id)n		return PLUGIN_CONTINUEn	}n        else if((get_pcvar_num(p_dod_nadeforall_rifles) == 1) && (pclass == DODC_GARAND || pclass == DODC_CARBINE || pclass == DODC_K43 || pclass == DODC_KAR || pclass == DODC_ENFIELD)){n		set_task(0.1,"give_nade",id)n		return PLUGIN_CONTINUEn	}nn	return PLUGIN_CONTINUEn}nnpublic give_nade(id){n	if(is_user_connected(id) == 1 && is_user_alive(id) == 1){ n		if(get_user_team(id) == 2){n			give_item(id, "weapon_stickgrenade")n		}n		else if(get_user_team(id) == 1){n			give_item(id, "weapon_handgrenade")n		}n	}n	return PLUGIN_HANDLEDn}
nnHere are the lines I edited.nnnew p_dod_nadeforall, p_dod_nadeforall_snipers, p_dod_nadeforall_mgs, p_dod_nadeforall_rockets,p_dod_nadeforall_riflesnnp_dod_nadeforall_rifles = register_cvar("dod_nadeforall_rifles","1") nn}n else if((get_pcvar_num(p_dod_nadeforall_rifles) == 1) && (pclass == DODC_GARAND || pclass == DODC_CARBINE || pclass == DODC_K43 || pclass == DODC_KAR || pclass == DODC_ENFIELD)){n set_task(0.1,"give_nade",id)n return PLUGIN_CONTINUEn }nnI have never tried working on plugins before but read many post where it was encouraged to try creating it first before asking for help.nnWhat do I need to add to give rifle classes 3 nades?nnThanksnnMerrill

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
06-30-2010, 11:15 AM #2

Make a new one, start from 0 - Start by hooking the spawn..

M Merrill
started this thread
Posts: 38
Threads: 6
Joined: Sep 2005
06-30-2010, 12:41 PM #3

Thanks Dr.GrnrnI was able to get it working by adding the following line.rnrnset_task(0.2,"give_nade",id) rnrnThanks

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
06-30-2010, 03:09 PM #4

Yea you are on to it - Start from scratch, in the codes above you are looking at alot of stuff you dont know what is, and isnt needed for your plugin. Your project here is a good way to start, its small. Post when you need help, I will help you.. Start with the spawn stuff..rnrnYou can use the way spawn is hooked in D-O's plugin above, its fine. ResetHUD only happen once, when you spawn (ofcource with the right flags)..rnrnSee : http://www.amxmodx.org/funcwiki.php?search=register_event&go=search

Archive › Old Forum Threads › Help › Scripting Help › Custom Nades
DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC