Only ID 1 + can use ban..
#10

Quote:
Originally Posted by player007
Now I know why !
You have a bad order of code, the "playerid == TargetID" check is actually done before sscanf, so it is always 0, as newly created variables will always be set to 0 by default.
Therefore the check is like "if playerid (which is 0, because only you are in the test server) is equal to 0"
Bottom line, use this order:
pawn Код:
if (sscanf(params, "uz", TargetID, reason) != 0)
    {
        SendClientMessage(playerid, COLOR_WHITE, "Usage: /ban (id/name) [reason]");
        return 1;
    }
    if(playerid == TargetID)
    {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot ban yourself.");
        return 1;
    }
Would this work?

pawn Код:
dcmd_ban(playerid,params[])
{
    new giveplayerid,string[128], name[24];
    if(pInfo[playerid][Level] < 3) return SendClientMessage(playerid,COLOR_RED,"You must be level 3 to ban someone!");
    if(sscanf(params,"uz",giveplayerid,params)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /ban (id) [reason]");
    if(giveplayerid == playerid) return SendClientMessage(playerid,COLOR_RED,"ERROR: You cannot ban yourself.");
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,COLOR_RED,"ERROR: Invalid ID!");

    GetPlayerName(giveplayerid, name,sizeof(name));
    format(string,128,"%s(%d) has been banned by %s(%d). [Reason: %s]",name,giveplayerid,ReturnPlayerName(playerid),playerid,params);
    SendClientMessageToAll(COLOR_RED,string);
    SendClientMessage(giveplayerid,COLOR_RED,"SERVER: You have been banned from the server.");

    ResetPlayerWeapons(giveplayerid);
    GivePlayerWeapon(giveplayerid,10,1);
    SetPlayerWeather(giveplayerid,150);
    SetPlayerSkin(giveplayerid,77);
    BanEx(giveplayerid,params);
    return 1;
}
Also, my kick command was exactly like my first posted ban command (first post), accept i made it ban instead of kick, and the kick works fine :P
Reply


Messages In This Thread
Only ID 1 + can use ban.. - by _Vortex - 16.09.2009, 02:21
Re: Only ID 1 + can use ban.. - by Clavius - 16.09.2009, 13:15
Re: Only ID 1 + can use ban.. - by _Vortex - 16.09.2009, 16:39
Re: Only ID 1 + can use ban.. - by Clavius - 16.09.2009, 16:50
Re: Only ID 1 + can use ban.. - by _Vortex - 16.09.2009, 17:11
Re: Only ID 1 + can use ban.. - by Clavius - 16.09.2009, 17:17
Re: Only ID 1 + can use ban.. - by _Vortex - 16.09.2009, 17:20
Re: Only ID 1 + can use ban.. - by _Vortex - 16.09.2009, 17:49
Re: Only ID 1 + can use ban.. - by Clavius - 16.09.2009, 18:23
Re: Only ID 1 + can use ban.. - by _Vortex - 16.09.2009, 20:42

Forum Jump:


Users browsing this thread: 1 Guest(s)