Raised This Month: $12 Target: $400
 3% 

Check if entity is a player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LightningZLaser
Member
Join Date: Dec 2010
Old 12-31-2010 , 08:13   Check if entity is a player
Reply With Quote #1

I'm making a prop spawning script which includes a function deleting the prop. I successfully made a delete function which deletes entities, but the problem is that it also deletes the bots when I was testing.

So, how do I make it to check if an entity index is a client?

Thx.
LightningZLaser is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-31-2010 , 08:33   Re: Check if entity is a player
Reply With Quote #2

0 < entity < 33 usually.
__________________
FaTony is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 12-31-2010 , 09:39   Re: Check if entity is a player
Reply With Quote #3

use "<= MaxClients" not "< 33" as games like css can have up to 64 players.
blodia is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-31-2010 , 10:20   Re: Check if entity is a player
Reply With Quote #4

PHP Code:
if ( (<= clientID <= MaxClients) ) // IsValidClient
if ( !(<= clientID <= MaxClients) ) // Is Invalid :D 
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Monkeys
Veteran Member
Join Date: Jan 2010
Old 12-31-2010 , 14:58   Re: Check if entity is a player
Reply With Quote #5

Quote:
Originally Posted by xbatista View Post
PHP Code:
if ( (<= clientID <= MaxClients) ) // IsValidClient
if ( !(<= clientID <= MaxClients) ) // Is Invalid :D 
Neither of those will work. (You'll have to split it in two with ANDs)
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-31-2010 , 15:43   Re: Check if entity is a player
Reply With Quote #6

Why ? :0
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Afronanny
Veteran Member
Join Date: Aug 2009
Old 12-31-2010 , 16:13   Re: Check if entity is a player
Reply With Quote #7

PHP Code:
if (<= clientID && clientID <= MaxClients// IsValidClient
if (!(<= clientID && clientID <= MaxClients)) // Is Invalid :D 
Afronanny is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-31-2010 , 16:15   Re: Check if entity is a player
Reply With Quote #8

Why the hell I need to do so? :0
If it's easier by my way :0
__________________
xbatista is offline
Send a message via Skype™ to xbatista
Afronanny
Veteran Member
Join Date: Aug 2009
Old 12-31-2010 , 16:21   Re: Check if entity is a player
Reply With Quote #9

Try to compile your way, you'll see
Afronanny is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 12-31-2010 , 16:25   Re: Check if entity is a player
Reply With Quote #10

Here I'm using in my code
PHP Code:
bool:IsValidClientclient )
{
    if ( !( 
<= client <= MaxClients ) || !IsClientInGame(client) )
        return 
false;
    
    return 
true;

Works like a charm
__________________
xbatista is offline
Send a message via Skype™ to xbatista
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 11:28.


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