SA-MP Forums Archive
hey help me - 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: hey help me (/showthread.php?tid=610778)



hey help me - JuzDoiT - 28.06.2016

tell me how admins cannot attack admins with admin powers? let me show you an admin command
PHP код:
COMMAND:hog(playerid, params[])
{
    new 
TargetID, string[256];
    if (
PlayerInfo[playerid][pAdminlevel] > 0)
    {
    if(
sscanf(params, "u", TargetID))
    {
    
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /hog (Name/ID)");
    return 
1;
    }
    if(!
IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID)
    {
    
SendClientMessage(playerid, COLOR_ERROR, "That Player Is Not Connected.");
    return 
1;
    }
    if(
IsPlayerNPC(TargetID))
    {
    
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Kill a BOT With Hand Of God.");
    return 
1;
    }
    if(
PlayerInfo[TargetID][pSpawned] == 0)
    {
    
SendClientMessage(playerid,COLOR_ERROR,"Player Is Not Spawned");
    return 
1;
    }
    
PlayerInfo[TargetID][pCustomDeath] = WEAPON_GOD;
    
SetPlayerHealth(TargetID, 0);
    
SetPlayerScore(playerid,GetPlayerScore(playerid) - 1);
    
SendDeathMessage(INVALID_PLAYER_ID, TargetID, 40);
    
format(string, sizeof(string), "%s (%i) Died By The Hand Of God.",PlayerInfo[TargetID][pName],TargetID);
    
SendClientMessageToAll(COLOR_DEATH, string);
    
SendGameText(TargetID,"~r~Struck Down By The Hand Of God");
    new 
Float:x, Float:y, Float:z;
    
GetPlayerPos(TargetID, x, y, z);
    
PlayerPlaySound(TargetID, 1159, x, y, z);
    }
    else
    {
    
SendClientMessage(playerid, COLOR_ERROR, "Unknown Command! Type /cmds For Available Commands.");
    }
    return 
1;
} 



Re: hey help me - Sjn - 28.06.2016

With a simple logic; if targetid has an admin level, stop them from using the command.

Код:
if (PlayerInfo[TargetID][pAdminLevel] != 0) 
      return SendClientMessage(playerid, -1, "You cannot use this command on an admin.");