i've been thinking but i don't know how to check if he has been up 100 units and down -100 units without using the bools. Could you give an example how to do that?
And can i even check a model and origin on victim in DeathMsg?
Or should i use Ham_Killed in pre?
I changed my code a bit:
now it spawns the model, but he won't go up. I still have the bools because idk how to do it otherwise.
And the original body still spawns to.
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <cstrike>
#include <hamsandwich>
#define SetFirstThink(%1,%2) entity_set_int( %1, EV_INT_iuser1, %2 )
#define CheckFirstThink(%1) entity_get_int( %1, EV_INT_iuser1 )
#define SetStopThink(%1,%2) entity_set_int( %1, EV_INT_iuser2, %2 )
#define CheckStopThink(%1) entity_get_int( %1, EV_INT_iuser2 )
#define SetHeight(%1,%2) entity_set_float( %1, EV_FL_fuser1, %2 )
#define GetHeight(%1) entity_get_float( %1, EV_FL_fuser1 )
#define IsPlayer(%1) (1<=%1<=g_maxplayers)
// new Float: height[33]
new bool: corpse_up
new bool: corpse_down
// new g_maxplayers
public plugin_init()
{
register_plugin("Mario Bros Death", "1.0", "Drekes")
register_event("ClCorpse", "Event_ClCorpse", "b")
RegisterHam(Ham_Killed, "player", "Event_Ham_Killed_Pre", 0)
register_think("dead","Fw_Think")
// g_maxplayers = get_maxplayers()
}
public plugin_precache()
{/*
precache_model("models/player/arctic/arctic.mdl")
precache_model("models/player/terror/terror.mdl")
precache_model("models/player/leet/leet.mdl")
precache_model("models/player/guerilla/guerilla.mdl")
precache_model("models/player/urban/urban.mdl")
precache_model("models/player/gign/gign.mdl")
precache_model("models/player/gsg9/gsg9.mdl")
precache_model("models/player/sas/sas.mdl")*/
precache_model("models/player/mario/mario.mdl")
}
public Event_ClCorpse(id)
return PLUGIN_HANDLED
public Event_Ham_Killed_Pre(victim, attacker)
{/*
if(IsPlayer(victim))
return*/
// Get info from real corpse
new model[12]
cs_get_user_model(victim, model, 11)
new Float: origin[3]
pev(victim, pev_origin, origin)
make_new_corpse(victim, 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, "dead")
engfunc(EngFunc_SetModel, corpse, "models/player/mario/mario.mdl")
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)
corpse_up = true
}
public Fw_Think(corpse)
{
if(!is_valid_ent(corpse))
SetStopThink(corpse, 1)
if(CheckStopThink(corpse))
return
if(CheckFirstThink(corpse))
SetFirstThink(corpse, 0)
new Float: flHeight = GetHeight(corpse)
if(corpse_up)
{
if(GetHeight(corpse) >= 100.0)
{
corpse_up = false
corpse_down = true
}
flHeight += 0.5
}
if(corpse_down)
{
if(GetHeight(corpse) <= -100.0)
{
corpse_down = false
}
flHeight -= 0.5
}
SetHeight(corpse, flHeight)
if(!corpse_up && !corpse_down)
{
SetStopThink(corpse, 1)
remove_task(corpse)
remove_entity(corpse)
}
}
__________________