#1

Hello!
In my server there are 4 npcs but by mistake admins are kicking or banning them from the server.
Is there any way to prevent it?
Reply
#2

Add check in your /kick or /ban function something like this:

Код:
if (IsPlayerNPC(id-of-player-you-want-to-kick-or-ban))
    SendClientMessage(playerid, -1, "Sir you can not ban bot (>‘o’)>.");
Reply
#3

In my server there are 4 bots, ID 0, 1, 2 and 3
and i need to add that protection in this command

pawn Код:
CMD:kick(playerid,params[]) {
    if(PlayerInfo[playerid][LoggedIn] == 1) {
        if(PlayerInfo[playerid][Level] >= 4) {
            new tmp[128], tmp2[128], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
            if(isnull(params)) return SendMessageToPlayer(playerid,COLOR_RED, "USAGE: /kick [playerid] [reason]");
            new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
            player1 = strval(tmp);
            new playname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playname, sizeof(playname));
            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
                GetPlayerName(player1, playername, sizeof(playername));     GetPlayerName(playerid, adminname, sizeof(adminname));
                CMDMessageToAdmins(playerid,"KICK");
                if(isnull(tmp2)) {
                    format(string,sizeof(string),"%s has been kicked by Administrator %s [no reason given] ",playername,adminname); SendMessageToAll(COLOR_BRIGHTRED,string);
                    SaveToFile("KickLog",string); print(string);
                    return Kick(player1);
                } else {
                    format(string,sizeof(string),"%s has been kicked by Administrator %s [reason: %s] ",playername,adminname,params[2]); SendMessageToAll(COLOR_BRIGHTRED,string);
                    SaveToFile("KickLog",string); print(string);
                    return Kick(player1);}
            } else return SendMessageToPlayer(playerid,COLOR_RED, "Player is not connected or is yourself or is the highest level admin");
        } else return SendMessageToPlayer(playerid, -1, "Error");
    } else return SendMessageToPlayer(playerid,COLOR_RED,"ERROR: You must be logged in to use this commands");}
Reply
#4

help me to add that..
Reply
#5

https://sampwiki.blast.hk/wiki/IsPlayerNPC

Do it yourself it's pretty simple.
Reply
#6

But i dont know where i should put that code in the kick cmd.
Please help
Reply
#7

Here you go:
pawn Код:
CMD:kick(playerid,params[]) {
    if(PlayerInfo[playerid][LoggedIn] == 1) {
        if(PlayerInfo[playerid][Level] >= 4) {
            new tmp[128], tmp2[128], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
            if(isnull(params)) return SendMessageToPlayer(playerid,COLOR_RED, "USAGE: /kick [playerid] [reason]");
            new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
            player1 = strval(tmp);
            if (IsPlayerNPC(player1)) return SendClientMessage(playerid, -1, "Sir you can not ban bot (>‘o’)>.");
            new playname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playname, sizeof(playname));
            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
                GetPlayerName(player1, playername, sizeof(playername));     GetPlayerName(playerid, adminname, sizeof(adminname));
                CMDMessageToAdmins(playerid,"KICK");
                if(isnull(tmp2)) {
                    format(string,sizeof(string),"%s has been kicked by Administrator %s [no reason given] ",playername,adminname); SendMessageToAll(COLOR_BRIGHTRED,string);
                    SaveToFile("KickLog",string); print(string);
                    return Kick(player1);
                } else {
                    format(string,sizeof(string),"%s has been kicked by Administrator %s [reason: %s] ",playername,adminname,params[2]); SendMessageToAll(COLOR_BRIGHTRED,string);
                    SaveToFile("KickLog",string); print(string);
                    return Kick(player1);}
            } else return SendMessageToPlayer(playerid,COLOR_RED, "Player is not connected or is yourself or is the highest level admin");
        } else return SendMessageToPlayer(playerid, -1, "Error");
    } else return SendMessageToPlayer(playerid,COLOR_RED,"ERROR: You must be logged in to use this commands");}
Your code is very messy... Try to indent it the right way, and work a little more, "Indenting" in the future..
makes it alot easier to add easy/small things
Reply
#8

You can add this in the code /kick or /ban

pawn Код:
if(IsPlayerNPC(YourGlobalVariableHere)) return //message here
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)