Hi,
I got a problem when remove entity created by owner when owner disconnect from server. You can see an example code that i used in server. I got this error log:
Code:
L 07/27/2011 - 17:17:46: [ENGINE] Invalid player 12 (not in-game)
L 07/27/2011 - 17:17:46: [AMXX] Displaying debug trace (plugin "TestCreateEntity.amxx")
L 07/27/2011 - 17:17:46: [AMXX] Run time error 10: native error (native "find_ent_by_owner")
And this is the code:
PHP Code:
public client_disconnect(id)
{
//I want remove all ent created by owner when he disconnect from server.
RemoveUserEntity(id)
}
public EventRoundStart()
{
RemoveAllBananaEntity()
}
//Cl_cmd
public CreateBananaEnt(id)
{
if(!is_user_alive(id)) return PLUGIN_HANDLED
if(pev(id, pev_flags) & FL_ONGROUND)
{
CreateTripEntity(id)
}
return PLUGIN_HANDLED
}
CreateTripEntity(id)
{
static Float:origin[3], ent
pev(id, pev_origin, origin)
ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if(pev_valid(ent))
{
set_pev(ent, pev_classname, "banana_ent")
set_pev(ent, pev_origin, origin)
engfunc(EngFunc_SetModel, ent, MODEL_BANANA)
engfunc(EngFunc_SetSize, ent, Float:{-3.0, -3.0, -3.0}, Float:{3.0, 3.0, 3.0})
set_pev(ent, pev_solid, 1)
set_pev(ent, pev_movetype, 6)
set_pev(ent, pev_sequence, 1)
set_pev(ent, pev_owner, id)
set_rendering(ent, kRenderFxGlowShell, 30, 30, 30, kRenderTransAlpha, 10)
emit_sound(ent, CHAN_VOICE, SOUND_BANANA, 1.0, ATTN_NORM, 0, PITCH_NORM)
client_print(id, print_center, "Banana entity has been created")
}
}
//Remove all ent created by owner
RemoveUserEntity(id)
{
new ent = find_ent_by_owner(-1, "banana_ent", id, 0)
while(ent > 0)
{
if(pev_valid(ent)) remove_entity(ent)
ent = find_ent_by_owner(-1, "banana_ent", id, 0)
}
}
//Remove all banana ent found on map
RemoveAllBananaEntity()
{
new ent = find_ent_by_class(-1, "banana_ent")
while(ent > 0)
{
remove_entity(ent)
ent = find_ent_by_class(-1, "banana_ent")
}
}
All i want to do is remove all entity created by owner when he left the server.
__________________