30.06.2015, 20:08
You kinda screwed up with bracket/blocks usage, so my suggestion is to start using an indent style when you write code, to help you spot those kind of mistakes, also makes it alot easier to find a certain bit of code in a wall of text. Cleaned up the code a bit aswell, combined variable creation to top of function and some other small things.
Код:
#if defined USE_STATS CMD:stats(playerid,params[]) { new playerName[MAX_PLAYER_NAME], dialogTitle[MAX_PLAYER_NAME+24], dialogString[128], killDeathRatio, pDeaths, player1, h, m, s; if(isnull(params)) { player1 = playerid; } else { player1 = strval(params); } if(IsPlayerConnected(player1)) { TotalGameTime(player1, h, m, s); if(PlayerInfo[player1][Deaths] == 0) { pDeaths = 1; } else { pDeaths = PlayerInfo[player1][Deaths]; } killDeathRatio = Float:PlayerInfo[player1][Kills]/Float:pDeaths; GetPlayerName(player1, playerName, sizeof(playerName)); format(dialogTitle, sizeof(dialogTitle), "Stats of %s", playerName); format(dialogString, sizeof(dialogString), "Level: %d \nKills: %d \nDeaths: %d \nRatio: %0.2f \nMoney: $%d \nBank: $%d \nTime: %d hrs %d mins %d secs", PlayerInfo[player1][Level], PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:killDeathRatio, GetPlayerMoney(player1), PlayerInfo[player1][bank], h, m, s); ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, dialogTitle, dialogString, "Ok", ""); } else { SendClientMessage(playerid, red, "Player Not Connected!"); } return 1; } #endif