rebeccs 发表于 2009-2-11 17:59:00

源码求助

/*
Weapons Mod 2.0
Brought to you by TooLz

Special thanks to DoDPlugins.net for providing the wonderful community!
*/

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <dodx>
#include <fakemeta>

#define MAXWEAPON 23
new got_weapon, Weapon_Name
enum WeaponData {
        WMOD_Weapon,
        WMOD_SayCmd,
        WMOD_Disabled
}
new WEAPON = {
        {DODW_KAR,"k98","amx_disable_k98"},                                        //0
        {DODW_GARAND,"m1","amx_disable_m1"},                                //1
        {DODW_K43,"k43","amx_disablek43"},                                        //2
        {DODW_M1_CARBINE,"kabin","amx_disable_kabin"},                                //3
        {DODW_MP40,"mp40","amx_disable_mp40"},                                        //4
        {DODW_THOMPSON,"tms","amx_disable_tms"},                        //5
        {DODW_STG44,"stg44","amx_disable_stg44"},                                //6
        {DODW_GREASEGUN,"greasegun","amx_disable_greasegun"},                        //7
        {DODW_SCOPED_KAR,"scopedk98","amx_disable_scopedk98"},                        //8
        {DODW_SPRINGFIELD,"springfield","amx_disable_springfield"},                //9
        {DODW_MG34,"mg34","amx_disable_mg34"},                                        //10
        {DODW_BAR,"bar","amx_disable_bar"},                                        //11
        {DODW_MG42,"mg42","amx_disable_mg42"},                                        //12
        {DODW_30_CAL,"30cal","amx_disable_30cal"},                                //13
        {DODW_PANZERSCHRECK,"panzerschreck","amx_disable_panzerschreck"},        //14
        {DODW_BAZOOKA,"bazooka","amx_disable_bazooka"},                                //15
        {DODW_ENFIELD,"enfield","amx_disable_enfield"},                                //16
        {DODW_STEN,"sten","amx_disable_sten"},                                        //17
        {DODW_BREN,"bren","amx_disable_bren"},                                        //18
        {DODW_PIAT,"piat","amx_disable_piat"},                                        //19
        {DODW_FG42,"fg42","amx_disable_fg42"},                                        //20
        {DODW_SCOPED_FG42,"scopedfg42","amx_disable_scopedfg42"},                //21
        {DODW_SCOPED_ENFIELD,"scopedenfield","amx_disable_scopedenfield"}        //22
}
public plugin_init()
{
        register_plugin("Weapons Mod 2.0","2.0","TooLz")
        register_event("ResetHUD","respawn","be")
        register_clcmd("say","cmdSay",0,"- Checks which weapon was said")
        register_cvar("amx_weapon_changes", "2")
        register_cvar("amx_disable_scopedfg42","0")
        register_cvar("amx_disable_scopedenfield","0")
        register_cvar("amx_disable_k98", "0")
        register_cvar("amx_disable_garand", "0")
        register_cvar("amx_disable_carbine", "0")
        register_cvar("amx_disable_k43", "0")
        register_cvar("amx_disable_mp40", "0")
        register_cvar("amx_disable_thompson", "0")
        register_cvar("amx_disable_stg44", "0")
        register_cvar("amx_disable_bar", "0")
        register_cvar("amx_disable_fg42", "0")
        register_cvar("amx_disable_greasegun", "0")
        register_cvar("amx_disable_bazooka", "0")
        register_cvar("amx_disable_enfield", "0")
        register_cvar("amx_disable_sten", "0")
        register_cvar("amx_disable_mg42", "0")
        register_cvar("amx_disable_mg34", "0")
        register_cvar("amx_disable_30cal", "0")
        register_cvar("amx_disable_springfield", "0")
        register_cvar("amx_disable_scopedk98", "0")
        register_cvar("amx_disable_bren", "0")
        register_cvar("amx_disable_panzerschreck", "0")
        register_cvar("amx_disable_piat", "0")
}
public respawn(id){
        got_weapon = 0
}
stock detect_weapon_id(id) {
// Big thanks to Wilson for this stock!
        new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn;
        new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);
        xmod_get_wpnlogname(m_iWpn, m_szWpn, 31);
        format(m_szWpn, 31, "weapon_%s", m_szWpn);
        if(equal(m_szWpn, "weapon_scoped_enfield")) m_szWpn = "weapon_enfield";
        if(equal(m_szWpn, "weapon_scoped_fg42")) m_szWpn = "weapon_fg42";
        new Float:m_flOrigin;
        pev(id, pev_origin, m_flOrigin);
        while((m_iCurEnt = engfunc(EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0)) != 0) {
                new m_szClassname;
                pev(m_iCurEnt, pev_classname, m_szClassname, 31);
                if(equal(m_szClassname, m_szWpn))
                        m_iWpnEnt = m_iCurEnt;
        }
        return m_iWpnEnt;
}
stock cmdWeapon(WeaponID, WeaponName) {
        xmod_get_wpnlogname(WeaponID, WeaponName, 31);
        format(WeaponName, 31, "weapon_%s", WeaponName);
}
stock dod_get_scoped(id) {
    new m_iCurEnt = -1, m_iWpnEnt = 0, m_szWpn;
    new clip, ammo, m_iWpn = get_user_weapon(id,clip,ammo);
    new is_scoped
    xmod_get_wpnlogname(m_iWpn, m_szWpn, 31);
    format(m_szWpn, 31, "weapon_%s", m_szWpn);
    if(equal(m_szWpn, "weapon_scoped_enfield")) m_szWpn = "weapon_enfield";
    if(equal(m_szWpn, "weapon_scoped_fg42")) m_szWpn = "weapon_fg42";
    new Float:m_flOrigin;
    pev(id, pev_origin, m_flOrigin);
    while((m_iCurEnt = engfunc(EngFunc_FindEntityInSphere, m_iCurEnt, m_flOrigin, Float:1.0)) != 0) {
      new m_szClassname;
      pev(m_iCurEnt, pev_classname, m_szClassname, 31);
      if(equal(m_szClassname, m_szWpn))
            m_iWpnEnt = m_iCurEnt;
    }
    is_scoped = get_pdata_int(m_iWpnEnt,115,4);
    return is_scoped;
}
public cmdMakeScoped(id){
        new is_scoped = dod_get_scoped(id)
        while(is_scoped != 1){
                is_scoped = dod_get_scoped(id)
                set_pdata_int(detect_weapon_id(id),115,1,4)
        }
        client_cmd(id,"slot2;wait;slot3")
}
public cmdGiveWeapon(id){
        if (!equali(Weapon_Name,"weapon_scoped_fg42") && !equali(Weapon_Name, "weapon_scoped_enfield")){
                give_item(id,Weapon_Name)
        }
        if(equali(Weapon_Name,"weapon_scoped_fg42")){
                give_item(id,"weapon_fg42")
                set_task(0.2,"cmdMakeScoped",id)
        }
        if(equali(Weapon_Name,"weapon_scoped_enfield")){
                give_item(id,"weapon_enfield")
                set_task(0.2,"cmdMakeScoped",id)
        }
        got_weapon++
}
public cmdSay(id) {
        new said
        read_argv(1,said,31)
        if(said != '/')
                return PLUGIN_CONTINUE;
        for(new i = 0 ; i < MAXWEAPON ; i++) {
                if(equali(said,WEAPON)) {
                        if(get_cvar_num(WEAPON) != 0){
                                client_print(id,print_chat, " This weapon is disabled on this server.")
                                return PLUGIN_HANDLED
                        }
                        if (got_weapon == get_cvar_num("amx_weapon_changes")){
                                client_print(id,print_chat, " You've used up your gun changes, you must wait until respawn to change guns again.")
                                return PLUGIN_HANDLED
                        }
                        cmdWeapon(WEAPON,Weapon_Name)
                        client_cmd(id, "drop")
                        set_task(0.3,"cmdGiveWeapon", id)
                        break;
                }
        }
        return PLUGIN_HANDLED
}这这源码里面怎么才能才能加入users.ini权限 就是说 怎么才能让users.ini里面得人员才能使用这个权限?

Leya 发表于 2009-2-11 22:45:40

我也不太懂,不过你可以借鉴下 admincmd.sma 这个有权限设置的

joysin 发表于 2009-3-5 10:43:18

可能是权限问题吧

=tank= 发表于 2009-10-14 16:17:23

我也在搞这个自由要枪的权限问题~ 一直没有解决。研究了这个源码貌似想加权限还有其他地方需要改动的。有高手指点一下吗????
页: [1]
查看完整版本: 源码求助