AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need Help with Disarm Plugin (https://forums.alliedmods.net/showthread.php?t=188746)

Sh0n3 06-29-2012 23:49

Need Help with Disarm Plugin
 
Hey guys, i have disarm menu plugin on my server but the problem is that admin can disarm other admins :shock: Can anyone help me with the code so admins with immunity can't be choosed in the menu? Thanks in advance :)

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

public plugin_init()
{
    
register_plugin("Disarm Menu""v2""InsaNe")
    
register_clcmd("say /disarm""Disarm")
    
register_clcmd("say_team /disarm""Disarm")
}
public 
Disarm(id)
{
    new 
menu menu_create("\rDisarm Menu:""menu_handler");
    
    new 
players[32], pnumtempid;
    
    new 
szName[32], szTempid[10];
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
        
get_user_name(tempidszNamecharsmax(szName));
        
num_to_str(tempidszTempidcharsmax(szTempid));
        
        
menu_additem(menuszNameszTempid0);
        
    }
    
    if(
get_user_flags(id) & ADMIN_BAN)
        
menu_display(idmenu0);
    
    return 
PLUGIN_HANDLED_MAIN
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    
    new 
tempid str_to_num(data);
    
    if(
is_user_alive(tempid))
        
{
    
strip_user_weapons(tempid)
    
give_item(tempid,"weapon_knife")
    
    
set_hudmessage(25500, -1.00.8622.07.0)
    
show_hudmessage(tempid"Admin te je disarm-ovao!")
}
    return 
PLUGIN_HANDLED;



EpicMonkey 06-30-2012 01:47

Re: Need Help with Disarm Plugin
 
http://www.amxmodx.org/funcwiki.php?...dmin&go=search

check if tempid is an admin

Neeeeeeeeeel.- 06-30-2012 02:00

Re: Need Help with Disarm Plugin
 
Why I think that you are trying to get the code to apply on what you asked?

Sh0n3 06-30-2012 02:13

Re: Need Help with Disarm Plugin
 
Quote:

Originally Posted by EpicMonkey (Post 1739486)

if( is_user_admin(tempid))

Where to put the damn thing? :oops:

Artifact 06-30-2012 03:26

Re: Need Help with Disarm Plugin
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

public plugin_init()
{
    
register_plugin("Disarm Menu""v2""InsaNe")
    
register_clcmd("say /disarm""Disarm")
    
register_clcmd("say_team /disarm""Disarm")
}
public 
Disarm(id)
{
    new 
menu menu_create("\rDisarm Menu:""menu_handler");
    
    new 
players[32], pnumtempid;
    
    new 
szName[32], szTempid[10];
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];
        
        
get_user_name(tempidszNamecharsmax(szName));
        
num_to_str(tempidszTempidcharsmax(szTempid));
        
        
menu_additem(menuszNameszTempid0);
        
    }
    
    if(
get_user_flags(id) & ADMIN_BAN)
        
menu_display(idmenu0);
    
    return 
PLUGIN_HANDLED_MAIN
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    
    new 
tempid str_to_num(data);
    
    if(
is_user_alive(tempid) && !is_user_admin(tempid))
        
    {
        
strip_user_weapons(tempid)
        
give_item(tempid,"weapon_knife")
    
        
set_hudmessage(25500, -1.00.8622.07.0)
        
show_hudmessage(tempid"Admin te je disarm-ovao!")
    }
    return 
PLUGIN_HANDLED;



Sh0n3 06-30-2012 04:19

Re: Need Help with Disarm Plugin
 
@Artifact It works, it does not disarm an admin, but i can still click on admin's nick in the menu, I wan't to be just like in kickmenu or banmenu :cry:

Artifact 06-30-2012 05:44

Re: Need Help with Disarm Plugin
 
PHP Code:


