Raised This Month: $ Target: $400
 0% 

[HELP] Door Options


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 12-27-2012 , 04:56   Re: [HELP] Door Options
Reply With Quote #7

Quote:
Originally Posted by ironskillz1 View Post
Here you go

only admins and ct can write /open

Code:
#include <amxmodx>
#include <fakemeta> 
#include <cstrike> 

#define PLUGIN "Open Cells"
#define VERSION "0.0.1"
#define AUTHOR "Freestyle"

#define PREFIX "Jailbreak"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_clcmd("say /open", "open_cells")
}

public open_cells(id)
{
    if(cs_get_user_team(id) == CS_TEAM_CT)
    {
        new szGuardName[32]
        get_user_name(id, szGuardName, charsmax(szGuardName))
        
        set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -1.0, 0, 6.0, 12.0)
        show_hudmessage(0, "[%s]^n= Guard %s open the cells =", PREFIX, szGuardName)
        
        while(engfunc(EngFunc_FindEntityByString, -1, "classname", "func_door"))
        { 
            dllfunc(DLLFunc_Use, -1, 0)
        }
    }
    else if( get_user_flags(id) & ADMIN_BAN )
    {
        new szGuardName[32]
        get_user_name(id, szGuardName, charsmax(szGuardName))
        
        set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), -1.0, -1.0, 0, 6.0, 12.0)
        show_hudmessage(0, "[%s]^n= Admin %s open the cells =", PREFIX, szGuardName)
        
        while(engfunc(EngFunc_FindEntityByString, -1, "classname", "func_door"))
        { 
            dllfunc(DLLFunc_Use, -1, 0)
        }
    }
} 
Better code:
PHP Code:
#include <amxmodx>
#include <fakemeta> 

#define PREFIX "Jailbreak"

enum _:Teams{
    
FM_TEAM_UNASSIGNED,
    
FM_TEAM_T,
    
FM_TEAM_CT,
    
FM_TEAM_SPECTATOR
};

public 
plugin_init(){
    
register_plugin("Open Cells","0.0.1","Freestyle");
    
register_clcmd("say /open","open_cells");
}

public 
open_cells(id){
    if(
is_user_can(id))
    {
        new 
szGuardName[32];
        
get_user_name(id,szGuardName,charsmax(szGuardName));
        
        
set_hudmessage(random_num(0,255),random_num(0,255),random_num(0,255),-1.0,-1.0,0,6.0,12.0);
        
show_hudmessage(0,"[%s]^n= %s %s open the cells =",PREFIX,is_user_admin(id) ? "Admin":"Guard",szGuardName);
        
        while(
engfunc(EngFunc_FindEntityByString, -1"classname""func_door"))
            
dllfunc(DLLFunc_Use, -10);
    }


stock bool:is_user_can(index){
    if(
is_user_admin(index))
        return 
true;

    if(!
is_user_alive(index) || fm_get_user_team(index) != FM_TEAM_CT)
    {
        
client_print(index,print_chat,"[AMXX] You must be guard and alive!");
        return 
false;
    }

    return 
true;
}

stock bool:is_user_admin(index)
    return 
get_user_flags(index) & ADMIN_ADMIN true:false;

stock fm_get_user_team(index)
    return 
get_pdata_int(index,114); 
__________________
simanovich is offline
 



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 13:44.


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