SA-MP Forums Archive
How come I get this error ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How come I get this error ? (/showthread.php?tid=404306)



How come I get this error ? - I3Psychedelic - 02.01.2013

pawn Код:
new saveammoex[MAX_PLAYERS][13];
format(string, 128, "GunId%d", s);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[MAX_PLAYERS][pGunz][s] = strval( val ); }
format(string, 128, "Ammo%d",val);
if( strcmp( key, string, true ) == 0) { val = ini_GetValue ( Data ); saveammoex[MAX_PLAYERS][s] = strval ( val ); }
Oh I forgot the error
error 032: array index out of bounds (variable "saveammoex


Re: How come I get this error ? - I3Psychedelic - 02.01.2013

Bump
Guys my thread went to page 2


Re: How come I get this error ? - Mr.Anonymous - 02.01.2013

Increase the "13" to a higher number.


Re: How come I get this error ? - I3Psychedelic - 02.01.2013

Quote:
Originally Posted by Mr.Anonymous
Посмотреть сообщение
Increase the "13" to a higher number.
Ey thanks for the reply.
I think the problem is with the MAX_PLAYERS here:
if( strcmp( key, string, true ) == 0) { val = ini_GetValue ( Data ); saveammoex[MAX_PLAYERS][s] = strval ( val ); }

because when I replace it with 499 or anything else the error is gone


Re: How come I get this error ? - park4bmx - 02.01.2013

yes because your not using it correctly!
pawn Код:
new saveammoex[MAX_PLAYERS][13];
format(string, 128, "GunId%d", s);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunz][s] = strval( val ); }
format(string, 128, "Ammo%d",val);
if( strcmp( key, string, true ) == 0) { val = ini_GetValue ( Data ); saveammoex[playerid][s] = strval ( val ); }
When you declared the "MAX_PLAYERS" is basically a define of "500" which then is set to the variable which means the variables is now an Arrey. which holds "MAX_PLAYERS" slots in it so it can store values in it for "MAX_PLAYERS"/"500" playerid.
So later on you will have to tell the script which exact playerid you want.
Quote:

This forum requires that you wait 120 seconds between posts

damm ;X


Re: How come I get this error ? - I3Psychedelic - 02.01.2013

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
yes because your not using it correctly!
pawn Код:
new saveammoex[MAX_PLAYERS][13];
format(string, 128, "GunId%d", s);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunz][s] = strval( val ); }
format(string, 128, "Ammo%d",val);
if( strcmp( key, string, true ) == 0) { val = ini_GetValue ( Data ); saveammoex[playerid][s] = strval ( val ); }
When you declared the "MAX_PLAYERS" is basically a define of "500" which then is set to the variable which means the variables is now an Arrey. which holds "MAX_PLAYERS" slots in it so it can store values in it for "MAX_PLAYERS"/"500" playerid.
So later on you will have to tell the script which exact playerid you want.
damm ;X
Thanks for the reply !
Damn man ...
sorry for being so stupid . but .. what should I do know lol


Re: How come I get this error ? - I3Psychedelic - 03.01.2013

Guys page 2 !
Bump ... help plz !


Re: How come I get this error ? - park4bmx - 03.01.2013

the code i gave you should work fine if the is any playerid in the callback your using it.
did you try it out ?