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

[Solved] Check if user is Connected


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheKidz
Senior Member
Join Date: May 2009
Old 11-15-2010 , 15:10   [Solved] Check if user is Connected
Reply With Quote #1

what is the best way ?

PHP Code:
 is_user_connectedindex 
or

PHP Code:
new bool:g_Connected33 ];

public 
client_connectedid g_Connectedid ] = true

public client_disconnectedid g_Connectedid ] = false

stock bool
:isConnectedindex ) return g_Connectedindex ] ? true false 
__________________
TheKidz is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 11-15-2010 , 15:32   Re: Check if user is Connected
Reply With Quote #2

How often are you checking it?
__________________
hleV is offline
TheKidz
Senior Member
Join Date: May 2009
Old 11-15-2010 , 15:34   Re: Check if user is Connected
Reply With Quote #3

what u mean with often ?
__________________
TheKidz is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 11-15-2010 , 15:58   Re: Check if user is Connected
Reply With Quote #4

How much do you check this function in your plugin.....
bibu is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-15-2010 , 16:07   Re: Check if user is Connected
Reply With Quote #5

If you are checking if user is connected for example when you execute command where player is a target then using is_user_connected(id) is fine, but if you loop through all players in prethink then caching is_user_connected is better however your method is not the best. You should use something like this:
PHP Code:
new _pg_is_ced
#define _IsUserConnected(%1) ( _pg_is_ced & 1<<(%1) )
#define _SetUserConnected(%1) _pg_is_ced |= 1<<(%1)
#define _SetUserNotConnected(%1) _pg_is_ced &= ~( 1<<(%1) )

public client_connectedid _SetUserConnected(id)

public 
client_disconnectedid _SetUserNotConnected(id)

public 
some_function(id){
    if(
_IsUserConnected(id)){
        
//code...
    
}

__________________
Impossible is Nothing
Sylwester is offline
TheKidz
Senior Member
Join Date: May 2009
Old 11-15-2010 , 16:29   Re: Check if user is Connected
Reply With Quote #6

i check if is user connected like a billion of times in my code, everything is checked :/
bcoz i got too many players count, tasks, etcetera
and btw, there is another way without bitsum ?
__________________
TheKidz is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 11-15-2010 , 16:35   Re: Check if user is Connected
Reply With Quote #7

Quote:
Originally Posted by TheKidz View Post
i check if is user connected like a billion of times in my code, everything is checked :/
bcoz i got too many players count, tasks, etcetera
and btw, there is another way without bitsum ?
Use bitsum.
__________________
hleV is offline
TheKidz
Senior Member
Join Date: May 2009
Old 11-15-2010 , 16:38   Re: Check if user is Connected
Reply With Quote #8

but it really worth change is_user_connected( index ) to bitsums ? just wondering
__________________
TheKidz is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 11-15-2010 , 16:42   Re: Check if user is Connected
Reply With Quote #9

You could use an array, but a bitsum would be more efficient.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
TheKidz
Senior Member
Join Date: May 2009
Old 11-15-2010 , 17:59   Re: Check if user is Connected
Reply With Quote #10

Thanks. Solved ;*
__________________
TheKidz 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 09:41.


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