/stats not shown +REP
#1

Script :

Код:
CMD:stats(playerid,params[]) {
	new stats[876], sstring[876], 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];
        format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nKills : %d\nDeaths : %d\nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds", PlayerName2(player1),playerid,PlayerName2(player1),PlayerInfo[player1][Level],GetRankFromLevel(playerid),GetPlayerMoney(player1),PlayerInfo[player1][bank],PlayerInfo[player1][Kills],PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths, h, m, s);
        strcat(stats,sstring);
		return ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",stats,"Close","");
	} else return SendClientMessage(playerid, red, "Player Not Connected!");
}
Bug : Not Shown when type /stats or /stats [playerid].

The problem is the dialogs dont show.
Tried everything but it won't work.
Please Help Me to Fix This !!!

I'll Give some +REP if you can helping me.


*SorryForMyLittleEnglish
Reply
#2

Damn, what a mess you got there... You should use sscanf and atleast organize your code.

pawn Код:
CMD:stats(playerid,params[])
{
    new sstring[500], Float:pDeaths, id, h, m, s;
    if(sscanf(params, "u", id))
    {
        TotalGameTime(playerid, h, m, s);
        format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nDeaths : %d\nKills : %d \
        \nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds"
, PlayerName2(playerid), playerid, PlayerName2(playerid), PlayerInfo[playerid][Level], \
        GetRankFromLevel(playerid), GetPlayerMoney(playerid), PlayerInfo[playerid][bank], PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], \
        PlayerInfo[playerid][Kills], pDeaths, h, m, s);
        ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",sstring,"Close","");
        return 1;
    }
    if(!IsPlayerConnected(id))
    {
        format(sstring, sizeof (sstring), "Player isn't connected to the server.");
        SendClientMessage(playerid, 0xFFFFFFFF, sstring);
        return 1;
    }
    TotalGameTime(id, h, m, s);
    format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nDeaths : %d\nKills : %d \
    \nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds"
, PlayerName2(id), id, PlayerName2(id), PlayerInfo[id][Level], \
    GetRankFromLevel(id), GetPlayerMoney(id), PlayerInfo[id][bank], PlayerInfo[id][Kills], PlayerInfo[id][Deaths], \
    PlayerInfo[id][Kills], pDeaths, h, m, s);
    ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",sstring,"Close","");
}
Note: pDeaths won't work as it isn't assigned to anything.
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Damn, what a mess you got there... You should use sscanf and atleast organize your code.

pawn Код:
CMD:stats(playerid,params[])
{
    new sstring[500], Float:pDeaths, id, h, m, s;
    if(sscanf(params, "u", id))
    {
        TotalGameTime(playerid, h, m, s);
        format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nDeaths : %d\nKills : %d \
        \nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds"
, PlayerName2(playerid), playerid, PlayerName2(playerid), PlayerInfo[playerid][Level], \
        GetRankFromLevel(playerid), GetPlayerMoney(playerid), PlayerInfo[playerid][bank], PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], \
        PlayerInfo[playerid][Kills], pDeaths, h, m, s);
        ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",sstring,"Close","");
        return 1;
    }
    if(!IsPlayerConnected(id))
    {
        format(sstring, sizeof (sstring), "Player isn't connected to the server.");
        SendClientMessage(playerid, 0xFFFFFFFF, sstring);
        return 1;
    }
    TotalGameTime(id, h, m, s);
    format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nDeaths : %d\nKills : %d \
    \nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds"
, PlayerName2(id), id, PlayerName2(id), PlayerInfo[id][Level], \
    GetRankFromLevel(id), GetPlayerMoney(id), PlayerInfo[id][bank], PlayerInfo[id][Kills], PlayerInfo[id][Deaths], \
    PlayerInfo[id][Kills], pDeaths, h, m, s);
    ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",sstring,"Close","");
}
Note: pDeaths won't work as it isn't assigned to anything.
Quote:

G:\GTA SA-MP Installers\SA-MP Server\Golden Ghost Gamers Freeroam\gamemodes\GGG.pwn(21763) : warning 209: function "cmd_stats" should return a value

Warning
Reply
#4

pawn Код:
CMD:stats(playerid,params[])
{
    new sstring[500], Float:pDeaths, id, h, m, s;
    if(sscanf(params, "u", id))
    {
        TotalGameTime(playerid, h, m, s);
        format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nDeaths : %d\nKills : %d \
        \nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds"
, PlayerName2(playerid), playerid, PlayerName2(playerid), PlayerInfo[playerid][Level], \
        GetRankFromLevel(playerid), GetPlayerMoney(playerid), PlayerInfo[playerid][bank], PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], \
        PlayerInfo[playerid][Kills], pDeaths, h, m, s);
        ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",sstring,"Close","");
        return 1;
    }
    if(!IsPlayerConnected(id))
    {
        format(sstring, sizeof (sstring), "Player isn't connected to the server.");
        SendClientMessage(playerid, 0xFFFFFFFF, sstring);
        return 1;
    }
    TotalGameTime(id, h, m, s);
    format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nDeaths : %d\nKills : %d \
    \nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds"
, PlayerName2(id), id, PlayerName2(id), PlayerInfo[id][Level], \
    GetRankFromLevel(id), GetPlayerMoney(id), PlayerInfo[id][bank], PlayerInfo[id][Kills], PlayerInfo[id][Deaths], \
    PlayerInfo[id][Kills], pDeaths, h, m, s);
    ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",sstring,"Close","");
    return 1;
}
Reply
#5

Simple fix, just add a return 1; before the last }
Reply
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
CMD:stats(playerid,params[])
{
    new sstring[500], Float:pDeaths, id, h, m, s;
    if(sscanf(params, "u", id))
    {
        TotalGameTime(playerid, h, m, s);
        format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nDeaths : %d\nKills : %d \
        \nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds"
, PlayerName2(playerid), playerid, PlayerName2(playerid), PlayerInfo[playerid][Level], \
        GetRankFromLevel(playerid), GetPlayerMoney(playerid), PlayerInfo[playerid][bank], PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], \
        PlayerInfo[playerid][Kills], pDeaths, h, m, s);
        ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",sstring,"Close","");
        return 1;
    }
    if(!IsPlayerConnected(id))
    {
        format(sstring, sizeof (sstring), "Player isn't connected to the server.");
        SendClientMessage(playerid, 0xFFFFFFFF, sstring);
        return 1;
    }
    TotalGameTime(id, h, m, s);
    format(sstring,sizeof(sstring),"Stats for %s (ID: %d):\n\nNama : %s\nLevel : %d\nRank : %d\nMoney : $%d\nBank : $%d\n\nDeaths : %d\nKills : %d \
    \nRatio : %0.2f\n\nTime Played : %d hours %d minutes %d seconds"
, PlayerName2(id), id, PlayerName2(id), PlayerInfo[id][Level], \
    GetRankFromLevel(id), GetPlayerMoney(id), PlayerInfo[id][bank], PlayerInfo[id][Kills], PlayerInfo[id][Deaths], \
    PlayerInfo[id][Kills], pDeaths, h, m, s);
    ShowPlayerDialog(playerid,44406,DIALOG_STYLE_MSGBOX,"Stats!",sstring,"Close","");
    return 1;
}
Still not shown
Reply
#7

Did you still get the error after you used that code?
Reply
#8

Quote:
Originally Posted by Infinitas
Посмотреть сообщение
Did you still get the error after you used that code?
No Warnings or Errors
Reply
#9

Please...Somebody can help me ??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)