SA-MP Forums Archive
Errors that i cannot explain. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Errors that i cannot explain. (/showthread.php?tid=269623)



Errors that i cannot explain. - Danny - 17.07.2011

Hi,

Why is this code giving me errors? Everything seems OK.

Code:

Код:
	format(smallstring[0], sizeof smallstring[0],"%d%d%d%d%d",random(9),random(9),random(9),random(9),random(9)); // used for the uniqe faction code
	mysql_real_escape_string(smallstring[0], eStr[0]);
Errors:

Код:
C:\Users\Tol\Desktop\ML-V3 16 juli 2011\pawno\include\homemadeincludes/factions.inc(61) : error 001: expected token: "]", but found "-integer value-"
C:\Users\Tol\Desktop\ML-V3 16 juli 2011\pawno\include\homemadeincludes/factions.inc(61) : warning 215: expression has no effect
C:\Users\Tol\Desktop\ML-V3 16 juli 2011\pawno\include\homemadeincludes/factions.inc(61) : error 001: expected token: ";", but found "]"
C:\Users\Tol\Desktop\ML-V3 16 juli 2011\pawno\include\homemadeincludes/factions.inc(61) : error 029: invalid expression, assumed zero
C:\Users\Tol\Desktop\ML-V3 16 juli 2011\pawno\include\homemadeincludes/factions.inc(61) : fatal error 107: too many error messages on one line
This should work, right?? Why it isn't working?

Greetz,
Danny


Re: Errors that i cannot explain. - [HiC]TheKiller - 17.07.2011

Make sure that you have
pawn Код:
new smallstring[value][stringsize];
What you probably have is
pawn Код:
new smallstring[stringsize];
You must define the string properly.


Re: Errors that i cannot explain. - Danny - 17.07.2011

That's already on top of the code:

Код:
new smallstring[2][50];



Re: Errors that i cannot explain. - [HiC]TheKiller - 17.07.2011

Oh, yeah, my bad. The error is actually because you don't have brackets around your sizeof function .


Re: Errors that i cannot explain. - MoroDan - 17.07.2011

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Oh, yeah, my bad. The error is actually because you don't have brackets around your sizeof function .
No, that's not true. The errors come from sizeof, because he is trying to determinate the sizeof of a 2D Array.
So you must do like this:
PHP код:
format(smallstring[0], 50"%d%d%d%d%d",random(9),random(9),random(9),random(9),random(9)); // used for the uniqe faction code
mysql_real_escape_string(smallstring[0], eStr[0]); 
And i don't understand why you don't use random(10) ... because random(9) can generates only this numbers:
• 0
• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 8
And because an integer can't starts with 0 ( something like: 0153 -> this will be transformed in 153 ), i suggest you to do like this:
PHP код:
format(smallstring[0], 50"%d", (10000 random(99999)))); // used for the uniqe faction code
mysql_real_escape_string(smallstring[0], eStr[0]); 



Re: Errors that i cannot explain. - Pghpunkid - 17.07.2011

Just to be clear, these are the lines from faction.inc that you pasted?


Re: Errors that i cannot explain. - Danny - 17.07.2011

Fixed by MoroDan, thanks.

@Pghpunkid: Yes.