Raised This Month: $ Target: $400
 0% 

when client connects and client disconnects


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 09-26-2011 , 09:01   Re: when client connects and client disconnects
Reply With Quote #3

I did it few times, but wierd things happen!!!! I'll tell you what i tried.:

in client_connect i did get_playersnum and if it has 10 players set a pass and do a client print.

in client_disconnect i did get_playersnum and if it has 10 players (before the client has left, meaning there are 9 now) remove the pass.

And this is what happened:

the 10th has logged in a pass was SET.
the 10th has logged out the pass was REMVOED.
the 8th has logged out a pass was set....

wierd random shit happen and i dont know why is this..

ill post the public here:

PHP Code:
// cvar "cvar_playersleft" equals to 10, yeah im sure.

public CheckEmpty(id// Called on client_disconnect
{
    if (
get_maxplayers() == get_pcvar_num(cvar_playersleft))
        return 
PLUGIN_HANDLED
        
        
    
if (get_playersnum() == get_pcvar_num(cvar_playersleft))
    {
        
set_cvar_string("sv_password""")
        
client_print(0print_chat"%s Server password has been REMOVED."PREFIX)
        
set_task(5.0"CheckNow")
    }
    
    return 
PLUGIN_CONTINUE
}

public 
CheckFull(id// Called on client_Connect
{
    if (
get_maxplayers() == get_pcvar_num(cvar_playersleft))
        return 
PLUGIN_HANDLED
        
    
if (get_playersnum()+== get_pcvar_num(cvar_playersleft))
    {
        new 
rnd random_num(999999)
        new 
pass[10]
        
        
num_to_str(rndpass9)
        
        
set_cvar_string("sv_password"pass)
        
client_print(0print_chat"%s Server is now password PROTECTED"PREFIX)
    }
    
    return 
PLUGIN_HANDLED

and dont tell me why you did get_playersnum()+1, cuz i tried it in many many variations, with +1 and without ina ll sequences and havent found the correct code. help pls!
Diegorkable 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 19:34.


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