AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Error 033: array must be indexed (https://forums.alliedmods.net/showthread.php?t=135427)

wangbochiang 08-16-2010 05:19

[Solved] Error 033: array must be indexed
 
1 Attachment(s)
I have stuck on this wried error and I cant fix this...

I wanna save climber timer when he was disconnect

and when the climber came back server,

timer will set to when he was left the server.

here is the pic of error
https://forums.alliedmods.net/attach...1&d=1281950015

here is declaration of timersave
PHP Code:

new const NULLSTR[ ] = ""
//Temp save vars ; took from Climb
new savepos 0steamid[32][32], Float:originssave[32][48], timersave[32][15], Float:originstemp[33][48

and here is the code between 830-835..

PHP Code:

        timersave[savepos] = g_playertime[id//save timer array
        
        //clear data for new client in that slot
        
for( new 048i++ ) g_player_specposition[id][i] = 0.0
        
for( new 014i++ ) g_playertime[id][i] = 0
    



if that will be so smooth.. here is my whole save pos and timer code down here
what I trying to transform from Climb to Kz-Arg

PHP Code:

public client_disconnect(id)
{
    if( 
g_playerisvip[id] )
        
fm_remove_model_ents(id)
    
remove_task(id+TASK_ID_MINISECOND)
    
remove_task(id+TASK_ID_NIGHTVISION)
    
remove_task(id+TASK_ID_WELCOMMSG)
// start save pos and timer !

    
if( get_pcvar_num(cvar_enable) )
    {
        
savepos++
        if( 
savepos == 31 savepos 0
        
        
new saveid[32]
        
get_user_authididsaveid32 )
        
        
//erase previous save if exists
        
for( new i=0i<32i++ )
            if( 
equalsaveidsteamid[i] ) ) steamid[i] = NULLSTR        
        
        
        
if( g_playertime[id] && g_playerstart[id] ) g_playerpaused[id] = //Pause if running
        
        
pev(idpev_originoriginstemp[id])
        
steamid[savepos] = saveid //save steamid to position reference
        
originssave[savepos] = originstemp[id//save origins 
        
timersave[savepos] = g_playertime[id//save timer array
        
        //clear data for new client in that slot
        
for( new 048i++ ) g_player_specposition[id][i] = 0.0
        
for( new 014i++ ) g_playertime[id][i] = 0
    
}



when player putinserver

PHP Code:

public client_putinserver(id)
{
    if( 
get_pcvar_num(kz_welcomemsg) == )
        
set_task(1.0"welcomemsg"id+TASK_ID_WELCOMMSG)
        
    
//search steamid to position reference for match
    
new searchid[32]
    
get_user_authididsearchid31 )
    for(new 
032i++ )
        if( 
equalsearchidsteamid[i] ) )
        {
//load origins & timer array if match found
            
set_pev(idpev_originoriginssave[id])
            
timer[id] = timersave[i]
        }
         
//blah blah down here is original kz-arg code..


thanks is advance and sorry my bad english..:oops:

Arkshine 08-16-2010 05:35

Re: Error 033: array must be indexed
 
Show the declaration of timersave.

wangbochiang 08-16-2010 05:43

Re: Error 033: array must be indexed
 
Quote:

Originally Posted by Arkshine (Post 1272386)
Show the declaration of timersave.

here it is

PHP Code:

new const NULLSTR[ ] = ""
//Temp save vars ; took from Climb
new savepos 0steamid[32][32], Float:originssave[32][48], timersave[32][15], Float:originstemp[33][48

thank you for helping me :'(

Bugsy 08-16-2010 09:01

Re: Error 033: array must be indexed
 
There are numerous things that need fixing in your code. For this particular error:

timersave array is 2-dimensional and you are using it as a 1-dimension array.

timersave[32][15]
timersave[savepos] = g_playertime[id]

The compiler expects this:

timersave[savepos][ some_other_index ] = g_playertime[id]

wangbochiang 08-16-2010 13:08

Re: Error 033: array must be indexed
 
Quote:

Originally Posted by Bugsy (Post 1272505)
There are numerous things that need fixing in your code. For this particular error:

timersave array is 2-dimensional and you are using it as a 1-dimension array.

timersave[32][15]
timersave[savepos] = g_playertime[id]

The compiler expects this:

timersave[savepos][ some_other_index ] = g_playertime[id]

thank you Bugsy, Now plugin is working fine :mrgreen:


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

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