SA-MP Forums Archive
Biggest fail to a GetPlayerName function! - 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: Biggest fail to a GetPlayerName function! (/showthread.php?tid=157005)



Biggest fail to a GetPlayerName function! - Antonio [G-RP] - 25.06.2010

Ahaha, I tried, but I have no clue how to do this...

pawn Код:
stock GetPlayerNameFromSQLid(SQLid)
{
    new query[256], pname[24];
    format(query, 256, "SELECT `username` FROM `accounts` WHERE `SQLid` = '%d'", SQLid);
    mysql_query(query);
    mysql_store_result(pname);
    return pname;
}



Re: Biggest fail to a GetPlayerName function! - Calgon - 25.06.2010

pawn Код:
stock GetPlayerNameFromSQLid(SQLid)
{
    new query[53], pname[24]; // You don't need 256 cells...
    format(query, sizeof(query), "SELECT `username` FROM `accounts` WHERE `SQLid` = '%d'", SQLid);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_field("username", pname);
    mysql_free_result();
    return pname;
}
Something similar, I've never really needed to retrieve only 1 value from a MySQL query in PAWN, so I use an asterisk.


Re: Biggest fail to a GetPlayerName function! - Antonio [G-RP] - 25.06.2010

Thanks.

is the [number] showing the length of the string by amount of characters?


Re: Biggest fail to a GetPlayerName function! - Calgon - 25.06.2010

Quote:
Originally Posted by ♂ Antonio [G-RP
]
Thanks.

is the [number] showing the length of the string by amount of characters?
Figure it out yourself.


Re: Biggest fail to a GetPlayerName function! - Antonio [G-RP] - 25.06.2010

Okay

Edit: Sorry for what I said, I'm REALLY confused right now.