AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Check if user is Connected (https://forums.alliedmods.net/showthread.php?t=143176)

TheKidz 11-15-2010 15:10

[Solved] Check if user is Connected
 
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 


hleV 11-15-2010 15:32

Re: Check if user is Connected
 
How often are you checking it?

TheKidz 11-15-2010 15:34

Re: Check if user is Connected
 
what u mean with often ?

bibu 11-15-2010 15:58

Re: Check if user is Connected
 
How much do you check this function in your plugin.....

Sylwester 11-15-2010 16:07

Re: Check if user is Connected
 
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...
    
}



TheKidz 11-15-2010 16:29

Re: Check if user is Connected
 
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 ?

hleV 11-15-2010 16:35

Re: Check if user is Connected
 
Quote:

Originally Posted by TheKidz (Post 1350178)
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.

TheKidz 11-15-2010 16:38

Re: Check if user is Connected
 
but it really worth change is_user_connected( index ) to bitsums ? just wondering

Xellath 11-15-2010 16:42

Re: Check if user is Connected
 
You could use an array, but a bitsum would be more efficient.

TheKidz 11-15-2010 17:59

Re: Check if user is Connected
 
Thanks. Solved ;*


All times are GMT -4. The time now is 11:21.

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