I don't know what's wrong with /kick and /ban?
#1

Well, today KiNG3 scripted /kick for me and I script /ban, but when I tested in the server, it shows the message but it didn't kick me, why?

Kick and Ban:
pawn Код:
CMD:kick(playerid,params[])
{
    new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME]; // iu've never used +1 after MAX_PLAYERNAME
    new targetid, reason;
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
    if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 1)
    {
        if(sscanf(params,"us[128]", targetid, reason)) return SendClientMessage(playerid, yellow, "[USAGE]: /kick [id/name] [reason]");
        else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
        else if(targetid <= pInfo[playerid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Hey, what are you trying to do?");
        format(string, sizeof(string), "[INFO]:{FFFFFF} Administrator %s has kicked %s (Reason: %s)", name, name2, reason);
        SendClientMessageToAll(COLOR_BLUE, string);
        Kick(targetid);
    }
    else return SendClientMessage(playerid, red, "[ERROR]: You have no permission to use this command.");
    return 1;
}

CMD:ban(playerid,params[])
{
    new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
    new targetid, reason;
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
    if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 2)
    {
        if(sscanf(params,"us[128]", targetid, reason)) return SendClientMessage(playerid, yellow, "[USAGE]: /ban [id/name] [reason]");
        else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
        else if(targetid <= pInfo[playerid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Hey, what are you trying to do?");
        format(string, sizeof(string), "[INFO]:{FFFFFF} Administrator %s has banned %s (Reason: %s)", name, name2, reason);
        SendClientMessageToAll(COLOR_BLUE, string);
        Kick(targetid);
        {
            new INI:file = INI_Open(Path(targetid));
            INI_WriteInt(file, "Banned", 1);
            INI_Close(file);
        }
    }
    else return SendClientMessage(playerid, red, "[ERROR]: You have no permission to use this command.");
    return 1;
}
Anyone has idea to fix it?
Reply
#2

Which message does it show?
Reply
#3

It shows the string but it doesn't kick me or another one.
Reply
#4

I tested it out on my script, works perfectly fine..
pawn Код:
CMD:kick(playerid,params[])
{
    new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME]; // iu've never used +1 after MAX_PLAYERNAME
    new targetid, reason;
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
    if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 1)
    {
        if(sscanf(params,"us[128]", targetid, reason)) return SendClientMessage(playerid, yellow, "[USAGE]: /kick [id/name] [reason]");
        else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
        else if(targetid <= pInfo[playerid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Hey, what are you trying to do?");
        format(string, sizeof(string), "[INFO]:{FFFFFF} Administrator %s has kicked %s (Reason: %s)", name, name2, reason);
        SendClientMessageToAll(COLOR_BLUE, string);
        SetTimerEx("KickPlayer", 1000, true, "i", targetid);
    }
    else return SendClientMessage(playerid, red, "[ERROR]: You have no permission to use this command.");
    return 1;
}

forward KickPlayer(targetid);
public KickPlayer(targetid)
{
    Kick(targetid);
    return 1;
}
Reply
#5

KiNG3, it still shows me the [INFO]: Administrator name has kicked (notname) (Reason: (reasonhere)) and didn't kick them out from the server.
Reply
#6

That's weird, because it works fine for me :/
Reply
#7

Quote:
Originally Posted by LeeXian99
Посмотреть сообщение
Well, today KiNG3 scripted /kick for me and I script /ban, but when I tested in the server, it shows the message but it didn't kick me, why?

Kick and Ban:
pawn Код:
CMD:kick(playerid,params[])
{
    new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME]; // iu've never used +1 after MAX_PLAYERNAME
    new targetid, reason;
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
    if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 1)
    {
        if(sscanf(params,"us[128]", targetid, reason)) return SendClientMessage(playerid, yellow, "[USAGE]: /kick [id/name] [reason]");
        else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
        else if(targetid <= pInfo[playerid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Hey, what are you trying to do?");
        format(string, sizeof(string), "[INFO]:{FFFFFF} Administrator %s has kicked %s (Reason: %s)", name, name2, reason);
        SendClientMessageToAll(COLOR_BLUE, string);
        Kick(targetid);
    }
    else return SendClientMessage(playerid, red, "[ERROR]: You have no permission to use this command.");
    return 1;
}

CMD:ban(playerid,params[])
{
    new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
    new targetid, reason;
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
    if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 2)
    {
        if(sscanf(params,"us[128]", targetid, reason)) return SendClientMessage(playerid, yellow, "[USAGE]: /ban [id/name] [reason]");
        else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
        else if(targetid <= pInfo[playerid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Hey, what are you trying to do?");
        format(string, sizeof(string), "[INFO]:{FFFFFF} Administrator %s has banned %s (Reason: %s)", name, name2, reason);
        SendClientMessageToAll(COLOR_BLUE, string);
        Kick(targetid);
        {
            new INI:file = INI_Open(Path(targetid));
            INI_WriteInt(file, "Banned", 1);
            INI_Close(file);
        }
    }
    else return SendClientMessage(playerid, red, "[ERROR]: You have no permission to use this command.");
    return 1;
}
Anyone has idea to fix it?
1)You are getting a name before sscanf, the name will not be the actual player name.
2)You have to use timers, you can't place a Kick soon after sending a ClientMessage.The message will not be shown.

This is a working code
Код:
CMD:kick(playerid,params[])
{
    new id,name1[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],reason[128],string[256];
    if(Admin[playerid] >= YOURLEVEL)
   {
           if(sscanf(params,"us",id,reason )) { SendClientMessage(playerid,COLOR_ERROR,"Usage:/kick [id/name]          [reason]");  
          return 1; 
    }
    if(!IsPlayerConnected(id)) { SendClientMessage(playerid,COLOR_ERROR,"invalid playrerid"); return 1; }
    format(string,sizeof(string),"ADMIN-BAN>>%s(%d) has been banned from the server - %s",name2,id,reason);
    SendClientMessageToAll(COLOR_ADMIN,string);
    SetTimerEx("xKick","i",id);
}
SendClientMessage(playerid,COLOR_RED,"You are not an administrator");
    return 1;
}

forward xKick(playerid);
public xKick(playerid)
{
   Kick(playerid);
}
Reply
#8

That is not going to work,

A) You basically took that straight out from your script, the variables don't even match his.. You are required to post TESTED code.

B) for us you need to have a string to it, s is the string so it should be us[128]

C) My kick cmd doesn't have a timer set to it.... It isn't required.

pawn Код:
CMD:kick(playerid,params[])
{
    new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME]; // iu've never used +1 after MAX_PLAYERNAME
    new targetid, reason;
    if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 1)
    {
        if(sscanf(params,"us[128]", targetid, reason)) return SendClientMessage(playerid, yellow, "[USAGE]: /kick [id/name] [reason]");
        else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
        else if(targetid <= pInfo[playerid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Hey, what are you trying to do?");
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
        format(string, sizeof(string), "[INFO]:{FFFFFF} Administrator %s has kicked %s (Reason: %s)", name, name2, reason);
        SendClientMessageToAll(COLOR_BLUE, string);
        Kick(targetid);
    }
    else return SendClientMessage(playerid, red, "[ERROR]: You have no permission to use this command.");
    return 1;
}
It is shocking, all the code I use is tested, but my variables were already defined, so that's probably why. But here.
Reply
#9

i can script another one for you and try if its works
Reply
#10

Man try to download Admin System.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)