ZCMD bug
#1

Well,i have made few commands,when i type the command alone without anything else it tells me to put id,but when i put invalid id it says invalid id,but when i put an id that exists is sends me the error message ,i am using ZCMD
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{

    return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(success) printf("%s performed the command ( %s )", PlayerName(playerid), cmdtext);
    if(!success)
    {
        format(string, sizeof(string), " Error:The command performed does not exist. ( %s )", cmdtext);
        return SendClientMessage(playerid,-1, string);
    }
    return 1;
}
CMD:resetplayer(playerid, params[])
{
    new player;
    if(!sscanf(params, "d", player))
    {
        if(pInfo[player][playercreated] != 1) return SendClientMessage(playerid, -1, "Invalid player id");
        else
        {
            pInfo[player][playercreated] = 0; //it only changes these two things
            pInfo[player][playeruserid] = 0; //it only changes these two things
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(pInfo[i][offerfrom] == player)
                {
                    pInfo[i][offerfrom] = 0;
                }
            }
            pInfo[player][playerphone] = 0;
            pInfo[player][playernumber] = 0;
            pInfo[player][playerkills] = 0;
            pInfo[player][playerdeaths] = 0;
            pInfo[player][playeritems] = 0;
            format(string, sizeof(string), "You have deleted player id %d.", player);
            SendClientMessage(playerid, COLOR_GREY, string);
            new query[128];
            mysql_format(dbHandle, query, sizeof(query), "DELETE * FROM `accounts` WHERE `Username`=%d", GetName(player));
            printf("%d deleted", player);
            mysql_tquery(dbHandle, query, "", "");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "/resetplayer [playerid]");
    }
    return 1;
}
Reply
#2

Where are you setting pInfo[playerid][playercreated] to 1?
Reply
#3

no worries ,i am sure it's set right i mean playercreated
Reply
#4

Well that seems to be the best place to begin fixing your problem as that is as far as the code goes.
Reply
#5

Why don't you just use IsPlayerConnected instead? It'll also prevent run time error 4 in case the player does not exist and player variable is INVALID_PLAYER_ID (65535).
Reply
#6

the problem is that i am sure the player is connected,i am using it on me.
Reply
#7

Hi iBots,

Код:
if(pInfo[player][playercreated] != 1) return SendClientMessage(playerid, -1, "Invalid player id");
You said that no matter if you enter a valid or invalid ID you get that error message which leads me to believe that when you are trying to use this command that the pInfo[player][playercreated] is always not equal to 1 which results in this message being displayed.

Can you show us where you set pInfo[player][playercreated]?
Reply
#8

i said if i put invalid id it says invalid id,but when i put a valid id it shows command error
Reply
#9

Quote:
Originally Posted by iBots
Посмотреть сообщение
i said if i put invalid id it says invalid id,but when i put a valid id it shows command error
So do what others said
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)