AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help me please. (https://forums.alliedmods.net/showthread.php?t=136268)

dantrix 08-24-2010 16:41

Help me please.
 
PHP Code:

public client_disconnect(id)
{
    if(
get_pcvar_num(lives) == 1)
    {
        
set_task(8.0"RestKarmaLive"id)
    }
}
public 
RestKarmaLive(id)
{
    if(!
is_user_connected(id)){
        
LoadKarma(id);
        new 
name[32];
        
get_user_name(idname31)
        
karma[id] -= 1;
        
client_print(0,print_chat"%L"LANG_PLAYER"LIVE_QUIT"name1)
        
server_print("%s lost karma!  KARMA: %d"namekarma[id])
        
SaveKarma(id);
    }
    


Hi.. i tried if the user disconnect ( with the cvar sv_live == 1 ) , and not reconnect yet in 8 seconds.., karma[id] -= 1(in nvault) .. and he's reconnect before past 8 second do nothing(duh)..
the LoadKarma ( just extrat values from nVault )
and the SaveKarma ( -.- saving nVault values).

server_print and the task work, but not decreasing 1 in the karma[id] ..

thx...:|

Bugsy 08-24-2010 17:07

Re: Help me please.
 
You cannot retrieve the name of a disconnected player. What are you using as the key for each player? Authid cannot be retrieved either if disconnected. You should store the values in a global string array at client putinserver.

dantrix 08-24-2010 17:21

Re: Help me please.
 
yes im using Authid.. , as would be the other way? these is the LoadKarma function:
PHP Code:

 stock LoadKarma(id)
{
    new 
valut nvault_open("Karma_System");  
    
    if(
valut == INVALID_HANDLE)
        
set_fail_state("nValut returned Invalid-Handle"); 
    
    new 
key[100], authid[33]
    
    
get_user_authid(idauthid32); 
    
    
formatex(key99,"%sKarma"authid);  
    
    
karma[id] = nvault_get(valutkey);  
    
nvault_close(valut);
    
    return 
PLUGIN_CONTINUE;



Bugsy 08-24-2010 17:45

Re: Help me please.
 
PHP Code:

//create global string array
new g_szAuthID33 ][ 34 ];

In client_authorized:
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) ); 

In your plugin, use g_szAuthID[ id ] to use a players steamid throughout your plugin. You can do the same thing for player names. You may want to use trie instead since a user could connect on the same slot as the disconnecting player within the 8 seconds.


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

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