AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [Help] ZP Admin Access Weapon (https://forums.alliedmods.net/showthread.php?t=323960)

elmedin 05-02-2020 12:00

[Help] ZP Admin Access Weapon
 
Hey im having a problem with a plugin, i give the weapon admin access only, when i try to buy it the menu appears again which is good, but when i try to get another weapon the moment i press a button the menu just fades away.

CORE Weapon Menu:

Registred native on main weapon core plugin
PHP Code:

register_native("zg_menu""zg_Test"1

PHP Code:

public zg_Test(id)
{
    
Show_MainEquipMenu(id)
    
Reset_PlayerWeapon(id1)


PHP Code:

public Show_MainEquipMenu(id)
{
    if(
zp_get_user_zombie(id) || zp_get_user_survivor(id) || zp_get_user_sniper(id) || zp_get_user_nemesis(id) || zp_get_user_assassin(id))
        return
    if(
Get_BitVar(g_GotWeaponid))
        return
    

    static 
LangText[64]; formatex(LangTextsizeof(LangText), "%L"GAME_LANG"WPN_MENU_NAME")
    static 
MenuMenu menu_create(LangText"MenuHandle_MainEquip")
    
    static 
WeaponName[32]
    
    if(
g_PreWeapon[id][WPN_PRIMARY] != -1)
    {
        
ArrayGetString(ArWeaponNameg_PreWeapon[id][WPN_PRIMARY], WeaponNamesizeof(WeaponName))
        
formatex(LangTextsizeof(LangText), "%L [\y%s\w]"GAME_LANG"WPN_MENU_PRIMARY"WeaponName)
    } else {
        
formatex(LangTextsizeof(LangText), "%L \d[ ]\w"GAME_LANG"WPN_MENU_PRIMARY")
    }
    
menu_additem(MenuLangText"wpn_pri")
    
    if(
g_PreWeapon[id][WPN_SECONDARY] != -1)
    {
        
ArrayGetString(ArWeaponNameg_PreWeapon[id][WPN_SECONDARY], WeaponNamesizeof(WeaponName))
        
formatex(LangTextsizeof(LangText), "%L [\y%s\w]"GAME_LANG"WPN_MENU_SECONDARY"WeaponName)
    } else {
        
formatex(LangTextsizeof(LangText), "%L \d[ ]\w"GAME_LANG"WPN_MENU_SECONDARY")
    }
    
menu_additem(MenuLangText"wpn_sec")
    
    if(
g_PreWeapon[id][WPN_MELEE] != -1)
    {
        
ArrayGetString(ArWeaponNameg_PreWeapon[id][WPN_MELEE], WeaponNamesizeof(WeaponName))
        
formatex(LangTextsizeof(LangText), "%L [\y%s\w]^n"GAME_LANG"WPN_MENU_MELEE"WeaponName)
    } else {
        
formatex(LangTextsizeof(LangText), "%L \d[ ]\w^n"GAME_LANG"WPN_MENU_MELEE")
    }
    
menu_additem(MenuLangText"wpn_melee")
   
    
formatex(LangTextsizeof(LangText), "\y%L"GAME_LANG"WPN_MENU_TAKEWPN")
    
menu_additem(MenuLangText"get_wpn")
   
    
menu_setprop(MenuMPROP_EXITMEXIT_ALL)
    
menu_display(idMenu0)


PHP Code:

public Reset_PlayerWeapon(idNewPlayer)
{
    if(
NewPlayer)
    {
        
g_PreWeapon[id][WPN_PRIMARY] = g_FirstWeapon[WPN_PRIMARY]
        
g_PreWeapon[id][WPN_SECONDARY] = g_FirstWeapon[WPN_SECONDARY]
        
g_PreWeapon[id][WPN_MELEE] = g_FirstWeapon[WPN_MELEE]
        
        for(new 
0MAX_WEAPONi++)
            
g_UnlockedWeapon[id][i] = 0
    
}
    
    
UnSet_BitVar(g_GotWeaponid)



Weapon Code admin access:

PHP Code:

public zg_weapon_bought(idItemID)
{
    if(
ItemID == g_Base)

    {
    
    if(
get_user_flags(id) & ADMIN_FLAG)
        {
            
Get_Base(id)
        }
        
// If not admin
        
else
        {
            
zg_menu(id);
            
client_print(idprint_chat"[ZPNM] This item is only for admin!");
            
                
            }
            
            }
            
            } 


CrazY. 05-06-2020 09:50

Re: [Help] ZP Admin Access Weapon
 
Share the code of the function MenuHandle_MainEquip

elmedin 05-06-2020 13:39

Re: [Help] ZP Admin Access Weapon
 
Quote:

Originally Posted by CrazY. (Post 2698491)
Share the code of the function MenuHandle_MainEquip

Its ok, i fixed it after some days :)


All times are GMT -4. The time now is 16:51.

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