AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Reset variables with for cycle (https://forums.alliedmods.net/showthread.php?t=273186)

mforce 10-14-2015 13:43

Reset variables with for cycle
 
Is it possible for reset all variables?

PHP Code:

enum PLAYER_DATABASE
{
    
STEAMID[32],
    
AWP_KILLS,
    
SCOUT_KILLS,
    
DEAGLE_KILLS,
    
USP_KILLS,
    
GLOCK_KILLS,
    
KNIFE_KILLS,
    
AWP_MENU,
    
SCOUT_MENU,
    
DEAGLE_MENU,
    
USP_MENU,
    
GLOCK_MENU,
    
KNIFE_MENU
}
new 
player_data[33][PLAYER_DATABASE];

public 
client_putinserver(id) {
    if(
is_user_bot(id)) return;
    for(new 
i=0;PLAYER_DATABASE:i<=KNIFE_MENU;PLAYER_DATABASE:i++)
        
player_data[id][PLAYER_DATABASE:i] = 0
    load
(id);



Bugsy 10-14-2015 18:19

Re: Reset variables with for cycle
 
Quote:

Originally Posted by mforce (Post 2353039)
Is it possible for reset all variables?

I assume by all variables, you mean just the connecting player?

It's common practice to clear variables when the player disconnects to leave the slot clean for the next player who connects on the slot.

Try this:
PHP Code:

enum _:PLAYER_DATABASE
{
    
STEAMID[32],
    
AWP_KILLS,
    
SCOUT_KILLS,
    
DEAGLE_KILLS,
    
USP_KILLS,
    
GLOCK_KILLS,
    
KNIFE_KILLS,
    
AWP_MENU,
    
SCOUT_MENU,
    
DEAGLE_MENU,
    
USP_MENU,
    
GLOCK_MENU,
    
KNIFE_MENU
}
new 
player_data[33][PLAYER_DATABASE];

public 
client_putinserver(id
{
    if( !
is_user_botid ) )     
        
load(id);    
}  

public 
client_disconnectid )
{
    
arraysetplayer_dataid ] , sizeofplayer_data[] ) );



mforce 10-16-2015 12:30

Re: Reset variables with for cycle
 
Thanks for your help! :)


All times are GMT -4. The time now is 22:18.

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