PHP Code:
#include <amxconst>
is not needed, it is automaticly included with <amxmodx>
PHP Code:
Params[0] = get_cvar_num("amx_NadeSpawn_Time") //Param[0] = Spawn time for a nade
Params[1] = get_cvar_num("amx_NadeSpawn_Type") //Param[1] = Type of nade (1 = He | 2 = Flash | 3 = Smoke)
You should use pcvars, because they are faster. Like this:
PHP Code:
new cvar_type, cvar_time
public plugin_init() {
new NadeSpawnOn = 1 //used by Toogle
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("amx_NadeSpawn_Toogle", "Toogle") //Toogle's NadeSpawn on and off
cvar_type = register_cvar("amx_NadeSpawn_Type", "1") //which type of grenade
cvar_time = register_cvar("amx_NadeSpawn_Time", "5") //Time in sec before grenade spawns
register_clcmd("amx_NadeSpawn_Help", "Help") //Displays some help in the console
//Define Parameters for SpawnNade loop:
new Params[2]
Params[0] = get_pcvar_num(cvar_time) //Param[0] = Spawn time for a nade
Params[1] = get_pcvar_num(cvar_type) //Param[1] = Type of nade (1 = He | 2 = Flash | 3 = Smoke)
Use a switch here:
PHP Code:
public PreSpawnNade(SpawnTime, numNadeType, id) {
//check what nade we are spawning..
if (numNadeType == 1) {
set_task(float(SpawnTime), "SpawnHE")
}
if (numNadeType == 2) {
set_task(float(SpawnTime), "SpawnFlash")
}
if (numNadeType == 3) {
set_task(float(SpawnTime), "SpawnSmoke")
}
}
PHP Code:
public PreSpawnNade(SpawnTime, numNadeType, id) {
//check what nade we are spawning..
switch(numNadeType)
{
case 1:
set_task(float(SpawnTime), "SpawnHE")
case 2:
set_task(float(SpawnTime), "SpawnFlash")
case 3:
set_task(float(SpawnTime), "SpawnSmoke")
}
}
instead of setting bpammo, use give_item from
PHP Code:
#include <fun>
give_item(id, "weapon_hegrenade")
and it doesn't work because you use id in preSpawnNade, but you don't got id there. I recommend using hamsandwich to detecht player spawn, and call that function there.
__________________