Variable shows no value - 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)
+--- Thread: Variable shows no value (
/showthread.php?tid=622270)
Variable shows no value -
SsHady - 20.11.2016
So, basically. I have a system that counts player registeration.
Код:
new DBResult:Answer;
Answer = BUD::RunQuery("SELECT COUNT(*) FROM `users`",true);
db_get_field(Answer,0,string,sizeof(string));
new name[MAX_PLAYER_NAME], string[256];
GetPlayerName(playerid, name, sizeof(name));
iUID = strval(string);
format(string, sizeof(string), "[NGF]%s Has successfully registered. Total Registered Accounts %d.", name, iUID);
SendClientMessageToAll(0xC4C4C4FF, string);
It shows "Total Registered Accounts 0"
When I remove the GetPlayerName thingy, it shows correct number of registered accounts. code is
Код:
new DBResult:Answer;
Answer = BUD::RunQuery("SELECT COUNT(*) FROM `users`",true);
db_get_field(Answer,0,string,sizeof(string));
iUID = strval(string);
format(string, sizeof(string), "Total players %d.", iUID);
SendClientMessageToAll(0xC4C4C4FF, string);
So, how can I fix this.
Re: Variable shows no value -
SyS - 20.11.2016
Код:
new DBResult:Answer;
Answer = BUD::RunQuery("SELECT COUNT(*) FROM `users`",true);
db_get_field(Answer,0,string,sizeof(string));//processing before declaration?
new name[MAX_PLAYER_NAME], string[256];
GetPlayerName(playerid, name, sizeof(name));
iUID = strval(string);
format(string, sizeof(string), "[NGF]%s Has successfully registered. Total Registered Accounts %d.", name, iUID);
SendClientMessageToAll(0xC4C4C4FF, string);
You are processing the variable before declaration...
Re: Variable shows no value -
SsHady - 20.11.2016
I'm just a silly fuck.
it works, thanks a lot man... +2