SA-MP Forums Archive
/stats dialog - 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: /stats dialog (/showthread.php?tid=551299)



/stats dialog - PowerF - 18.12.2014

does someone know how to make cmd /stats with dialog?


Код:
#if defined USE_STATS
CMD:stats(playerid,params[]) {
	new string[100], pDeaths, player1,playername[MAX_PLAYER_NAME];
	if(isnull(params)) player1 = playerid;
	else player1 = strval(params);

	if(IsPlayerConnected(player1)) {
	    GetPlayerName(player1, playername, sizeof(playername));
 		if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
 		new str[120], str1[100];
 		format(str, sizeof(str),"%s's Stats", PlayerName2(player1));
		format(string,sizeof(string),"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f", GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);
		format(str1, sizeof(str1),"Rank: %s | Team: %s | Class: %s | Session Kills %d",GetRankName(player1), GetTeamName(player1), GetClass(player1), Skills[player1]);

		SendClientMessage(playerid, green,str);
		SendClientMessage(playerid, green,string);
		SendClientMessage(playerid, green,str1);
	} else return SendClientMessage(playerid, red, "Player Not Connected!");
	return 1;
}
#endif



Re: /stats dialog - Quickie - 18.12.2014

pawn Код:
#define DIALOG_STATS    1154

#if defined USE_STATS
CMD:stats(playerid,params[]) {
    new string[100], pDeaths, player1,playername[MAX_PLAYER_NAME],dialog[1000];
    if(isnull(params)) player1 = playerid;
    else player1 = strval(params);

    if(IsPlayerConnected(player1)) {
        GetPlayerName(player1, playername, sizeof(playername));
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
        new str[120], str1[100];
        format(str, sizeof(str),"~g~%s's Stats", PlayerName2(player1));
        format(string,sizeof(string),"~g~Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f \n", GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);
        format(str1, sizeof(str1),"~g~Rank: %s | Team: %s | Class: %s | Session Kills %d \n",GetRankName(player1), GetTeamName(player1), GetClass(player1), Skills[player1]);

        strcat(dialog,string);
        strcat(dialog,str1);
        ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, str, dialog, "Cancel", "");
    } else return SendClientMessage(playerid, red, "Player Not Connected!");
    return 1;
}
#endif



Re: /stats dialog - Ciandlah - 18.12.2014

Or for a much more effective and efficient way

Код:
enum
{
	STATS
};

CMD: stats(playerid, params[]) {
	new string[128], para[128], pDeaths, player1, playername[MAX_PLAYER_NAME];
	if(isnull(params)) player1 = playerid;
	else player1 = strval(params)
	
	if(IsPlayerConnected(playerid)) {
		GetPlayerName(player1, playername, sizeof(playername));
		if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
		
		format(string, sizeof(string), "%s's Statistics", PlayerName2(player1));
		format(para,sizeof(para),"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f", GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);

		ShowPlayerDialog(playerid, STATS, DIALOG_STYLE_MSGBOX, string, para, "", "Close");
	} else return SendClientMessage(playerid, red, "Player Not Connected!");
	return 1;
}



Re: /stats dialog - PowerF - 18.12.2014

Quote:
Originally Posted by Ciandlah
Посмотреть сообщение
Or for a much more effective and efficient way

Код:
enum
{
	STATS
};

CMD: stats(playerid, params[]) {
	new string[128], para[128], pDeaths, player1, playername[MAX_PLAYER_NAME];
	if(isnull(params)) player1 = playerid;
	else player1 = strval(params)
	
	if(IsPlayerConnected(playerid)) {
		GetPlayerName(player1, playername, sizeof(playername));
		if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
		
		format(string, sizeof(string), "%s's Statistics", PlayerName2(player1));
		format(para,sizeof(para),"Scores: %d | Money: $%d | Kills: %d | Deaths: %d | K/D Ratio: %0.2f", GetPlayerScore(player1), GetPlayerMoney(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths);

		ShowPlayerDialog(playerid, STATS, DIALOG_STYLE_MSGBOX, string, para, "", "Close");
	} else return SendClientMessage(playerid, red, "Player Not Connected!");
	return 1;
}
Код:
C:\Program Files\Call of Duty black Ops 2 Script\gamemodes\codww.pwn(15699) : error 001: expected token: ";", but found "if"
C:\Program Files\Call of Duty black Ops 2 Script\gamemodes\codww.pwn(18329) : error 030: compound statement not closed at the end of file (started at line 18327)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: /stats dialog - JeaSon - 18.12.2014

you forget " ; "

change this
pawn Код:
else player1 = strval(params)
to

pawn Код:
else player1 = strval(params);



Re: /stats dialog - Stinged - 18.12.2014

This wouldn't fix your problem, but it will bug the command.
Change IsPlayerConnected(playerid) to IsPlayerConnected(player1)