Stats command problem
#1

I've got this stats command, and sometimes if you put someones id in, it'll return "Command not found".. Please help.

pawn Код:
dcmd_stats(playerid,params[])
{
    new pName[24], PlayerFile[50];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(PlayerFile, sizeof(PlayerFile), "AdminScript/Users/%s.ini", pName);
    pInfo[playerid][Deaths] = dini_Int(PlayerFile, "Deaths");
    if(!pInfo[playerid][Logged])
    {
        SendClientMessage(playerid,COLOR_RED,"ERROR: You must be loggedin to view your stats.");
        return 1;
    }
    if(params[0])
    {
        new giveplayerid = strval(params),string[128];
        if(!IsPlayerConnected(giveplayerid))
        {
            SendClientMessage(playerid,COLOR_RED,"ERROR: Invalid ID.");
            return 1;
        }
        if(!pInfo[giveplayerid][Logged])
        {
            SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not logged in");
            return 1;
        }
        if(giveplayerid == playerid)
        {
            format(string,128,"| Your Stats: | Kills: %d | Deaths: %d | Ratio: %d | Money: %d | Level: %d |",pInfo[playerid][Kills],pInfo[playerid][Deaths],pInfo[playerid][Kills] / pInfo[playerid][Deaths],GetPlayerMoney(playerid),pInfo[playerid][pLevel]);
            SendClientMessage(playerid,COLOR_WHITE,string);
            return 1;
        }
        format(string,128,"| Stats for %s: | Kills: %d | Deaths: %d | Ratio: %f | Money: %d | Level: %d |",ReturnPlayerName(giveplayerid),pInfo[giveplayerid][Kills],pInfo[giveplayerid][Deaths],pInfo[giveplayerid][Kills] / pInfo[giveplayerid][Deaths],GetPlayerMoney(giveplayerid),pInfo[giveplayerid][pLevel]);
        SendClientMessage(playerid,COLOR_WHITE,string);
        return 1;
    }
    else
    {
        new string[128];
        format(string,128,"| Your Stats: | Kills: %d | Deaths: %d | Ratio: %f | Money: %d | Level: %d |",pInfo[playerid][Kills],pInfo[playerid][Deaths],pInfo[playerid][Kills] / pInfo[playerid][Deaths],GetPlayerMoney(playerid),pInfo[playerid][pLevel]);
        SendClientMessage(playerid,COLOR_WHITE,string);
        return 1;
    }
}
Reply
#2

?? That's a /stats command not a /spec command.
Reply
#3

Sorry, I meant stats. I'm not sure where my mind is xD
Reply
#4

well im not so sure about that problem but
pawn Код:
if(!IsPlayerConnected(giveplayerid))
        {
            SendClientMessage(playerid,COLOR_RED,"ERROR: Invalid ID.");
            return 1;
        }
        if(!pInfo[giveplayerid][Logged])
        {
            SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not logged in");
            return 1;
        }
        if(giveplayerid == playerid)
        {
            format(string,128,"| Your Stats: | Kills: %d | Deaths: %d | Ratio: %d | Money: %d | Level: %d |",pInfo[playerid][Kills],pInfo[playerid][Deaths],pInfo[playerid][Kills] / pInfo[playerid][Deaths],GetPlayerMoney(playerid),pInfo[playerid][pLevel]);
            SendClientMessage(playerid,COLOR_WHITE,string);
            return 1;
        }
        format(string,128,"| Stats for %s: | Kills: %d | Deaths: %d | Ratio: %f | Money: %d | Level: %d |",ReturnPlayerName(giveplayerid),pInfo[giveplayerid][Kills],pInfo[giveplayerid][Deaths],pInfo[giveplayerid][Kills] / pInfo[giveplayerid][Deaths],GetPlayerMoney(giveplayerid),pInfo[giveplayerid][pLevel]);
        SendClientMessage(playerid,COLOR_WHITE,string);
        return 1;
    }

should be

pawn Код:
if(!IsPlayerConnected(giveplayerid))
        {
            SendClientMessage(playerid,COLOR_RED,"ERROR: Invalid ID.");
            return 1;
        }
         else
        if(!pInfo[giveplayerid][Logged])
        {
            SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not logged in");
            return 1;
        }
         else
        if(giveplayerid == playerid)
        {
            format(string,128,"| Your Stats: | Kills: %d | Deaths: %d | Ratio: %d | Money: %d | Level: %d |",pInfo[playerid][Kills],pInfo[playerid][Deaths],pInfo[playerid][Kills] / pInfo[playerid][Deaths],GetPlayerMoney(playerid),pInfo[playerid][pLevel]);
            SendClientMessage(playerid,COLOR_WHITE,string);
            return 1;
        }
         else
        format(string,128,"| Stats for %s: | Kills: %d | Deaths: %d | Ratio: %f | Money: %d | Level: %d |",ReturnPlayerName(giveplayerid),pInfo[giveplayerid][Kills],pInfo[giveplayerid][Deaths],pInfo[giveplayerid][Kills] / pInfo[giveplayerid][Deaths],GetPlayerMoney(giveplayerid),pInfo[giveplayerid][pLevel]);
        SendClientMessage(playerid,COLOR_WHITE,string);
        return 1;
    }
if u don't set the else
it will continue anyway
even if theres no player connected or logged in and it would send both clientmessages, the one for giveplayerid == playerid and the other.

-SaiBerFun
Reply
#5

Where to add it this?
And if i have errors, to add dini?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)