Cant kick admins
#1

How to make these commands unusable on admins,can someone add that code to these cmds(So admins cant/kick or ban each other)
PHP код:
 // Kicks a player with a reason
COMMAND:kikaj(playeridparams[])
{
    new 
PlayerToKickReason[128], ReasonMsg[128], Name[24];
    
// Send the command to all admins so they can see it
    
SendAdminText(playerid"/kikaj"params);
    
// Check if the player has logged in
    
if (APlayerData[playerid][LoggedIn] == true)
    {
        
// Check if the player's admin-level is at least 1
        
if (APlayerData[playerid][PlayerLevel] >= 1)
        {
            if (
sscanf(params"us[128]"PlayerToKickReason)) SendClientMessage(playerid0xFF0000AA"Koristenje: \"/kikaj <Igrac> <Razlog>\"");
            else
                if (
IsPlayerConnected(PlayerToKick)) // If the player is a valid playerid (he's connected)
                
{
                    
// Get the name of the player who warned the player
                    
GetPlayerName(playeridNamesizeof(Name));
                    
// Send the warned player a message who kicked him and why he's been kicked
                    
format(ReasonMsg128"Izbacen si sa servera od %s %s"AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
                    
SendClientMessage(PlayerToKick0xFF0000FFReasonMsg);
                    
format(ReasonMsg128"Razlog: %s"Reason);
                    
SendClientMessage(PlayerToKick0xFF0000FFReasonMsg);
                    
// Kick the player
                    
Kick_(PlayerToKick);
                }
                else
                    
SendClientMessage(playerid0xFF0000FF"Upisani igrac nije online na serveru.");
        }
        else
            return 
0;
    }
    else
        return 
0;
    
// Let the server know that this was a valid command
    
return 1;
}
// Bans a player for (days, hours, minutes, seconds)
COMMAND:banaj(playeridparams[])
{
    
// Setup local variables
    
new PlayerToBanDaysHoursReason[128], TotalBanTimeMsg[128], Name[24], AdminName[24];
    
// Send the command to all admins so they can see it
    
SendAdminText(playerid"/banaj"params);
    
// Check if the player has logged in
    
if (APlayerData[playerid][LoggedIn] == true)
    {
        
// Check if the player's admin-level is at least 3
        
if (APlayerData[playerid][PlayerLevel] >= 3)
        {
            if (
sscanf(params"uiis[128]"PlayerToBanDaysHoursReason))
                
SendClientMessage(playerid0xFF0000AA"Koristenje: \"/banaj <Igrac> <Dani> <Sati> <Razlog>\"");
            else
            {
                if (
IsPlayerConnected(PlayerToBan))
                {
                    
// Get the names of the player and the admin who executed the ban
                    
GetPlayerName(playeridAdminNamesizeof(AdminName));
                    
GetPlayerName(PlayerToBanNamesizeof(Name));
                    
// Increase the number of bans
                    
APlayerData[PlayerToBan][Bans]++;
                    
// Calculate the total bantime (when the player can login again)
                    
TotalBanTime = (Days 86400) + (Hours 3600) + gettime();
                    
// Check if this is the player's 5th ban
                    
if (APlayerData[PlayerToBan][Bans] == 5)
                        
APlayerData[PlayerToBan][BanTime] = 2147483640// Make the ban permanent (as high as it can go)
                    
else
                        
APlayerData[PlayerToBan][BanTime] = TotalBanTime// Store this value for the player
                    // Inform the player about his ban
                    // Check if this is the player's 5th ban
                    
if (APlayerData[PlayerToBan][Bans] == 5)
                    {
                        
format(Msg128"Zauvijek si banan sa servera od %s, ovo ti je 5. ban."AdminName);
                        
SendClientMessage(PlayerToBan0x808080FFMsg);
                    }
                    else
                    {
                        
format(Msg128"Banan si sa servera od %s na %i dana i %i sati."AdminNameDaysHours);
                        
SendClientMessage(PlayerToBan0x808080FFMsg);
                        
format(Msg128"Razlog: %s"Reason);
                        
SendClientMessage(PlayerToBan0x808080FFMsg);
                        
format(Msg128"Banan si vec %i puta, peti put je trajno."APlayerData[PlayerToBan][Bans]);
                        
SendClientMessage(PlayerToBan0x808080FFMsg);
                    }
                    
// Kick the player (his data will be saved)
                    
Kick_(PlayerToBan);
                    
// Inform everybody else which player was banned and for how long
                    
format(Msg128"%s %s je banao %s na %i dana i %i sati."AdminLevelName[APlayerData[playerid][PlayerLevel]], AdminNameNameDaysHours);
                    
SendClientMessageToAll(0x808080FFMsg);
                }
            }
        }
        else
            return 
0;
    }
    else
        return 
0;
    return 
1;
}
COMMAND:srusi(playerid,params[])
{
    
SendAdminText(playerid"/srusi"params);
    if (
APlayerData[playerid][LoggedIn] == true && APlayerData[playerid][PlayerLevel] > 9)
    {
        new 
Korisnik;
        if(
sscanf(params"u"Korisnik)) return SendClientMessage(playerid0xFF0000FF"{FF0000}Komanda:{FF0000} {FFFFFF}/Srusi <Nadimak / ID> {FFFFFF}");
        
GameTextForPlayer(Korisnik"~k~~INVALID_KEY~"1005);
        return 
1;
    }
    return 
0;

Reply
#2

use this

pawn Код:
if(APlayerData[PlayerToKick][PlayerLevel] >= 1)
{
    SendClientMessage(playerid, -1, "You are not able to kick admins.");
    return 1;
}
Reply
#3

First of all, why do you have this?
pawn Код:
SendAdminText(playerid, "/kikaj", params);
I am assuming you do this for every command - since you're especially using zcmd simply ise the OnPlayerCommandPerformed callback and put it there.

Secondly, you can use the PlayerLevel variable as you do to check if the player is admin
pawn Код:
if(APlayerData[playerid][PlayerLevel] > APlayerData[Korisink][PlayerLevel]
This checks if the player's admin level is higher than the target.
Reply
#4

You can use this line: if (APlayerData[playerid][PlayerLevel] >= 1)

Only change the "playerid" to "PlayerToKick" and check the player you want kick is admin or not, obviously the code is after this: if (IsPlayerConnected(PlayerToKick))
Reply
#5

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
use this

pawn Код:
if(APlayerData[PlayerToKick][PlayerLevel] >= 1)
{
    SendClientMessage(playerid, -1, "You are not able to kick admins.");
    return 1;
}
I get these errors
Код:
C:\Users\Korisnik\Desktop\Yugoslavia Trucking v.0.3.7\include\PlayerCommands.inc(628) : error 010: invalid function or declaration
C:\Users\Korisnik\Desktop\Yugoslavia Trucking v.0.3.7\include\PlayerCommands.inc(631) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)