Raised This Month: $ Target: $400
 0% 

[SOLVED] find_ent_by_owner() on client_disconnect()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-27-2011 , 12:24   Re: [Help] find_ent_by_owner() on client_disconnect()
Reply With Quote #1

Hmm, wouldn't this:
Code:
    while(ent > 0)
    {
        remove_entity(ent)
        ent = find_ent_by_class(-1, "banana_ent")
    }
...make an infinite loop ? since find_ent_by_class() would always return the same entity over and over...

Anyway... you should use ent instead of -1 there and asign ent to -1 when you create it... but I'm gonna add the owner check aswell:
Code:
new ent = -1
// "id" is player's entity id

while((ent = find_ent_by_class(ent, "banana_ent")) != 0)
{
    if(entity_get_int(ent, EV_ENT_owner) == id)
        remove_entity(ent)
}
__________________

Last edited by Hunter-Digital; 07-27-2011 at 12:40.
Hunter-Digital is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-27-2011 , 12:32   Re: [Help] find_ent_by_owner() on client_disconnect()
Reply With Quote #2

Quote:
Originally Posted by Hunter-Digital View Post
...make an infinnite loop ? since find_ent_by_class() would always return the same entity over and over...
It can't return the same entity after it is removed.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-27-2011 , 12:39   Re: [Help] find_ent_by_owner() on client_disconnect()
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
It can't return the same entity after it is removed.
Oh right =) but if it didn't remove that entity the loop would've failed.

Still, it would be faster to input the entity back to the function to limit the search range... just pointing it out.

EDIT: Also, AFAIK, it would also be useless to check for valid entity since that function only returns valid entities... reference to yokomo's last edit.
__________________

Last edited by Hunter-Digital; 07-27-2011 at 12:41.
Hunter-Digital is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 07-27-2011 , 14:56   Re: [Help] find_ent_by_owner() on client_disconnect()
Reply With Quote #4

Ok after 2 hours in server using this code:
PHP Code:
RemovePlayerEntity(id

    static 
ent 
    ent 
= -
     
    
while ((ent find_ent_by_class(entCLASSNAME))) 
    { 
        if(
pev(entpev_owner) != id
            continue 
         
        if(
pev_valid(ent)) remove_entity(ent
    } 

No error log found yet thanks guys.
__________________
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
yokomo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-27-2011 , 14:58   Re: [Help] find_ent_by_owner() on client_disconnect()
Reply With Quote #5

You could try to hook FM_ClientDisconnect PRE and then send find_ent_by_owner, but if you need only a specific classname, then the code you actually have is ok.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



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