MySQL /stats command
#1

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.
Reply
#2

it's not that complicated,
i coded that 6 months ago you can take it as an example:

PHP код:
YCMD:stats(playeridparams[], help)
{
    if(
help) return SendClientMessage(playeridgray"/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(playeridShow:StatsDIALOG_STYLE_MSGBOX,"Your Stats",s,"Ok","");
    return 
1;

before that, you have to store all the information, like score, in an enum ofc.
Reply
#3

Thanks alot man, it worked great!

+rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)