AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ index out of bounds ] (https://forums.alliedmods.net/showthread.php?t=254963)

Xablau 01-08-2015 20:29

[ index out of bounds ]
 
I have problem :(

Error: index out of bounds on line:
PHP Code:

parse(lines[i], line_variableSIZEline_valueSIZEline_value2SIZE

See my code:

PHP Code:

public client_putinserver(pid)
{
    new 
errorsendbuffer[512]

    
g_Socket socket_open("127.0.0.1"80SOCKET_TCPerror)
    
    
format(sendbuffer511"GET /web.php HTTP/1.1^nHost: 127.0.0.1^n^n")
        
    
socket_send(g_Socketsendbuffer511)
    
    const 
SIZE 63
    
new line_variable[SIZE 1], line_value[SIZE 1], line_value2[SIZE 1]
    
    if (
socket_change(g_Socket))
    {
        new 
lines[30][100], count 0
        socket_recv
(g_Socketg_Data1024)
        
count ExplodeString(lines50119g_Data13)
        for(new 
i=0;i<count;i++)
        {
            
parse(lines[i], line_variableSIZEline_valueSIZEline_value2SIZE)

            
// 100 lines in web.php ...
            // Continue...
        
}   
    }
    
socket_close(g_Socket)
    return 
PLUGIN_CONTINUE;
}
stock ExplodeStringp_szOutput[][], p_nMaxp_nSizep_szInput[], p_szDelimiter ) { // Function by xeroblood
    
new nIdx 0strlen(p_szInput)
    new 
nLen = (copycp_szOutput[nIdx], p_nSizep_szInputp_szDelimiter ))
    while( (
nLen l) && (++nIdx p_nMax) )
        
nLen += (copycp_szOutput[nIdx], p_nSizep_szInput[nLen], p_szDelimiter ))
    return 
nIdx


lines[30][100] to lines[100][100] not work.

In web.php have 100 lines:
"Value 1" "Value 2" "Value 3"

How to Fix problem?

fysiks 01-08-2015 20:44

Re: [ index out of bounds ]
 
You need to learn to debug these things on your own if you are going to keep asking about trivial problems.

When you are working with strings and need to know the maximum string length (arguments 3, 5, and 7 of the parse command), you should be charsmax(szStringVariable).

Xablau 01-08-2015 20:59

Re: [ index out of bounds ]
 
Quote:

Originally Posted by fysiks (Post 2246662)
You need to learn to debug these things on your own if you are going to keep asking about trivial problems.

When you are working with strings and need to know the maximum string length (arguments 3, 5, and 7 of the parse command), you should be charsmax(szStringVariable).

The index out of bounds refers to the limit of entries in lines being greater than 31

lines[30][100] to lines[100][100] not work, with error: stack error

and...

PHP Code:

parse(lines[i], line_variablecharsmax(line_variable), line_valuecharsmax(line_value), line_value2charsmax(line_value2)) 

not work...

How to fix?

fysiks 01-08-2015 22:10

Re: [ index out of bounds ]
 
Like I said, you need to learn to debug. What happens when you change it to 200 string? What is the value of 'count'?

P.S. stop putting brackets around your whole topic title.

Xablau 01-09-2015 04:40

Re: [ index out of bounds ]
 
count = ExplodeString(lines, 50, 119, g_Data, 13) //100 (Have 100 lines on web.php)

I noticed that exceed 30 lines, gives the error: index out of bounds

If change lines[30][100] to lines[100][100], give error:
stack error on lines[100][100]

fysiks 01-09-2015 18:33

Re: [ index out of bounds ]
 
If you are going to ignore questions/advice then I'm just going to stop posting.

Xablau 01-09-2015 18:51

Re: [ index out of bounds ]
 
Quote:

Originally Posted by fysiks (Post 2247171)
If you are going to ignore questions/advice then I'm just going to stop posting.

I'm not ignoring. Excuse my bad English. =/

I tried your suggestions, but none worked yet.

fysiks 01-09-2015 18:55

Re: [ index out of bounds ]
 
Attach your web.php and your whole .sma files.

Xablau 01-09-2015 19:31

Re: [ index out of bounds ]
 
2 Attachment(s)
Quote:

Originally Posted by fysiks (Post 2247181)
Attach your web.php and your whole .sma files.

Attach

fysiks 01-09-2015 19:34

Re: [ index out of bounds ]
 
Are those the actual files you are using? I need the actual files that you are using.


All times are GMT -4. The time now is 15:31.

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