SA-MP Forums Archive
ZCMD bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: ZCMD bug (/showthread.php?tid=571113)



ZCMD bug - iBots - 16.04.2015

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;
}



Re: ZCMD bug - Infamous - 16.04.2015

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


Re: ZCMD bug - iBots - 16.04.2015

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


Re: ZCMD bug - Infamous - 16.04.2015

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


Re: ZCMD bug - Konstantinos - 16.04.2015

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).


Re: ZCMD bug - iBots - 16.04.2015

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


Re: ZCMD bug - MEW273 - 16.04.2015

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]?


Re: ZCMD bug - iBots - 16.04.2015

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


Re: ZCMD bug - ATGOggy - 16.04.2015

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