[SOLVED]Dialog /stats Bugged
#1

Does anyone know what is wrong with this code?

Код:
dcmd_stats(playerid,params[]) {
	new player1;
	new name[MAX_PLAYERS];
	new string[128];
	if(!strlen(params)) player1 = playerid;
	else player1 = strval(params);

	if(IsPlayerConnected(player1)) {
		format(string, sizeof(string),"%s's Stats\n\nKills: %d\nDeaths: %d\nRatio: %0.2f\nMoney: %d", name[player1], PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], PlayerInfo[player1][Kills]/Float:Deaths,GetPlayerMoney(player1));
		return ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_MSGBOX, "Stats", string, "Ok", "Exit");
	} else return SendClientMessage(playerid, COLOR_RED, "Player Not Connected!");
}
If you do "/stats ID" it shows your own stats. How can I make it so it shows the stats of the ID I chose?
Thanks for the help.
Reply
#2

hmm, try this instead.

pawn Код:
dcmd_stats(playerid,params[])
{
  new gplayer;
  if(!params[0])gplayer = playerid;
  else gplayer=strval(params);
  if(!IsPlayerConnected(gplayer))return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
  new tempstring[250];
  GivePlayerName(gplayer,tempstring,sizeof(tempstring));
  format(tempstring,sizeof(tempstring),"%s's Stats\n\nKills: %d\nDeaths: %d\nRatio: %0.1f\nMoney: %d",tempstring,PlayerInfo[gplayer][Kills], PlayerInfo[gplayer][Deaths], floatdiv(PlayerInfo[gplayer][Kills], PlayerInfo[gplayer][Deaths]),GetPlayerMoney(gplayer));
  ShowPlayerDialog(playerid,DIALOGID,DIALOG_STYLE_MSGBOX,"Stats",tempstring,"","Close");
  return 1;
}
Replace DIALOGID with a dialog id that won't interfere with other scripts.
Reply
#3

Thanks for the help, works good now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)