Raised This Month: $ Target: $400
 0% 

Only admin can use plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gr33tz
Member
Join Date: Apr 2008
Old 08-05-2008 , 13:37   Only admin can use plugin
Reply With Quote #1

Hi i have one plugin, i want to use can only admins (prefer with flag "T" admin_level_h"

Is it enough to replace

is_user_alive
to is_user_admin?

plugin bio_antiblock
Code:
#include <amxmodx>
#include <fakemeta>
#tryinclude <biohazard>

#if !defined _biohazard_included
        #assert Biohazard functions file required!
#endif

enum CsTeams
{
    CS_TEAM_UNASSIGNED    = 0,
    CS_TEAM_T         = 1,
    CS_TEAM_CT         = 2,
    CS_TEAM_SPECTATOR     = 3
}

#define OFFSET_TEAM 114
#define cs_get_user_team(%1) CsTeams:get_pdata_int(%1, OFFSET_TEAM)

new cvar_antiblock, Float:g_lasttimetouched[33] // lol
public plugin_init()
{
    register_plugin("anti block", "0.2", "cheap_suit")
    is_biomod_active() ? plugin_init2() : pause("ad")
}

public plugin_init2()
{
    register_forward(FM_Touch, "fwd_touch")
    register_forward(FM_PlayerPreThink, "fwd_playerprethink")
    cvar_antiblock = register_cvar("bh_antiblock", "1")
}

public fwd_playerprethink(id)
{
    if(!is_user_alive(id))
        return FMRES_IGNORED
    
    static solid; solid = pev(id, pev_solid)
    if(solid == SOLID_NOT && (get_gametime() - g_lasttimetouched[id]) > 0.34)
        set_pev(id, pev_solid, SOLID_SLIDEBOX)
    
    return FMRES_IGNORED
}

public fwd_touch(blocker, id)
{
    if(!is_user_alive(blocker) || !is_user_alive(id) || !get_pcvar_num(cvar_antiblock))
        return FMRES_IGNORED
    
    static button[2]
    button[0] = pev(id, pev_button), button[1] = pev(blocker, pev_button)
    
    if(button[0] & IN_USE || button[1] & IN_USE)
    {
        static CsTeams:team[2]
        team[0] = cs_get_user_team(id), team[1] = cs_get_user_team(blocker)
    
        if(team[0] != team[1])
            return FMRES_IGNORED
        
        set_pev(blocker, pev_solid, SOLID_NOT), set_pev(id, pev_solid, SOLID_NOT)
        
        static Float:gametime; gametime = get_gametime()
        g_lasttimetouched[id] = gametime, g_lasttimetouched[blocker] = gametime
    }
    return FMRES_IGNORED
}

Last edited by Gr33tz; 08-06-2008 at 07:02.
Gr33tz is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 08-05-2008 , 17:29   Re: Only admin can use plugin
Reply With Quote #2

Fix your tags please /code] is fail and nobody wants to read this crap.
Styles is offline
Send a message via AIM to Styles
Gr33tz
Member
Join Date: Apr 2008
Old 08-06-2008 , 07:02   Re: Only admin can use plugin
Reply With Quote #3

fixed, anyone?
Gr33tz is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 08-06-2008 , 08:31   Re: Only admin can use plugin
Reply With Quote #4

try this:

replace:
PHP Code:
if(!is_user_alive(blocker) || !is_user_alive(id) || !get_pcvar_num(cvar_antiblock)) 
to

PHP Code:
if(!is_user_alive(blocker) || !is_user_alive(id) || !is_user_admin(id) || !get_pcvar_num(cvar_antiblock)) 
xPaw is offline
Gr33tz
Member
Join Date: Apr 2008
Old 08-06-2008 , 12:21   Re: Only admin can use plugin
Reply With Quote #5

@xPaw didn't working

Code:
#include <amxmodx>
#include <fakemeta>
#tryinclude <biohazard>

#if !defined _biohazard_included
        #assert Biohazard functions file required!
#endif

enum CsTeams
{
    CS_TEAM_UNASSIGNED    = 0,
    CS_TEAM_T         = 1,
    CS_TEAM_CT         = 2,
    CS_TEAM_SPECTATOR     = 3
}

#define OFFSET_TEAM 114
#define cs_get_user_team(%1) CsTeams:get_pdata_int(%1, OFFSET_TEAM)

new cvar_antiblock, Float:g_lasttimetouched[33] // lol
public plugin_init()
{
    register_plugin("anti block", "0.2", "cheap_suit")
    is_biomod_active() ? plugin_init2() : pause("ad")
}

