Problem with stats -
Pawnie - 31.08.2013
Well simply is shows only the last line.
Код:
CMD:stats(playerid, params[])
{
new money = PlayerInfo[playerid][pMoney];
new score = PlayerInfo[playerid][pScores];
new admin = PlayerInfo[playerid][pAdminLevel];
new vip = PlayerInfo[playerid][pVIPlevel];
new kills = PlayerInfo[playerid][pKills];
new Deaths = PlayerInfo[playerid][pDeaths];
new Kicks = PlayerInfo[playerid][pKicks];
new Warns = PlayerInfo[playerid][pWarns];
new string[700];
format(string,sizeof(string), "{0099FF}Money: %d\nLevel: %d", money,score);
format(string,sizeof(string), "{00AAFF}%s\nAdmin: %d\nVIP: %d", string, admin, vip);
format(string,sizeof(string), "{00AAFF}%s\nKills: %d\nDeaths: %d", string, kills, Deaths);
format(string,sizeof(string), "{00AAFF}%s\nKicks: %d\nWarns: %d", Kicks, Warns);
ShowPlayerDialog(playerid, D_STATS, DIALOG_STYLE_MSGBOX, "Your stats", string, "Close", "");
return 1;
}
Re: Problem with stats -
Tom1412 - 31.08.2013
a dialog will only read one string not loads, you have to put all the strings into one.
Re: Problem with stats -
knackworst - 31.08.2013
Everytime you format the same string, you just 'rewrite' it, so it will only show the last line since it is the last one that has been formatted.
Rename each string: so the first line you call: string, the second 'string2', etc...
should work
Re: Problem with stats -
EiresJason - 31.08.2013
Yeh, like Tom said it will only read one string.
The reason your code only reads the last line (even if you just used SendClientMessage) is because you never send the message before reformatting the string.
You should do:
pawn Код:
format(string,sizeof(string), "{0099FF}Money: %d\nLevel: %d", money,score); //formats string.
SendClientMessage(playerid, -1, string) //sends string.
format(string,sizeof(string), "{00AAFF}%s\nAdmin: %d\nVIP: %d", string, admin, vip); //reformats string
SendClientMessage(playerid, -1, string) //sends reformatted string.
If you give me a bit; i will edit this post with the finished string.
Re: Problem with stats -
Dragonsaurus - 31.08.2013
After formatting, use strcat:
pawn Код:
new string2[128];
format(string2,sizeof(string2), "{0099FF}Money: %d\nLevel: %d\n", money,score);
strcat(string, string2);
format(string2,sizeof(string2), "{00AAFF}%s\nAdmin: %d\nVIP: %d\n", string, admin, vip);
strcat(string, string2);
format(string2,sizeof(string2), "{00AAFF}%s\nKills: %d\nDeaths: %d\n", string, kills, Deaths);
strcat(string, string2);
format(string2,sizeof(string2), "{00AAFF}%s\nKicks: %d\nWarns: %d", Kicks, Warns);
Re: Problem with stats -
EiresJason - 31.08.2013
Something like this would be needed.
pawn Код:
CMD:stats(playerid, params[])
{
new money = PlayerInfo[playerid][pMoney];
new score = PlayerInfo[playerid][pScores];
new admin = PlayerInfo[playerid][pAdminLevel];
new vip = PlayerInfo[playerid][pVIPlevel];
new kills = PlayerInfo[playerid][pKills];
new Deaths = PlayerInfo[playerid][pDeaths];
new Kicks = PlayerInfo[playerid][pKicks];
new Warns = PlayerInfo[playerid][pWarns];
new string[128], string2[128],string3[128], finalstring[700];
format(string,sizeof(string), "{0099FF}Money: %d\nLevel: %d", money,score);
strins(finalstring, string,0,sizeof(string));
format(string,sizeof(string), "{00AAFF}%s\nAdmin: %d\nVIP: %d\n", string, admin, vip);
strins(finalstring, string,sizeof(string)+1,sizeof(string2));
format(string2,sizeof(string2), "{00AAFF}%s\nKills: %d\nDeaths: %d\n", string, kills, Deaths);
strins(finalstring, string,sizeof(string)+1,sizeof(string2));
format(string3,sizeof(string3), "{00AAFF}%s\nKicks: %d\nWarns: %d\n", Kicks, Warns);
strins(finalstring, string,sizeof(string2)+1,sizeof(string3));
ShowPlayerDialog(playerid, D_STATS, DIALOG_STYLE_MSGBOX, "Your stats", finalstring, "Close", "");
return 1;
}
It inserts each 'string' into 'finalstring' and then sends that as the dialog text.
Re: Problem with stats -
Pawnie - 31.08.2013
This is my final stuff
Код:
CMD:stats(playerid, params[])
{
new money = PlayerInfo[playerid][pMoney];
new score = PlayerInfo[playerid][pScores];
new admin = PlayerInfo[playerid][pAdminLevel];
new vip = PlayerInfo[playerid][pVIPlevel];
new kills = PlayerInfo[playerid][pKills];
new Deaths = PlayerInfo[playerid][pDeaths];
new Kicks = PlayerInfo[playerid][pKicks];
new Warns = PlayerInfo[playerid][pWarns];
new Achievements = PlayerInfo[playerid][pAchievementPoints];
new string[128], string2[128],string3[128],string4[128], finalstring[800];
format(string,sizeof(string), "{0099FF}Money: %d\nLevel: %d", money,score);
strins(finalstring, string,0,sizeof(string));
format(string,sizeof(string), "{00AAFF}%s\nAdmin: %d\nVIP: %d\n", string, admin, vip);
strins(finalstring, string,sizeof(string)+1,sizeof(string2));
format(string2,sizeof(string2), "{00AAFF}%s\nKills: %d\nDeaths: %d\n", string, kills, Deaths);
strins(finalstring, string,sizeof(string)+1,sizeof(string2));
format(string3,sizeof(string3), "{00AAFF}%s\nKicks: %d\nWarns: %d\n", Kicks, Warns);
strins(finalstring, string,sizeof(string)+1,sizeof(string3));
format(string4,sizeof(string4), "{00AAFF}%s\nAchievement Points: %d \n", Achievements);
strins(finalstring, string,sizeof(string2)+1,sizeof(string4));
ShowPlayerDialog(playerid, D_STATS, DIALOG_STYLE_MSGBOX, "Your stats", finalstring, "Close", "");
return 1;
}
Keeps saying "Unknown command"
Re : Problem with stats -
PakPak - 01.09.2013
You should read that :
https://sampforum.blast.hk/showthread.php?tid=336102
Look at the end of the tutorial.