SA-MP Forums Archive
[SOLVED]Dialog /stats Bugged - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED]Dialog /stats Bugged (/showthread.php?tid=119634)



[SOLVED]Dialog /stats Bugged - PotH3Ad - 08.01.2010

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.


Re: Dialog /stats Bugged - Joe Staff - 08.01.2010

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.


Re: Dialog /stats Bugged - PotH3Ad - 09.01.2010

Thanks for the help, works good now.