public actionBanMenu(idkey)
{
    switch (
key)
    {
        case 
7:
        {            
            ++
g_menuOption[id]
            
g_menuOption[id] %= ArraySize(g_bantimes);

            
g_menuSettings[id] = ArrayGetCell(g_bantimesg_menuOption[id]);

            
displayBanMenu(idg_menuPosition[id])
        }
        case 
8displayBanMenu(id, ++g_menuPosition[id])
        case 
9displayBanMenu(id, --g_menuPosition[id])
        default:
        {
            new 
player g_menuPlayers[id][g_menuPosition[id] * key]
            new 
name[32], name2[32], authid[32], authid2[32]
        
            
get_user_name(playername231)
            
get_user_authid(idauthid31)
            
get_user_authid(playerauthid231)
            
get_user_name(idname31)
            
            new 
userid2 get_user_userid(player)

            
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")"nameget_user_userid(id), authidname2userid2authid2g_menuSettings[id])

            if (
g_menuSettings[id]==0)
            {
                new 
maxpl get_maxplayers();
                for (new 
1<= maxpli++)
                {
                    
show_activity_id(iidname"%L %s %L"i"BAN"name2i"PERM");
                }
            }
            else
            {
                new 
tempTime[32];
                
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
                new 
maxpl get_maxplayers();
                for (new 
1<= maxpli++)
                {
                    
show_activity_id(iidname"%L %s %L"i"BAN"name2i"FOR_MIN"tempTime);
                }
            }
            if (
equal("4294967295"authid2)
                || 
equal("HLTV"authid2)
                || 
equal("STEAM_ID_LAN"authid2)
                || 
equali("VALVE_ID_LAN"authid2))
            {
                new 
ipa[32]
                
get_user_ip(playeripa311)
                
                
server_cmd("addip %d %s;writeip"g_menuSettings[id], ipa)
            }
            else
            {
                
server_cmd("banid %d #%d kick;writeid"g_menuSettings[id], userid2)
            }

            
server_exec()

            
displayBanMenu(idg_menuPosition[id])
        }
    }
    
    return 
PLUGIN_HANDLED
}

displayBanMenu(idpos)
{
    if (
pos 0)
        return

    
get_players(g_menuPlayers[id], g_menuPlayersNum[id])

    new 
menuBody[512]
    new 
0
    
new i
    
new name[32]
    new 
start pos 7

    
if (start >= g_menuPlayersNum[id])
        
start pos g_menuPosition[id] = 0

    
new len format(menuBody511g_coloredMenus "\y%L\R%d/%d^n\w^n" "%L %d/%d^n^n"id"BAN_MENU"pos 1, (g_menuPlayersNum[id] / + ((g_menuPlayersNum[id] % 7) ? 0)))
    new 
end start 7
    
new keys MENU_KEY_0|MENU_KEY_8

    
if (end g_menuPlayersNum[id])
        
end g_menuPlayersNum[id]

    for (new 
startend; ++a)
    {
        
g_menuPlayers[id][a]
        
get_user_name(iname31)

        if (
is_user_bot(i) || (access(iADMIN_IMMUNITY) && != id))
        {
            ++
b
            
            
if (g_coloredMenus)
                
len += format(menuBody[len], 511-len"\d%d. %s^n\w"bname)
            else
                
len += format(menuBody[len], 511-len"#. %s^n"name)
        } else {
            
keys |= (1<<b)
                
            if (
is_user_admin(i))
                
len += format(menuBody[len], 511-leng_coloredMenus "%d. %s \r*^n\w" "%d. %s *^n", ++bname)
            else
                
len += format(menuBody[len], 511-len"%d. %s^n", ++bname)
        }
    }

    if (
g_menuSettings[id])
        
len += format(menuBody[len], 511-len"^n8. %L^n"id"BAN_FOR_MIN"g_menuSettings[id])
    else
        
len += format(menuBody[len], 511-len"^n8. %L^n"id"BAN_PERM")

    if (
end != g_menuPlayersNum[id])
    {
        
format(menuBody[len], 511-len"^n9. %L...^n0. %L"id"MORE"idpos "BACK" "EXIT")
        
keys |= MENU_KEY_9
    
}
    else
        
format(menuBody[len], 511-len"^n0. %L"idpos "BACK" "EXIT")

    
show_menu(idkeysmenuBody, -1"Ban Menu")
}

public 
cmdBanMenu(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED

    g_menuOption
[id] = 0
    
    
if (ArraySize(g_bantimes) > 0)
    {
        
g_menuSettings[id] = ArrayGetCell(g_bantimesg_menuOption[id]);
    }
    else
    {
        
g_menuSettings[id] = 0
    
}
    
displayBanMenu(idg_menuPosition[id] = 0)

    return 
PLUGIN_HANDLED



Sh0n3 06-30-2012 13:17

Re: Need Help with Disarm Plugin
 
Mate if i needed a banmenu code i would look at admincmd.sma The thing is i don't understand too much about AMXX scripting. Could you just add a function to my disarm plugin so admins can't be choosed in the menu? Thanks in advance :mrgreen:

wickedd 06-30-2012 15:51

Re: Need Help with Disarm Plugin
 
Quote:

Originally Posted by Sh0n3 (Post 1739798)
Could you just add a function to my disarm plugin so admins can't be choosed in the menu? Thanks in advance :mrgreen:

Do it yourself.

Sh0n3 06-30-2012 16:22

Re: Need Help with Disarm Plugin
 
Quote:

Originally Posted by wickedd (Post 1739925)
Do it yourself.

If i knew how i would not made this thread and asked for help. Go troll somewhere else post hunter ;)


All times are GMT -4. The time now is 15:20.

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