what is wrong here ?
#1

when i tupe /banid in my server i get ban my self i dont tupe any id...
pawn Код:
CMD:banid(playerid, params[])
{
    if(IsPlayerAdmin2[playerid] == 2)
    {
        new targetid, reason[128], name[24], msg[64];
        if(sscanf(params, "us", targetid)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /banid <playerid> <reason>");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "that player is not connected");
        GetPlayerName(targetid, name, sizeof(name));
        format(msg, sizeof(msg), "%s (%d) was banned. Reason: %s", name, targetid, reason);
        SendClientMessageToAll(0xFFFFFFFF, msg);
        if(GetPVarInt(targetid, "Logged"))
        {
            new filename[64];
            format(filename, sizeof(filename), "MaceRP/users/%s.ini", PlayerName(targetid));
            dini_IntSet(filename, "Banned", 1);
        }
        BanEx(targetid, reason);
        return 1;
    }
    return 1;
}
Reply
#2

You should fix the sscanf format.

pawn Код:
if(sscanf(params, "us[128]", targetid, reason))
Reply
#3

omg i dont even look at that i was looking this code 10 mins to see what is wrong :S
Thanks dude xD
Reply
#4

here is again something bad..
pawn Код:
CMD:banid(playerid, params[])
{
    if(IsPlayerAdmin2[playerid] == 2)
    {
        new targetid, reason[64], name[24], msg[64];
        if(sscanf(params, "us[64]", targetid, reason)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /banid <playerid> <reason>");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "that player is not connected");
        GetPlayerName(targetid, name, sizeof(name));
        format(msg, sizeof(msg), "%s (%d) was banned. Reason: %s", name, targetid, reason);
        SendClientMessageToAll(0xFFFFFFFF, msg);
        if(GetPVarInt(targetid, "Logged"))
        {
            new filename[64];
            format(filename, sizeof(filename), "MaceRP/users/%s.ini", PlayerName(targetid));
            dini_IntSet(filename, "Banned", 1);
        }
        BanEx(targetid, reason);
        GameTextForPlayer(targetid, "You has been banned", 4000, 3);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You can't use this command.");
        return 1;
    }
}
i'm still getting banned when ill tupe /banid
please somebody tell me what is the problem :/
Reply
#5

Here is my old /ban cmd modify for your needs:
pawn Код:
dcmd_ban(playerid, params[])
{
    if(IsPlayerAdmin2[playerid] == 2)
    {
    new level;
    new pid;
    if (sscanf(params, "us", pid, level))
    {
        SendClientMessage(playerid, 0xFF0000AA, "USAGE: /ban [ID] [Reason] - Ban a rule-breaker.");
    }
    else if (pid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    else
    {
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(pid, pname, sizeof(pname));
    new string[256];
    format(string, sizeof(string), "Administrator %s have banned %s for: %s", name, pname, level);
    SendClientMessageToAll(COLOR_BLUE, string);
    Ban(pid);
    }
    return 1;
}
    else return SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be an admin level 4 or higher to use this command.");
Note: You got to fix colors and messages to get this working.
Reply
#6

Quote:
Originally Posted by expertprogrammer
Посмотреть сообщение
Here is my old /ban cmd modify for your needs:
pawn Код:
dcmd_ban(playerid, params[])
{
    if(IsPlayerAdmin2[playerid] == 2)
    {
    new level;
    new pid;
    if (sscanf(params, "us", pid, level))
    {
        SendClientMessage(playerid, 0xFF0000AA, "USAGE: /ban [ID] [Reason] - Ban a rule-breaker.");
    }
    else if (pid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    else
    {
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(pid, pname, sizeof(pname));
    new string[256];
    format(string, sizeof(string), "Administrator %s have banned %s for: %s", name, pname, level);
    SendClientMessageToAll(COLOR_BLUE, string);
    Ban(pid);
    }
    return 1;
}
    else return SendClientMessage(playerid,COLOR_RED,"ERROR: You need to be an admin level 4 or higher to use this command.");
Note: You got to fix colors and messages to get this working.
Thanks dude i fix this i just forgot to return...
pawn Код:
if(sscanf(params, "us[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /banid <playerid> <reason>");
FIXED
Reply
#7

pawn Код:
if(IsPlayerAdmin2[playerid] == 2)
Does this mean if an administrator is level 2 he could ban, or it just confirms he's admin no level?

If it confirms the level I would use
pawn Код:
if(IsPlayerAdmin2[playerid] >= 2)
, so level 3 administrator's could use /ban. Hope I helped you good luck with your script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)