/check command not detecting Target's statistics correctly.
#1

So a few of my Administrators have been saying this command isn't checking peoples stats correctly. So I'm just asking here, if the code looks fine or not? Is there a reason it's not detecting the player's statistics correctly?

EDIT: I just checked the command myself, and it's displaying all of my stats as 0. Same with other players on my server.
pawn Код:
CMD:check(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >=2)
    {
        new target;
        new cash, vip, kills, deaths, score;
        cash = PlayerInfo[target][pCash];
        vip = PlayerInfo[target][pVip];
        kills = PlayerInfo[target][pKills];
        deaths = PlayerInfo[target][pDeaths];
        score = PlayerInfo[target][pScore];
        if(sscanf(params, "u",target)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /check [playerid]");
        if(!IsPlayerConnected(target)) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player ID is not connected.");
        {
            new string[200];
            format(string,sizeof(string), "%s's current statistics: Money: %d || VIP: %d || Kills: %d || Deaths: %d || Score: %d || Admin: %s || Talent: %s",GetName(target),cash,vip,kills,deaths,score,GetAdminLvlName(target),GetTalentName(target));
            SendClientMessage(playerid,COLOR_GREEN, string);
        }
    }
    else return SendClientMessage(playerid,COLOR_GREY, ERROR);
    return 1;
}
Reply
#2

You need to do these two lines before anything else

if(sscanf(params, "u",target)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /check [playerid]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player ID is not connected.");

The code you have is always getting player with ID 0's stats.

Код:
CMD:check(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >=2)
    {
        new target;

        if(sscanf(params, "u",target)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /check [playerid]");
        if(!IsPlayerConnected(target)) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player ID is not connected.");

        new string[200];
        format(string,sizeof(string), "%s's current statistics: Money: %d || VIP: %d || Kills: %d || Deaths: %d || Score: %d || Admin: %s || Talent: %s",GetName(target),PlayerInfo[target][pCash],PlayerInfo[target][pVip],PlayerInfo[target][pKills],PlayerInfo[target][pDeaths],PlayerInfo[target][pScore],GetAdminLvlName(target),GetTalentName(target));
        SendClientMessage(playerid,COLOR_GREEN, string);
    }
    else return SendClientMessage(playerid,COLOR_GREY, ERROR);
    return 1;
}

// If you want to have some more fun pretty sure this should work

public OnPlayerClickPlayer(playerid, clickedplayerid, source) { new strid[4]; valstr(strid, clickedplayerid); cmd_check(playerid, strid); }
Reply
#3

Instead of "cash, vip, kills, deaths, score;" simply use the player's information(PlayerInfo[target][pCash];, etc) when you format the string.
Reply
#4

this is my version, but with GUI DIALOG if you want, just need some edit

Код:
CMD:check(playerid, params[])
{
	new target;
	if(sscanf(params, "u",target)) return SendClientMessage(playerid, COLOR_WHITE, "USE: /check [ID].");
	if(!IsPlayerConnected(target)) return SendClientMessage(playerid,COLOR_RED, "Player is not connected.");
    new Float:health;
	GetPlayerHealth(target, health);
	new Float:armour;
	GetPlayerArmour(target, armour);
    new stats[1280];
    format(stats, sizeof(stats), "{44A1D0}Sex: {FFFFFF}[coming soon]\n{44A1D0}EXP: {FFFFFF}%d\n{44A1D0}Health: {FFFFFF}%f\n{44A1D0}Armour: {FFFFFF}%f\n{44A1D0}Cash: {FFFFFF}$%d\n{44A1D0}Salary: {FFFFFF}[[coming soon]\n{44A1D0}Licenze: {FFFFFF}[coming soon]\n{44A1D0}Job: {FFFFFF}[[coming soon]\n{44A1D0}Director: {FFFFFF}[coming soon]\n{44A1D0}Car: {FFFFFF}[[coming soon]\n{44A1D0}Kills: {FFFFFF}%d\n{44A1D0}Deaths: {FFFFFF}%d\n{44A1D0}Admin: {FFFFFF}%d\n{44A1D0}Warns: {FFFFFF}%d\n",
	PlayerInfo[target][pEXP], health, armour, PlayerInfo[target][pCash], PlayerInfo[target][pKills], PlayerInfo[target][pDeaths], PlayerInfo[target][pAdmin], PlayerInfo[target][pWarns]);
    ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Information",stats,"Ok","");
    return 1;
}
Reply
#5

pawn Код:
CMD:check(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >=2)
    {
        new target;
        if(sscanf(params, "u",target)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /check [playerid]");
        if(!IsPlayerConnected(target)) return SendClientMessage(playerid,COLOR_RED, "ERROR: Player ID is not connected.");
        new string[200];
        format(string,sizeof(string), "%s's current statistics: Money: %d || VIP: %d || Kills: %d || Deaths: %d || Score: %d || Admin: %s || Talent: %s",GetName(target),
        PlayerInfo[target][pCash],
        PlayerInfo[target][pVip],
        PlayerInfo[target][pKills],
        PlayerInfo[target][pDeaths],
        PlayerInfo[target][pScore],
        GetAdminLvlName(target),
        GetTalentName(target));
        SendClientMessage(playerid,COLOR_GREEN, string);
    }
    else return SendClientMessage(playerid,COLOR_GREY, ERROR);
    return 1;
}
This command seems good, you just have to check if your vars are okay as well.
Reply
#6

Thank you everyone.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)