public plugin_init2()
{
    register_forward(FM_Touch, "fwd_touch")
    register_forward(FM_PlayerPreThink, "fwd_playerprethink")
    cvar_antiblock = register_cvar("bh_antiblock", "1")
}

public fwd_playerprethink(id)
{
    if(!is_user_alive(id))
        return FMRES_IGNORED
    
    static solid; solid = pev(id, pev_solid)
    if(solid == SOLID_NOT && (get_gametime() - g_lasttimetouched[id]) > 0.34)
        set_pev(id, pev_solid, SOLID_SLIDEBOX)
    
    return FMRES_IGNORED
}

public fwd_touch(blocker, id)
{
    new flags = get_user_flags(id, 0);
    if(!(flags & ADMIN_LEVEL_H))
    if(!is_user_alive(blocker) || !get_pcvar_num(cvar_antiblock))
        return FMRES_IGNORED
    
    static button[2]
    button[0] = pev(id, pev_button), button[1] = pev(blocker, pev_button)
    
    if(button[0] & IN_USE || button[1] & IN_USE)
    {
        static CsTeams:team[2]
        team[0] = cs_get_user_team(id), team[1] = cs_get_user_team(blocker)
    
        if(team[0] != team[1])
            return FMRES_IGNORED
        
        set_pev(blocker, pev_solid, SOLID_NOT), set_pev(id, pev_solid, SOLID_NOT)
        
        static Float:gametime; gametime = get_gametime()
        g_lasttimetouched[id] = gametime, g_lasttimetouched[blocker] = gametime
    }
    return FMRES_IGNORED
}
good?
Gr33tz is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-06-2008 , 12:36   Re: Only admin can use plugin
Reply With Quote #6

PHP Code:
if(!is_user_alive(blocker) || !get_pcvar_num(cvar_antiblock)) 
to

PHP Code:
if(!is_user_alive(blocker) || !get_user_flags(id)&ADMIN_LEVEL_H || !get_pcvar_num(cvar_antiblock)) 
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Gr33tz
Member
Join Date: Apr 2008
Old 08-06-2008 , 13:42   Re: Only admin can use plugin
Reply With Quote #7

Again didn't working
Gr33tz is offline
Gr33tz
Member
Join Date: Apr 2008
Old 08-07-2008 , 04:55   Re: Only admin can use plugin
Reply With Quote #8

buuuuuuuuump
Gr33tz is offline
zwfgdlc
Senior Member
Join Date: May 2006
Old 08-07-2008 , 07:13   Re: Only admin can use plugin
Reply With Quote #9

Code:
public fwd_touch(blocker, id) {     new flags = get_user_flags(id, 0);     if(!(flags & ADMIN_LEVEL_H))     if(!is_user_alive(blocker) || !get_pcvar_num(cvar_antiblock))         return FMRES_IGNORED         static button[2]     button[0] = pev(id, pev_button), button[1] = pev(blocker, pev_button)         if(button[0] & IN_USE || button[1] & IN_USE)     {         static CsTeams:team[2]         team[0] = cs_get_user_team(id), team[1] = cs_get_user_team(blocker)             if(team[0] != team[1])             return FMRES_IGNORED                 set_pev(blocker, pev_solid, SOLID_NOT), set_pev(id, pev_solid, SOLID_NOT)                 static Float:gametime; gametime = get_gametime()         g_lasttimetouched[id] = gametime, g_lasttimetouched[blocker] = gametime     }     return FMRES_IGNORED }
change to
Code:
public fwd_touch(blocker, id) {     if(!(get_user_flags(id) & ADMIN_LEVEL_H)) return FMRES_IGNORED;     if(!is_user_alive(blocker) || !get_pcvar_num(cvar_antiblock))         return FMRES_IGNORED         static button[2]     button[0] = pev(id, pev_button), button[1] = pev(blocker, pev_button)         if(button[0] & IN_USE || button[1] & IN_USE)     {         static CsTeams:team[2]         team[0] = cs_get_user_team(id), team[1] = cs_get_user_team(blocker)             if(team[0] != team[1])             return FMRES_IGNORED                 set_pev(blocker, pev_solid, SOLID_NOT), set_pev(id, pev_solid, SOLID_NOT)                 static Float:gametime; gametime = get_gametime()         g_lasttimetouched[id] = gametime, g_lasttimetouched[blocker] = gametime     }     return FMRES_IGNORED }
zwfgdlc is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:34.


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