MySQL /stats command - 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: MySQL /stats command (
/showthread.php?tid=482451)
MySQL /stats command -
ZBits - 21.12.2013
Hello,
I know this is not a script request thread but i would like someone to help me with this script/idea.
I am trying to make a /stats commands which retrieves data from my MySQL database and shows it to the player via a dialog. The main idea is to show stats as any other command does but since my saving system is MySQL i would like to get my data from there and display it to the player.
My MySQL datsbase table name is: "accounts"(without quotes).
Things i would like to see in the /stats dialog.
Код:
Username:
Admin Level
Score:
Kills:
Deaths:
My mysql database fields are(its according to the above order of stats)
Код:
nick
admin
score
kills
death
I tried constructing a command but it didnt work, so i removed it but now i realized i could ask for help via samp forums.It would be great if someone could help me with it.
Re: MySQL /stats command -
CutX - 21.12.2013
it's not that complicated,
i coded that 6 months ago you can take it as an example:
PHP код:
YCMD:stats(playerid, params[], help)
{
if(help) return SendClientMessage(playerid, gray, "/stats Is used to Displays your Statistics.");
new s[150];
format(s,sizeof s,"Name: %s\nScore: %d\nMoney: %d$\nBank-Money: %d\nWanted-Level: %d\nAdmin-Level: %d\nRegDate: %s",
GetName(playerid),
Pi[playerid][pScore],
Pi[playerid][pMoney],
Pi[playerid][pBank],
Pi[playerid][pWanted],
Pi[playerid][pAdminLevel],
Pi[playerid][pRegDate]);
ShowDialog(playerid, Show:Stats, DIALOG_STYLE_MSGBOX,"Your Stats",s,"Ok","");
return 1;
}
before that, you have to store all the information, like score, in an enum ofc.
Re: MySQL /stats command -
ZBits - 21.12.2013
Thanks alot man, it worked great!
+rep