/stats dialog
#1

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

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
Reply
#3

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;
}
Reply
#4

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

you forget " ; "

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)