warning 224: indeterminate array size in "sizeof" expression (symbol "")
#1

pawn Code:
public ChangePlayerDecisions(playerid,decisions[])
{
    new fm[128];
    for(new i = 0; i < sizeof(decisions); i++)//line 523
    {
        PlayerDecisions[playerid][i] = decisions[i];
        format(fm,sizeof(fm),"/%i: %s",i+1,decisionMessages[i]);
        OnPlayerDecisionsChange(playerid,decisions);
    }
    return 1;
}
Error:
Code:
(523) warning 224: indeterminate array size in "sizeof" expression (symbol "")
Can someone please explain? I'm using sizeof with an existing symbol, so why is it blank there? Is it undetermined somehow because I didn't specify a length in the function's declaration/definition?
Reply
#2

Try
pawn Code:
public ChangePlayerDecisions(playerid,decisions[], s_size = sizeof(decisions))
for(new i = 0; i < s_size-1; i++)//line 523
Reply
#3

EDIT: Never mind. Didn't have to be public (don't know why it was in the first place). Thanks, repping
Reply
#4

Having another problem:
pawn Code:
ChangePlayerDecisions(playerid,{DECISION_SETTINGS_CHANGE_PASS,DECISION_SETTINGS_SHOW_DEATHS,DECISION_SETTINGS_PREF_CITY,DECISION_SETTINGS_MAX_TRIES});//line 736 (duh)
Errors:
Code:
....pwn(736) : error 001: expected token: "}", but found ";"
....pwn(736) : error 001: expected token: ",", but found ";"
....pwn(736) : error 029: invalid expression, assumed zero
....pwn(736) : fatal error 107: too many error messages on one line
Edit: And yes, the DECISION_... variables are defined:
pawn Code:
#define DECISION_SETTINGS_CHANGE_PASS 0;
#define DECISION_SETTINGS_SHOW_DEATHS 1;
#define DECISION_SETTINGS_PREF_CITY 2;
#define DECISION_SETTINGS_MAX_TRIES 3;
Reply
#5

Why are your parameters wrapped in { }?
Reply
#6

pawn Code:
#define DECISION_SETTINGS_CHANGE_PASS   0
#define DECISION_SETTINGS_SHOW_DEATHS   1
#define DECISION_SETTINGS_PREF_CITY     2
#define DECISION_SETTINGS_MAX_TRIES     3

@ChangePlayerDecisions(playerid, ...); // its forward
@ChangePlayerDecisions(playerid, ...) // its public
{
    //new fm[128];
    new
        i = 1, // 1 because we have 'playerid' as first
        n = numargs()
    ;

    while(i < n)
    {
        PlayerDecisions[playerid][i-1] = getarg(i);
        //format(fm,sizeof(fm),"/%i: %s",i+1,decisionMessages[i]);
        OnPlayerDecisionsChange(playerid,decisions);
        i++;
    }
    return 1;
}

// Usage
@ChangePlayerDecisions(playerid,DECISION_SETTINGS_CHANGE_PASS,DECISION_SETTINGS_SHOW_DEATHS,DECISION_SETTINGS_PREF_CITY,DECISION_SETTINGS_MAX_TRIES);
and show OnPlayerDecisionsChange
Reply
#7

Quote:
Originally Posted by Jefff
View Post
pawn Code:
#define DECISION_SETTINGS_CHANGE_PASS   0
#define DECISION_SETTINGS_SHOW_DEATHS   1
#define DECISION_SETTINGS_PREF_CITY     2
#define DECISION_SETTINGS_MAX_TRIES     3

@ChangePlayerDecisions(playerid, ...); // its forward
@ChangePlayerDecisions(playerid, ...) // its public
{
    //new fm[128];
    new
        i = 1, // 1 because we have 'playerid' as first
        n = numargs()
    ;

    while(i < n)
    {
        PlayerDecisions[playerid][i-1] = getarg(i);
        //format(fm,sizeof(fm),"/%i: %s",i+1,decisionMessages[i]);
        OnPlayerDecisionsChange(playerid,decisions);
        i++;
    }
    return 1;
}

// Usage
@ChangePlayerDecisions(playerid,DECISION_SETTINGS_CHANGE_PASS,DECISION_SETTINGS_SHOW_DEATHS,DECISION_SETTINGS_PREF_CITY,DECISION_SETTINGS_MAX_TRIES);
and show OnPlayerDecisionsChange
Still some errors:
Code:
heist92_01b.pwn(736) : error 001: expected token: ",", but found ";"
heist92_01b.pwn(736) : error 029: invalid expression, assumed zero
heist92_01b.pwn(736) : warning 215: expression has no effect
heist92_01b.pwn(736) : error 029: invalid expression, assumed zero
heist92_01b.pwn(736) : fatal error 107: too many error messages on one line
Reply
#8

Bump.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)