SA-MP Forums Archive
Bug in Warn command - 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: Bug in Warn command (/showthread.php?tid=525687)



Bug in Warn command - Team_PRO - 13.07.2014

i get a bug when i do /warn

pawn Код:
CMD:warn(playerid, params[])
{
    new str[128], id, reason[128];
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,red,error);
    {
        //if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid,-1, "PHT-BOT:"lgreen" /warn (playerid) (reason)")
        if(sscanf(params,"us[128]",id,reason)) return SendClientMessage(playerid,lightgreen,"USAGE: "lyellow2"/warn (id) (reason)");
        if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,red,error2);
        format(str, sizeof(str), "» Administrator %s(%d) warns %s(%d) [Reason: %s]", GetPName(playerid), playerid, GetPName(playerid), playerid, reason);
        SendClientMessageToAll(yellow, str);
        format(str, sizeof(str), "» You warned %s(%d) [Reason: %s]",GetPName(playerid), playerid, reason);
        SendClientMessage(playerid, green, str);
        format(str, sizeof(str), "» You've been warned by Administrator%s(%d) [Reason: %s]",GetPName(playerid), playerid, reason);
        SendClientMessage(id, red, str);
        }
    return 1;
}
when i /warn 1 somereason then i press enter it warn different Player like id 2 or 3 and not the id 1 and when i warn a not connected player id it giving warn to myself any idea to those?


Re: Bug in Warn command - Konstantinos - 13.07.2014

"id" holds the player's ID but you used the "playerid" instead so you checked if the player who typed the command is not connected and also in the messages.

pawn Код:
CMD:warn(playerid, params[])
{
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,red,error);
    new id, reason[64];
    if(sscanf(params,"us[64]",id,reason)) return SendClientMessage(playerid,lightgreen,"USAGE: "lyellow2"/warn (id) (reason)");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,red,error2);
    new str[128];
    format(str, sizeof(str), "» Administrator %s(%d) warns %s(%d) [Reason: %s]", GetPName(playerid), playerid, GetPName(id), id, reason);
    SendClientMessageToAll(yellow, str);
    format(str, sizeof(str), "» You warned %s(%d) [Reason: %s]",GetPName(id), id, reason);
    SendClientMessage(playerid, green, str);
    format(str, sizeof(str), "» You've been warned by Administrator%s(%d) [Reason: %s]",GetPName(playerid), playerid, reason);
    SendClientMessage(id, red, str);
    return 1;
}



Re: Bug in Warn command - Team_PRO - 13.07.2014

how can i make /ask command with same so it will not incompatible?
and /spec(tate) and /endspec

+

how can i put a maximum warning to 3? to /warn command