AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help w/ reset array (https://forums.alliedmods.net/showthread.php?t=168170)

fmcTheKing 09-25-2011 03:53

help w/ reset array
 
how best to reset this:
PHP Code:

enum GLOBAL_STATS
{
    
global_frags 0,        
    
global_deaths,
    
global_assists,            
    
global_headshots,
    
global_damage,            
    
global_roundsplayed,
    
global_bombsplanted,        
    
global_bombsdefusals,
    
global_timeplayed,        
    
global_roundswon,
    
global_roundsloses,        
    
global_matcheswon,
    
global_matchesloses,
    
global_matchesties,
    
global_1k,
    
global_2k,
    
global_3k,
    
global_4k,
    
global_5k,
    
global_1v1,
    
global_1v2,
    
global_1v3,
    
global_1v4,
    
global_1v5
}

new 
g_Global_Stats33 ][ GLOBAL_STATS 

if I try this:
PHP Code:

for(new GLOBAL_STATS i++){
    
g_Global_Stats[id][i] = 0


results in this:

Quote:

Warning: Tag mismatch on line 148
Warning: Index tag mismatch (symbol "g_Global_Stats") on line 149

ConnorMcLeod 09-25-2011 04:07

Re: help w/ reset array
 
Try :

enum GLOBAL_STATS

->

enum _:GLOBAL_STATS

PHP Code:

for(new GLOBAL_STATS i++){
    
g_Global_Stats[id][i] = 0



And if you need to reset all players, try this :
PHP Code:

new g_iMaxPlayers

public plugin_init()
{
    
g_iMaxPlayers get_maxplayers()
}

public 
ResetStats()
{
    for(new 
id=1id<=g_iMaxPlayersid++)
    {
        
arrayset(g_Global_Stats[id], 0sizeof(g_Global_Stats[]))
    }



Arkshine 09-25-2011 04:39

Re: help w/ reset array
 
For functions like arrayset() which takes an array with no tag, you should avoid to have have a strong tag (first letter in uppercase).

fmcTheKing 09-25-2011 17:26

Re: help w/ reset array
 
hmmm, I understood, thanks.


All times are GMT -4. The time now is 19:43.

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