SA-MP Forums Archive
help with this /stats - 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: help with this /stats (/showthread.php?tid=479611)



[SOLVED] help with this /stats - ahmad95 - 06.12.2013

Solved


Respuesta: help with this /stats - [CG]Milito - 06.12.2013

You have to format your string

Try like this


pawn Код:
CMD:stats(playerid, params[])
{
    if(P_DATA[playerid][P_Registered] == 0) return ShowInfoTD(playerid, "~r~~h~You must be registered by using /register before using this command.");
    if(P_DATA[playerid][P_LoggedIn] == 0) return 1;

    new stats[300];
    new str[100];
    format(str,sizeof(str),"{FFFFFF}Name: %s\nAccount ID: %d\nAdmin: %d\nVIP: %dScore: %d\nMoney: %d\n", ReturnPlayerName(playerid), P_DATA[playerid][P_AccID],P_DATA[playerid][P_Admin], GetPlayerScore(playerid),GetPlayerMoney(playerid));
    strcat(stats, str, sizeof(str));
    format(str,sizeof(str),"Autofix: %i\nAutoflip: %i\nManualflip: %i\nBounce: %i\nSpeed Boost: %i\nNos: %i", P_DATA[playerid][P_AutoFix], P_DATA[playerid][P_AutoFlip],P_DATA[playerid][P_ManualFlip], P_DATA[playerid][P_Bounce],P_DATA[playerid][P_SpeedBoost],P_DATA[playerid][P_Nos]);
    strcat(stats,  str(sizeof(str));
    ShowPlayerDialog(playerid, DIALOG_ID_STATS, DIALOG_STYLE_MSGBOX, "{0088FF}XFPE - Stats", stats,"OK","");

    return 1;
}



Re: Respuesta: help with this /stats - ahmad95 - 06.12.2013

Quote:
Originally Posted by [CG]Milito
Посмотреть сообщение
You have to format your string

Try like this


pawn Код:
CMD:stats(playerid, params[])
{
    if(P_DATA[playerid][P_Registered] == 0) return ShowInfoTD(playerid, "~r~~h~You must be registered by using /register before using this command.");
    if(P_DATA[playerid][P_LoggedIn] == 0) return 1;

    new stats[300];
    new str[100];
    format(str,sizeof(str),"{FFFFFF}Name: %s\nAccount ID: %d\nAdmin: %d\nVIP: %dScore: %d\nMoney: %d\n", ReturnPlayerName(playerid), P_DATA[playerid][P_AccID],P_DATA[playerid][P_Admin], GetPlayerScore(playerid),GetPlayerMoney(playerid));
    strcat(stats, str, sizeof(str));
    format(str,sizeof(str),"Autofix: %i\nAutoflip: %i\nManualflip: %i\nBounce: %i\nSpeed Boost: %i\nNos: %i", P_DATA[playerid][P_AutoFix], P_DATA[playerid][P_AutoFlip],P_DATA[playerid][P_ManualFlip], P_DATA[playerid][P_Bounce],P_DATA[playerid][P_SpeedBoost],P_DATA[playerid][P_Nos]);
    strcat(stats,  str(sizeof(str));
    ShowPlayerDialog(playerid, DIALOG_ID_STATS, DIALOG_STYLE_MSGBOX, "{0088FF}XFPE - Stats", stats,"OK","");

    return 1;
}
I compiled and got these error.

Код:
[GM]XF-PE.pwn(1517) : error 012: invalid function call, not a valid address
[GM]XF-PE.pwn(1517) : error 001: expected token: ",", but found "sizeof"
[GM]XF-PE.pwn(1517) : warning 215: expression has no effect
[GM]XF-PE.pwn(1517) : error 001: expected token: ";", but found ")"
[GM]XF-PE.pwn(1517) : fatal error 107: too many error messages on one line



Respuesta: help with this /stats - [CG]Milito - 06.12.2013

pawn Код:
CMD:stats(playerid, params[])
{
    if(P_DATA[playerid][P_Registered] == 0) return ShowInfoTD(playerid, "~r~~h~You must be registered by using /register before using this command.");
    if(P_DATA[playerid][P_LoggedIn] == 0) return 1;

    new stats[300];
    new str[155];
    format(str,sizeof(str),"{FFFFFF}Name: %s\nAccount ID: %d\nAdmin: %d\nVIP: %dScore: %d\nMoney: %d\n", ReturnPlayerName(playerid), P_DATA[playerid][P_AccID],P_DATA[playerid][P_Admin], GetPlayerScore(playerid),GetPlayerMoney(playerid));
    strcat(stats, str, sizeof(str));
    format(str,sizeof(str),"Autofix: %i\nAutoflip: %i\nManualflip: %i\nBounce: %i\nSpeed Boost: %i\nNos: %i", P_DATA[playerid][P_AutoFix], P_DATA[playerid][P_AutoFlip],P_DATA[playerid][P_ManualFlip], P_DATA[playerid][P_Bounce],P_DATA[playerid][P_SpeedBoost],P_DATA[playerid][P_Nos]);
    strcat(stats,  str,sizeof(str));
    ShowPlayerDialog(playerid, DIALOG_ID_STATS, DIALOG_STYLE_MSGBOX, "{0088FF}XFPE - Stats", stats,"OK","");

    return 1;
}


Now it should work properly

The string size was not enough,


Re: help with this /stats - ahmad95 - 06.12.2013



when /stats ingame the cmd doesnt show the content fully...

Sorry for bad english.


Respuesta: help with this /stats - [CG]Milito - 06.12.2013

Now it should work properly

pawn Код:
CMD:stats(playerid, params[])
{
    if(P_DATA[playerid][P_Registered] == 0) return ShowInfoTD(playerid, "~r~~h~You must be registered by using /register before using this command.");
    if(P_DATA[playerid][P_LoggedIn] == 0) return 1;

    new stats[300];
    new str[155];
    format(str,sizeof(str),"{FFFFFF}Name: %s\nAccount ID: %d\nAdmin: %d\nVIP: %dScore: %d\nMoney: %d\n", ReturnPlayerName(playerid), P_DATA[playerid][P_AccID],P_DATA[playerid][P_Admin], GetPlayerScore(playerid),GetPlayerMoney(playerid));
    strcat(stats, str, sizeof(str));
    format(str,sizeof(str),"Autofix: %i\nAutoflip: %i\nManualflip: %i\nBounce: %i\nSpeed Boost: %i\nNos: %i", P_DATA[playerid][P_AutoFix], P_DATA[playerid][P_AutoFlip],P_DATA[playerid][P_ManualFlip], P_DATA[playerid][P_Bounce],P_DATA[playerid][P_SpeedBoost],P_DATA[playerid][P_Nos]);
    strcat(stats,  str,sizeof(str));
    ShowPlayerDialog(playerid, DIALOG_ID_STATS, DIALOG_STYLE_MSGBOX, "{0088FF}XFPE - Stats", stats,"OK","");

    return 1;
}



Re: help with this /stats - ahmad95 - 06.12.2013

Thanks Milito, it works.
REP +1 for your help


Respuesta: help with this /stats - [CG]Milito - 06.12.2013

No problem dude, Just ask

Thanks for the rep!