Errors that i cannot explain.
#1

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
Reply
#2

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.
Reply
#3

That's already on top of the code:

Код:
new smallstring[2][50];
Reply
#4

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

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]); 
Reply
#6

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

Fixed by MoroDan, thanks.

@Pghpunkid: Yes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)