Raised This Month: $ Target: $400
 0% 

[SOLVED] find_ent_by_owner() on client_disconnect()


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 07-27-2011 , 06:54   [SOLVED] find_ent_by_owner() on client_disconnect()
Reply With Quote #1

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(idpev_flags) & FL_ONGROUND)
    {
        
CreateTripEntity(id)
    }

        return 
PLUGIN_HANDLED
}

CreateTripEntity(id)
{
    static 
Float:origin[3], ent
    pev
(idpev_originorigin)
    
    
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
    if(
pev_valid(ent))
    {
        
set_pev(entpev_classname"banana_ent")
        
set_pev(entpev_originorigin)
        
engfunc(EngFunc_SetModelentMODEL_BANANA)
        
engfunc(EngFunc_SetSizeentFloat:{-3.0, -3.0, -3.0}, Float:{3.03.03.0})
        
set_pev(entpev_solid1)
        
set_pev(entpev_movetype6)
        
set_pev(entpev_sequence1)
        
set_pev(entpev_ownerid)
        
set_rendering(entkRenderFxGlowShell303030kRenderTransAlpha10)
        
emit_sound(entCHAN_VOICESOUND_BANANA1.0ATTN_NORM0PITCH_NORM)
        
client_print(idprint_center"Banana entity has been created")
    }
}

//Remove all ent created by owner
RemoveUserEntity(id)
{
    new 
ent find_ent_by_owner(-1"banana_ent"id0)
    while(
ent 0)
    {
        if(
pev_valid(ent)) remove_entity(ent)
        
ent find_ent_by_owner(-1"banana_ent"id0)
    }
}

//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.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 04-22-2012 at 14:45. Reason: Solved
yokomo is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode