SA-MP Forums Archive
NPC - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: NPC (/showthread.php?tid=369581)



NPC - P<3TS - 17.08.2012

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?


Re: NPC - MicroD - 17.08.2012

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’)>.");



Re: NPC - P<3TS - 18.08.2012

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");}



Re: NPC - P<3TS - 18.08.2012

help me to add that..


Re: NPC - Kitten - 18.08.2012

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

Do it yourself it's pretty simple.


Re: NPC - P<3TS - 18.08.2012

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


Re: NPC - Jstylezzz - 18.08.2012

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


Re: NPC - JaKe Elite - 18.08.2012

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

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