Playerid Error
#1

Im confused on this error:

pawn Код:
error 017: undefined symbol "playerid"
pawn Код:
stock GetFromAccount(name[], obtaining[], holdingvar[])
{
    new Query[180];
    format(Query, sizeof(Query), "SELECT `%s` FROM `Users` WHERE `Name` = '%s'", obtaining, UserStats[playerid][Name]);
    mysql_query(Query);
    mysql_store_result();

    if(mysql_fetch_row(holdingvar) == 1)
    {
        mysql_free_result();
    }
    return 1;
}
The error comes from that code, this line:
pawn Код:
format(Query, sizeof(Query), "SELECT `%s` FROM `Users` WHERE `Name` = '%s'", obtaining, UserStats[playerid][Name]);
Reply
#2

In the function, there's no "playerid" param. That's why it isn't working.
Use an "GetIDFromName" function:

pawn Код:
stock GetIDFromName(name[])
{
    new pName[MAX_PLAYER_NAME];
    for(new i = 0; i < MAX_PLAYERS; i++){
        GetPlayerName(i, pName, MAX_PLAYER_NAME);
        if(!strcmp(name, pName, false))
            return i;
        else continue;
    }
    return -1;
}
Reply
#3

Why bother creating another function?

pawn Код:
stock GetFromAccount(playerid, name[], obtaining[], holdingvar[])
{
    new Query[180];
    format(Query, sizeof(Query), "SELECT `%s` FROM `Users` WHERE `Name` = '%s'", obtaining, UserStats[playerid][Name]);
    mysql_query(Query);
    mysql_store_result();

    if(mysql_fetch_row(holdingvar) == 1)
    {
        mysql_free_result();
    }
    return 1;
}
Reply
#4

That's also possible :')
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)