Raised This Month: $ Target: $400
 0% 

Model Menu API


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 07-04-2021 , 15:16   Model Menu API
Reply With Quote #1

Hi, I made this plugin "Model Menu API" something like zp model system, when i add level support the menu won't open but other data in the plugin are work and it doesn't show any bug!
Can someone show me where is the issue.

PHP Code:
#if !defined crxranks_get_user_level
    #define crxranks_get_user_level get_user_level
#endif

#if !defined crxranks_get_max_levels
    #define crxranks_get_max_levels get_max_levels
#endif

#if defined crxranks
    
native crxranks_get_user_level(id)
    
native crxranks_get_max_levels()
#else
    
native get_user_level(id)
    
native get_max_levels()
#endif
new iMaxLevels
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /skin""CustomMenu")
    
iMaxLevels get_max_levels()
}


public 
CustomMenu(id)
{
    new 
szData[MAX_MENU_LENGTH], szInfo[128]
    static 
iPagesi
        
    formatex
(szInfocharsmax(szInfo), "%L"idiUserTeam(id) != "SHOP_TITLE_CT" "SHOP_TITLE_T")
    
    new 
iMenu menu_create(szInfo"Handler")
    
    for(
0g_iTotalModelsi++)
    {
        
ArrayGetArray(ModelsieData)
        
        
g_szAdditionalText[0] = EOS;
        
        
ExecuteForward(g_iForwards[g_MenuOpened], iReturnForwardidi)

        if( 
eData[Team] && eData[Team] != iUserTeam(id) )
            continue;
        
        new 
iFlagInfo[64], iLevelInfo[64]
        
        if ( 
eData[Flag] )
            
format(iFlagInfocharsmax(iFlagInfo), "\r[Flag: %s]"eData[Flag])
        else
            
format(iFlagInfocharsmax(iFlagInfo), "")
        
        if ( 
eData[Level] && eData[Level] <= iMaxLevels)
            
format(iLevelInfocharsmax(iLevelInfo), "\r[\yLv: %d\r]"eData[Level])
        else
            
format(iLevelInfocharsmax(iLevelInfo), "")
        

        new 
iUserLevel get_user_level(id)
        
formatex(szDatacharsmax(szData), "%s%s \y%s %s %s %s",
        (
access(ideData[Flag]) && iUserLevel >= eData[Level]) ? "\w" "\d",
        
eData[Name], eData[Info], iLevelInfoiFlagInfog_szAdditionalText)

        
menu_additem(iMenuszData)
    }
    
    
formatex(szInfocharsmax(szInfo), "%L"id"PREV_PAGE")
    
menu_setprop(iMenuMPROP_BACKNAMEszInfo)
    
formatex(szInfocharsmax(szInfo), "%L"id"NEXT_PAGE")
    
menu_setprop(iMenuMPROP_NEXTNAMEszInfo)
    
formatex(szInfocharsmax(szInfo), "%L"id"EXIT_MENU")
    
menu_setprop(iMenuMPROP_EXITNAMEszInfo)
        
    
iPages menu_pages(iMenu)
    
    if ( !
iPages )
    {
        
client_print(idprint_chat"%L"id"NOT_MODELS")
        return 
PLUGIN_HANDLED;
    }
    else if(
iPages 1)
    {
        
formatex(szInfocharsmax(szInfo), "%L ^n\wPage:\d"idiUserTeam(id) != "SHOP_TITLE_CT" "SHOP_TITLE_T")
        
menu_setprop(iMenuMPROP_TITLEszInfo)
    }
    
    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED;
}

public 
Handler(idiMenuiItem
{
    if(
iItem != MENU_EXIT)
    {
        if(!
is_user_alive(id))
        {
            
client_print(idprint_chat"%L"id"NOT_ALIVE")
            return 
PLUGIN_HANDLED;
        }

        
ArrayGetArray(ModelsiItemeData)
        
        if( 
eData[Flag] && !access(ideData[Flag]) )
        {
            
client_print(idprint_chat"%L"id"NOT_ACCESS")
            return 
PLUGIN_HANDLED;
        }
        if ( 
eData[Level] && eData[Level] <= iMaxLevels)
        {
            new 
iUserLevel get_user_level(id)
            if ( 
eData[Level] && iUserLevel eData[Level])
            {
                
client_print(idprint_chat"%L"id"NOT_LVL")
                return 
PLUGIN_HANDLED;
            }
        }
        
        
ExecuteForward(g_iForwards[g_SelectModel], iReturnForwardidiItem)
        
client_print(idprint_chat"%L"id"INFO_SELECT",
        
eData[Name], eData[Health], eData[Speed],  floatround(Float:eData[Gravity] * 800.0), floatround(Float:eData[KnockBack] * 100.0))
    }
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED;

Subplugin:
PHP Code:
native register_model(const szName[], const szInfo[], const szModel[], const szFlag[], iHealthiSpeedFloat:iGravityFloat:iKnockBackiLeveliTeam)

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_model("Test""\r[\yNewer\r]""Test"""5000500Float:0.5Float:0.5151/*T Team*/)

The file is reading level value but why the menu won't open:
PHP Code:
[Test]
NAME Test
INFO 
= \r[\yNewer\r]
MODEL Test
HP 
5000
SPEED 
500
GRAVITY 
0.50
KNOCKBACK 
0.50
LEVEL 
15
TEAM 
Terrorist 
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 07-04-2021 at 18:09.
Supremache 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 09:04.


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