I make this, but it give runtime error 4: index out of bounds.
normally i would check if he is alive and if he is a player to fix this, but this is none of those, and idea how i can fix this. And if this sucks, tell it and i'll do something else instead.
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
new Float: height[33]
new bool: FirstThink[33] = false
new bool: StopThink[33] = false
public plugin_init()
{
register_plugin("Mario Bros Death", "1.0", "Drekes")
register_event("ClCorpse", "Event_ClCorpse", "b")
register_event("DeathMsg", "Event_DeathMsg", "b")
register_forward(FM_Think, "Fw_Think")
}
public Event_ClCorpse(id)
return PLUGIN_HANDLED
public Event_DeathMsg(id)
{
// Get info from real corpse
new model[12]
cs_get_user_model(id, model, 11)
new Float: origin[3]
pev(id, pev_origin, origin)
make_new_corpse(id, model, Float: origin)
}
public make_new_corpse(id, model[12], Float: origin[3])
{
// Start making new corpse
new corpse = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
set_pev(corpse, pev_classname, "fake_corpse")
engfunc(EngFunc_SetModel, corpse, model)
set_pev(corpse, pev_solid, 2)
set_pev(corpse, pev_origin, origin)
set_pev(corpse, pev_animtime, 2.0)
set_pev(corpse, pev_framerate, 1.0)
set_pev(corpse, pev_sequence, 54)
FirstThink[corpse] = true
StopThink[corpse] = false
}
public Fw_Think(corpse)
{
if(StopThink[corpse])
return
if(FirstThink[corpse])
{
height[corpse] = 0.0
FirstThink[corpse] = false
}
new classname[32]
new Float: DeadOrigin[3]
pev(corpse, pev_classname, classname, 31)
pev(corpse, pev_origin, DeadOrigin)
if (!equal(classname, "fake_corpse"))
return
set_pev(corpse, pev_nextthink, get_gametime() + 0.1)
dllfunc(DLLFunc_Think, corpse)
height[corpse] += 0.5
if(height[corpse] >= 100.0)
{
drop_corpse(corpse)
StopThink[corpse] = true
}
}
public drop_corpse(corpse)
{
if(FirstThink[corpse])
{
height[corpse] = 0.0
FirstThink[corpse] = false
}
new classname[32]
new Float: DeadOrigin[3]
pev(corpse, pev_classname, classname, 31)
pev(corpse, pev_origin, DeadOrigin)
if (!equal(classname, "fake_corpse"))
return
height[corpse] -= 0.5
if(height[corpse] <= -100.0)
{
drop_corpse(corpse)
}
}
__________________