Small help - 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: Small help (
/showthread.php?tid=589723)
Small help -
Face9000 - 21.09.2015
I have this code which Vince made for me (thanks Vince), for selecting random gamemode and changing it, i'm getting a warning at this line:
warning 224: indeterminate array size in "sizeof" expression (symbol "")
Код:
static const FILE_NAMES[][] = {
Full code:
Код:
new randomIndex;
static gCurrentIndex = -1;
public ChangeGame(playerid)
{
static const FILE_NAMES[][] = {
"bare",
"barron",
"bandito"
};
do
{
randomIndex = random(sizeof(FILE_NAMES));
}
while(randomIndex == gCurrentIndex);
gCurrentIndex = randomIndex;
new rconCommand[16 + sizeof(FILE_NAMES[])];
format(rconCommand, sizeof(rconCommand), "changemode %s.amx", FILE_NAMES[gCurrentIndex]);
SendRconCommand(rconCommand);
return 1;
}
Thanks.
Re: Small help -
Jefff - 21.09.2015
You need set max length for "static const FILE_NAMES[][] = {" (bandito - 7 chars + null = 8 )
Re: Small help -
Face9000 - 21.09.2015
Yes but i have 3 names, not just "bandito"...
Re: Small help -
Jefff - 21.09.2015
Doesn't matter just set 8 because "bandito" is longest from these 3
Re: Small help -
Face9000 - 21.09.2015
Tried in this way:
Код:
static const FILE_NAMES[3] = {
"bare",
"barron",
"bandito"
};
But getting "error 018: initialization data exceeds declared size".
Re: Small help -
Jefff - 21.09.2015
Must be [][8]