ID Bug Again.
#1

I am having a serious problem with my server, yesterday i saw someone hacking in my server, then when i tried the /ban command on him over Client message it returned that Jockey_Hary has been banned from the server by an admin, but actually instead of him the server banned me.. and the unban is only possible by /rcon unbanip what is this i didnt understand at all, help me out please.
Reply
#2

Are we meant to guess your code?
Reply
#3

Well sure, here you go, thats not just ban requires rcon unban but also auto ban require /rcon unban. Alright here's the code
pawn Код:
CMD:ban(playerid, params[])
{
    new playerb, ip;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    if(PlayerInfo[playerid][pAdmin] > 1) {
        new player, reason[126];
        if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /ban [playerid] [reason]");

        if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
        new string[126];

        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[player][pAdmin])
        {
            format(string, sizeof(string), "AdmCmd: %s has been kicked because they attempted to ban a higher admin!", RPN(playerid));
            SendClientMessageToAll(COLOR_DARKRED, string);
        }

        format(string, sizeof(string), "AdmCmd: %s has been banned by %s %s, reason: %s",RPN(playerb), RPALN(playerid), RPN(playerid), reason);
        SendClientMessageToAll(COLOR_DARKRED, string);
        Ban(playerid);
        AddBan(ip);
    }
    return 1;
}
Reply
#4

pawn Код:
CMD:ban(playerid, params[])
{
    new playerb, ip;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    if(PlayerInfo[playerid][pAdmin] > 1) {
        new player, reason[126];
        if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /ban [playerid] [reason]");

        if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
        new string[126];

        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[player][pAdmin])
        {
            format(string, sizeof(string), "AdmCmd: %s has been kicked because they attempted to ban a higher admin!", RPN(playerid));
            SendClientMessageToAll(COLOR_DARKRED, string);
        }

        format(string, sizeof(string), "AdmCmd: %s has been banned by %s %s, reason: %s",RPN(playerb), RPALN(playerid), RPN(playerid), reason);
        SendClientMessageToAll(COLOR_DARKRED, string);
        Ban(playerb); // you were using "playerid" as targeted player
        AddBan(ip);
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by HyperZ
Посмотреть сообщение
pawn Код:
CMD:ban(playerid, params[])
{
    new playerb, ip;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    if(PlayerInfo[playerid][pAdmin] > 1) {
        new player, reason[126];
        if(sscanf(params, "us[126]", player, reason)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /ban [playerid] [reason]");

        if(!IsPlayerConnected(player)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
        new string[126];

        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[player][pAdmin])
        {
            format(string, sizeof(string), "AdmCmd: %s has been kicked because they attempted to ban a higher admin!", RPN(playerid));
            SendClientMessageToAll(COLOR_DARKRED, string);
        }

        format(string, sizeof(string), "AdmCmd: %s has been banned by %s %s, reason: %s",RPN(playerb), RPALN(playerid), RPN(playerid), reason);
        SendClientMessageToAll(COLOR_DARKRED, string);
        Ban(playerb);
        AddBan(ip);
    }
    return 1;
}
Still unsure what i did wrong.
Reply
#6

Quote:
Originally Posted by Imperor
Посмотреть сообщение
Still unsure what i did wrong.
Edited.
Reply
#7

What did you edit can i know?
Reply
#8

Quote:
Originally Posted by Imperor
Посмотреть сообщение
What did you edit can i know?
You were using "playerid" as targeted playerid, that's why you got banned instead of the targeted player.

It should be:
pawn Код:
Ban(playerb);
Instead of:
pawn Код:
Ban(playerid);
Could you tell show me "AddBan" function too? As i can see you're doing "AddBan(ip)" thingy wrong.
Reply
#9

Here you go mate.
pawn Код:
stock AddBan(playerid)
{
    new string[24];
    new File:ban = fopen("ban.cfg", io_append);
    format(string, sizeof(string), "%s\r\n", RPIP(playerid));
    fwrite(ban, string);
    fclose(ban);
}
Reply
#10

Here is your fixed code, and i removed some useless, or unneeded vars. Now your ban system is script sided.
pawn Код:
CMD:ban(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    if(PlayerInfo[playerid][pAdmin] > 1)
    {
        new playerb, reason[126];
        if(sscanf(params, "us[126]", playerb, reason)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /ban [playerid] [reason]");

        if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
        new string[126];

        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin])
        {
            format(string, sizeof(string), "AdmCmd: %s has been kicked because they attempted to ban a higher admin!", RPN(playerid));
            SendClientMessageToAll(COLOR_DARKRED, string);
        }

        format(string, sizeof(string), "AdmCmd: %s has been banned by %s %s, reason: %s",RPN(playerb), RPALN(playerid), RPN(playerid), reason);
        SendClientMessageToAll(COLOR_DARKRED, string);

        AddBan(playerb);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)