Help in some commands
#1

Well guys, I made some commands for my server but when I kick/ban someone he logs in again and /pm me what was the reason for kicking me.

There are the codes, Can someone tell me what's the error and Where?

pawn Код:
CMD:kick(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 4)
    {
        new string[128], giveplayerid, reason[64];
        if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "Tip: /kick [playerid] [reason]");

        if(IsPlayerConnected(giveplayerid))
        {
            if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin] && (PlayerInfo[giveplayerid][pHelper] >= 2 || PlayerInfo[giveplayerid][pAdmin] > 0) && playerid != giveplayerid)
            {
                format(string, sizeof(string), "Server Action: %s has been auto-kicked, reason: Trying to /kick a higher admin.", GetPlayerNameEx(playerid));
                ABroadCast(COLOR_YELLOW,string, (PlayerInfo[playerid][pAdmin] == 1) ? (1) : (2));
                Kick(playerid);
                return 1;
            }
            else
            {
                new year, month,day;
                getdate(year, month, day);
                new playerip[32];
                GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
                format(string, sizeof(string), "Server Action: %s (IP:%s) was kicked by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
                Log("logs/kick.log", string);
                if(PlayerInfo[playerid][pAdmin] == 1) Log("logs/moderator.log", string);
                format(string, sizeof(string), "Server Action: %s was kicked by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
                SendClientMessageToAllEx(COLOR_LIGHTRED, string);
                Kick(giveplayerid);
            }
            return 1;
        }
    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid, -1, "You must be on Admin Duty to use this Command!");
    if (PlayerInfo[playerid][pAdmin] >= 2)
    {
        new string[128], giveplayerid, reason[64];
        if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "Tip: /ban [playerid] [reason]");

        if(IsPlayerConnected(giveplayerid))
        {
            if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
            {
                format(string, sizeof(string), "Server Action: %s has been auto-banned, reason: Trying to /ban a higher admin.", GetPlayerNameEx(playerid));
                ABroadCast(COLOR_YELLOW,string,2);
                PlayerInfo[playerid][pBanned] = 1;
                new ip[32];
                GetPlayerIp(playerid,ip,sizeof(ip));
                AddBan(ip);
                Kick(playerid);
                return 1;
            }
            else
            {
                new year, month,day;
                getdate(year, month, day);
                new playerip[32];
                GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
                format(string, sizeof(string), "Server Action: %s(IP:%s) was banned by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
                Log("logs/ban.log", string);
                format(string, sizeof(string), "Server Action: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
                SendClientMessageToAllEx(COLOR_LIGHTRED, string);
                PlayerInfo[giveplayerid][pBanned] = 1;
                format(PlayerInfo[giveplayerid][pFlag], 128, "");
                new ip[32];
                GetPlayerIp(giveplayerid,ip,sizeof(ip));
                AddBan(ip);
                Kick(giveplayerid);
                return 1;
            }

        }
    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}

And one more thing, Can someone tell me how to make length of /pm bigger?
pawn Код:
CMD:pm(playerid, params[])
{
    new str[400], str2[400], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
        SendClientMessage(playerid, 0xFF0000FF, "Tip: /pm <id> <message>");
        return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
    if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!");
    else
    {
        GetPlayerName(playerid, Name1, sizeof(Name1));
        GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "{FFCC00}((PM To %s(ID %d): %s))", Name2, id, str2);
        SendClientMessage(playerid, 0xFF0000FF, str);
        format(str, sizeof(str), "{FFCC00}((PM From %s(ID %d): %s))", Name1, playerid, str2);
        SendClientMessage(id, 0xFF0000FF, str);
    }
    return 1;
}
Reply
#2

Quote:
As of SA-MP 0.3x, any action taken directly before Kick() (such as sending a message with SendClientMessage) will not reach the player. A timer must be used to delay the kick.
Read.
Reply
#3

Now What I have to do?, Can you fix those commands?
Reply
#4

Use a timer of 1 sec after SendClientMessage, so it will send the message and then kick the player.

About length of pm the maximum is 128 i think or 144, so if the words are 128+ they won't show.
Reply
#5

pawn Код:
forward OnKickPlayer(playerid);
public OnKickPlayer(playerid)
{
    return Kick(playerid);
}

stock KickWithMessage(playerid, color, const message[])
{
    SendClientMessage(playerid, color, message);
    SetTimerEx("OnKickPlayer", 100, 0, "d", playerid);
    return 1;
}
Use this function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)