AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   How to get admin immunity? (https://forums.alliedmods.net/showthread.php?t=316023)

Hennesy 05-04-2019 08:37

How to get admin immunity?
 
How to get admin immunity into variable?

Powerlord 05-04-2019 17:04

Re: How to get admin immunity?
 
GetAdminImmunityLevel

Having said that, if you want to know whether a user can target another user, CanUserTarget is likely more useful.

eyal282 05-06-2019 10:39

Re: How to get admin immunity?
 
Didn't even put this in a compiler.

Code:


stock int GetClientAdminImmunity(client)
{
        new AdminId:AID = GetUserAdmin(client);
        if(AID == INVALID_ADMIN_ID)
                return 0;
       
        return GetAdminImmunityLevel(AID);
}


Hennesy 05-07-2019 08:58

Immunity of administrators in the menu
 
Hi people!
There is the following code:
PHP Code:

for(int i 1i<=MaxClients; ++i)
{
    if(
ValidPlayer(i))
    {
        
char str_i[3];
        
IntToString(istr_isizeof(str_i));
        
char name[64];
        
GetClientName(inamesizeof(name));
         
        
menu.AddItem(str_inameITEMDRAW_DEFAULT);
    }


en: How can I make so that the list does not add admins with immunity above the admin who called the menu
ru: Как мне сделать так, чтобы в список не добавлялись админы с имунитетом выше того админа который вызвал меню

CrazyHackGUT 05-07-2019 09:21

Re: How to get admin immunity?
 
en: Use helper method for detecting, can your admin target another or not.
ru: Используйте вспомогательный метод для определения, может Ваш админ таргетить другого или нет.

https://sm.alliedmods.net/new-api/clients/CanUserTarget

ThatKidWhoGames 05-07-2019 10:24

Re: How to get admin immunity?
 
Quote:

Originally Posted by Hennesy (Post 2650756)
How can I make so that the list does not add admins with immunity above the admin who called the menu

PHP Code:

stock void CreatePlayerMenu(int clientbool bots=false)
{
    
Menu menu = new Menu(Menu_Handler);
    
menu.SetTitle("Choose a player:");

    
char userid[11], buffer[256];
    for (
int i 1<= MaxClientsi++)
    {
        if (
client != && IsClientInGame(i) && CanUserTarget(clienti) && !(!bots && IsFakeClient(i)))
        {
            
IntToString(GetClientUserId(i), useridsizeof(userid));
            
Format(buffersizeof(buffer), "%N [%s]"iuserid);
            
menu.AddItem(useridbuffer);
        }
    }

    if (!
menu.ItemCount)
    {
        
menu.AddItem("""No players available."ITEMDRAW_DISABLED);
    }

    
menu.Display(client20);
}

public 
int Menu_Handler(Menu menuMenuAction actionint clientint param2)
{
    if (
action == MenuAction_Select)
    {
        
char userid[11];
        
menu.GetItem(param2useridsizeof(userid));
        
int target GetClientOfUserId(StringToInt(userid));
        if (
target)
        {
            
// Do stuff with target
        
} else {
            
// Target is no longer in-game
        
}
    } else if (
action == MenuAction_End) {
        
delete menu;
    }

    return 
0;




All times are GMT -4. The time now is 07:29.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.