Small help
#1

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

You need set max length for "static const FILE_NAMES[][] = {" (bandito - 7 chars + null = 8 )
Reply
#3

Yes but i have 3 names, not just "bandito"...
Reply
#4

Doesn't matter just set 8 because "bandito" is longest from these 3
Reply
#5

Tried in this way:

Код:
static const FILE_NAMES[3] = {
  "bare",
  "barron",
  "bandito"
};
But getting "error 018: initialization data exceeds declared size".
Reply
#6

Must be [][8]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)