Strings- 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: Strings- Error (
/showthread.php?tid=531805)
Strings- Error -
Sarra - 14.08.2014
Hey , please check the following example:
pawn Код:
new string[4][128];
format(string[0], sizeof(string[0]), "BlaBla%i", int);
when I do this I get an error
so I have to change the sizeofstring(string[0]) to 128 to get rid of the error
pawn Код:
new string[4][128];
format(string[0], 128, "BlaBla%i", int);
this works fine
Why?
Re: Strings- Error -
CutX - 14.08.2014
do it like this
pawn Код:
new string[4][128];
format(string[0], sizeof(string), "BlaBla%i", int);
just "sizeof(string)" without the brackets is enough cuz
the sole name of an array is the pointer to it's 1st element
ps: u don't need the clips when using the keyword "sizeof"
this:
pawn Код:
format(string[0], sizeof string, "BlaBla%i", int);
works fine too
Re: Strings- Error -
Jefff - 14.08.2014
pawn Код:
sizeof(string[]) returns 128
Re: Strings- Error -
Sarra - 16.08.2014
Quote:
Originally Posted by Jefff
pawn Код:
sizeof(string[]) returns 128
|
Thanks, that's it, +rep
-----------
Quote:
Originally Posted by CutX
do it like this
pawn Код:
new string[4][128]; format(string[0], sizeof(string), "BlaBla%i", int);
just "sizeof(string)" without the brackets is enough cuz
the sole name of an array is the pointer to it's 1st element
ps: u don't need the clips when using the keyword "sizeof"
this:
pawn Код:
format(string[0], sizeof string, "BlaBla%i", int);
works fine too
|
thanks, but the right one is sizeof string[], +rep also since I learned that I don't need the "()"
__________________________________________________ __________________________________________________ _______________________________________________
One last question,
now in this case
I can use sizeof string[]
but what do I do in this case
pawn Код:
enum pData
{
pPass[20], // what do I do to get the size of this one?
// .....
pCash,
Float:pPosx,
Float:pPosy,
Float:pPosz,
pKills,
pDeaths,
pVehnumber,
Float:pHealth
}
new PlayerData[MAX_PLAYERS][pData];
I don't believe that I can simply use sizeof PlayerData[][] for the size of pPass which is 20