Playerid 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Playerid Error (
/showthread.php?tid=208726)
Playerid Error -
Anthonyx3' - 09.01.2011
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]);
Re: Playerid Error -
Kwarde - 09.01.2011
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;
}
Re: Playerid Error -
California - 09.01.2011
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;
}
Re: Playerid Error -
Kwarde - 09.01.2011
That's also possible :')