AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Model Menu API (https://forums.alliedmods.net/showthread.php?t=333342)

Supremache 07-04-2021 15:16

Model Menu API
 
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 


VINAGHOST 07-05-2021 09:36

Re: Model Menu API
 
check g_iTotalModels's value

Supremache 07-08-2021 04:06

Re: Model Menu API
 
Quote:

Originally Posted by VINAGHOST (Post 2751930)
check g_iTotalModels's value

I think the issue from my rank system Here.

I want to know why this issuse happinng ? which thing in these code can make other menu won't open!!!

Supremache 07-08-2021 17:26

Re: Model Menu API
 
Which line that make other menus won't open those are using native of rank system because when i disable this function the plugin work:

PHP Code:

public CommandSay(id)
{
    new 
szArgs[192]
    
    
read_args(szArgscharsmax(szArgs))
    
remove_quotes(szArgs)
    
trim(szArgs)

    new 
szCmd[35]
    
parse(szArgsszCmdcharsmax(szCmd))
    
trim(szCmd)
    
    if (
szCmd[0] != '/')
        return 
PLUGIN_CONTINUE
    
    
new iMenu = -1
    
    
for(new  0<= charsmax(g_iCommandSettings); i++)
    {
        if (
equali(szCmd[1], g_iCommandSettings[i][iCommands]))
        {
            
iMenu g_iCommandSettings[i][iMenuType]
            
            if (
iMenu == -1)
                return 
PLUGIN_CONTINUE
            
            g_iPlayerMenu
[id] = iMenu
            PlayerRank
(idg_iCommandSettings[i][iFlags])
            break;
        }
    }

    return 
PLUGIN_HANDLED


Or the issuse from these codes:

PHP Code:

public CustomMenu(id)
{
    new 
szData[MAX_MENU_LENGTH], szInfo[128], pFlag[64], pLevel[64], iPages
        
    formatex
(szInfocharsmax(szInfo), "%L %s"id,  "MENU_TITLE"g_szTeams[iUserTeam(id)])
    
    new 
iMenu menu_create(szInfo"Handler")
    
    for(new 
0g_iTotalModelsi++)
    {
        
ArrayGetArray(ModelsieData)
        
        
g_szAdditionalText[0] = EOS;
        
        
ExecuteForward(g_iForwards[g_MenuOpened], iReturnForwardidi)
        
        if( 
eData[Team] && eData[Team] != iUserTeam(id) )
            continue;
        
        if ( 
eData[Flag] )
            
formatex(pFlagcharsmax(pFlag), "\r[Flag: %s]"eData[Flag])
            
        if ( 
eData[Level] && min(eData[Level], iMaxLevel) )
        {
            
formatex(pLevelcharsmax(pLevel), "\r[\yLv\r:\y%d\r]"min(eData[Level], iMaxLevel))
        }
        
        
formatex(szDatacharsmax(szData), "%s%s \y%s %s %s %s",
        
access(ideData[Flag]) ? "\w" "\d"eData[Name], eData[Info], pFlagpLevelg_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 %s ^n\wPage:\d"id"MENU_TITLE"g_szTeams[iUserTeam(id)])
        
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;
        }
        
        new 
iUserLevel get_user_level(id)
        if ( 
eData[Level] && min(eData[Level], iMaxLevel) > iUserLevel )
        {
            
client_print(idprint_chat"%L"id"NOT_LVL")
            return 
PLUGIN_HANDLED;
        }
            
        
ExecuteForward(g_iForwards[g_MenuOpened], iReturnForwardidiItem)
        
ExecuteForward(g_iForwards[g_SelectModel], iReturnForwardidiItem)
        
client_print(idprint_chat"%L"id"INFO_SELECT",
        
eData[Name], eData[Health], eData[Armor], eData[Speed],  floatround(Float:eData[Gravity] * 800.0), floatround(Float:eData[KnockBack] * 100.0), eData[MultiJump])
    }
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED;



Supremache 07-09-2021 07:48

Re: Model Menu API
 
1 Attachment(s)
I give up, everytime when i add new thing i found issue i will leave it here if someone want to complete :(

Shadows Adi 07-09-2021 13:22

Re: Model Menu API
 
Try this: ( I left some comments too where you done wrong )
PHP Code:

/* Issuse:
    1. Knife precache
    2. Player Model
    3. Edit data from ini file
    4. Replace g_szTeams name into eData[Team]
*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Supremache"

#if !defined client_disconnected
    #define client_disconnected client_disconnect
#endif

#define SetUserModeled(%1)        g_bModeled |= ( 1<<(%1 & 31) ) //flag_set
#define SetUserNotModeled(%1)    g_bModeled &= ~( 1<<(%1 & 31) )//unset
#define IsUserModeled(%1)        ( g_bModeled & ( 1<<(%1 & 31) ) ) //flag_get
#define m_pPlayer 41
#define m_pTeam 114
#define iUserTeam(%1) get_pdata_int(%1, m_pTeam)
#define m_afButtonPressed 246
#define MAX_MENU_LENGTH 512
#define MAX_PLAYERS 32

enum _:Data
{
    
Name[MAX_PLAYERS],
    
Info[MAX_PLAYERS],
    
Model[MAX_PLAYERS],
    
Knife[MAX_PLAYERS 2],
    
Flag[MAX_PLAYERS],
    
Health,
    
Armor,
    
Speed,
    
Gravity,
    
KnockBack,
    
MultiJump,
    
Team
}

enum _:TotalForwards
{
    
g_MenuOpened 0,
    
g_SelectModel,
    
g_SetModel
}


new 
g_iForwards[TotalForwards],
    
iReturnForward
    
new Array:Models,
    
g_iTotalModels,
    
eData[Data],
    
g_szAdditionalText[MAX_PLAYERS 2],
    
Float:g_iKnockBack[MAX_PLAYERS],
    
Float:g_iSpeed[MAX_PLAYERS],
    
g_iJump[MAX_PLAYERS],
    
g_szCurrentModel[MAX_PLAYERS][MAX_PLAYERS 2],
    
g_szFile[MAX_PLAYERS 8],
    
g_szTeams[4][MAX_PLAYERS],
    
g_bModeled,
    
g_iJumpCount[MAX_PLAYERS 1],
    
bool:g_bGiveMultiJump[MAX_PLAYERS 1],
    
g_iNextClass[MAX_PLAYERS 1],
    
g_iClass[MAX_PLAYERS 1]


public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_dictionary("CustomModels.txt");
    
    if( 
g_iTotalModels )
        
console_print(0"* Total Registered Models: %d"g_iTotalModels)
    else 
console_print(0"* No Models found in the configuration file.")
        
    
RegisterHam(Ham_Spawn"player""OnPlayerSpawn"1)
    
RegisterHam(Ham_Item_Deploy"weapon_knife""OnSelectKnife"1)
    
RegisterHam(Ham_Player_Jump"player""OnCBasePlayer_Jump"false)
    
    
g_iForwards[g_MenuOpened] = CreateMultiForward("open_menu"ET_IGNOREFP_CELL)
    
g_iForwards[g_SelectModel] = CreateMultiForward("model_selected"ET_IGNOREFP_CELLFP_CELL)
    
g_iForwards[g_SetModel] = CreateMultiForward("set_model"ET_IGNOREFP_CELLFP_CELL)
    
    
register_forwardFM_SetClientKeyValue"fw_SetClientKeyValue" );
    
register_forwardFM_PlayerPreThink"fw_PlayerPreThink" )
    
    
ReadFile()
}

public 
plugin_precache()
{
    
Models ArrayCreate(Data)
    
    
// The array should be created before precache.
    //Models = ArrayCreate(Data)
    
    
get_configsdir(g_szFilecharsmax(g_szFile))
    
add(g_szFilecharsmax(g_szFile), "/ModelMenu.ini")
}

public 
client_putinserverid )
{
    
g_iClass[id] = 0
    g_iNextClass
[id] = g_iClass[id]
    
g_bGiveMultiJump[id] = true
}

public 
client_disconnected(id)
{
    
g_iClass[id] = 0
    g_iNextClass
[id] = 0
    g_bGiveMultiJump
[id] = false
}

public 
plugin_natives()
{
    
register_native("register_model""_RegisterModels")
    
register_native("add_text""_MenuText")
    
register_native("get_next_class""_NextClass")
    
register_native("get_class""_Class")
}

public 
_MenuText(iPluginiParams)
{
    
get_string(1g_szAdditionalTextcharsmax(g_szAdditionalText))
}

public 
_NextClass(iPluginiParams)
{
    return 
g_iNextClass[get_param(1)];
}

public 
_Class(iPluginiParams)
{
    return 
g_iClass[get_param(1)];
}

/*Example of native:
//native register_model(
        const szName[],
        const szInfo[],
        const szModel[],
        const szKnife[],
        const szFlag[],
        iHealth,
        iArmor,
        iSpeed,
        Float:iGravity,
        Float:iKnockBack,
        iMultiJump,
        iTeam 
    );
*/
public _RegisterModels(iPluginiParams)
{
    
get_string(1eData[Name], charsmax(eData[Name]))
    
get_string(2eData[Info], charsmax(eData[Info]))
    
get_string(3eData[Model], charsmax(eData[Model]))
    
get_string(4eData[Knife], charsmax(eData[Knife]))
    
get_string(5eData[Flag], charsmax(eData[Flag]))
    
eData[Health] = get_param(6)
    
eData[Armor] = get_param(7)
    
eData[Speed] = get_param(8)
    
eData[Gravity] = get_param(9)
    
eData[KnockBack] = get_param(10)
    
eData[MultiJump] = get_param(11)
    
eData[Team] = get_param(12)

    new 
szModel[64];

    if(
eData[Model] != EOS)
    {
        
formatexszModelcharsmaxszModel ), "models/player/%s/%s.mdl"eData[Model], eData[Model] );
        
precache_modelszModel );
    }
    
    if(
eData[Knife] != EOS)
    {
        
formatexszModelcharsmaxszModel ), "models/%s.mdl"eData[Knife] );
        
precache_modelszModel );
    }

    
ArrayPushArray(ModelseData)

    
g_iTotalModels++
    

    
// Why do you wanna return every time the total models num - 1 ??
    //return g_iTotalModels - 1
}

public 
plugin_end()
{    
    
// Why do you loop through array's items if the server is deactivating or map changes?

    /*for(new i ; i < g_iTotalModels; i++)
    {
        ArrayGetArray(Models, i, eData)
    }*/
    
    
ArrayDestroy(Models)
    
DestroyForward(g_iForwards[g_MenuOpened])
    
DestroyForward(g_iForwards[g_SelectModel])
    
DestroyForward(g_iForwards[g_SetModel])
}


public 
OnTakeDamage(iVictimiInflictoriAttacker)
{
    for(new 
0g_iTotalModelsi++)
    {
        
ArrayGetArray(ModelsieData)
        
        if( 
eData[Team] && eData[Team] != iUserTeam(iVictim) )
            continue;
                
        if(
eData[KnockBack])
        {
            if(!
is_user_connected(iAttacker) || iVictim == iAttacker || iInflictor != iAttacker)
                return 
HAM_IGNORED;
        
            if(
iUserTeam(iAttacker) == iUserTeam(iVictim))
                return 
HAM_SUPERCEDE;
            
            new 
Float:fVelocity[3]
            
velocity_by_aim(iAttacker64fVelocity)
            
fVelocity[2] = g_iKnockBack[iAttacker]
            
set_pev(iVictimpev_velocityfVelocity)
        }
    }
    return 
HAM_SUPERCEDE;
}

public 
OnCBasePlayer_Jump(id)
{
    if ( !
g_bGiveMultiJump[id] || !is_user_alive(id))
        return 
HAM_HANDLED
    
    
new iFlags pev(idpev_flags)
    
    if( 
iFlags FL_WATERJUMP || pev(idpev_waterlevel) >= || !(get_pdata_int(idm_afButtonPressed) & IN_JUMP))
    {
        return 
HAM_IGNORED
    
}
    
    if (
iFlags FL_ONGROUND)
    {
        
g_iJumpCount[id] = 0
        
return HAM_IGNORED
    
}
    
    for(new 
0g_iTotalModelsi++)
    {
        
ArrayGetArray(ModelsieData)
            
        if( 
eData[Team] && eData[Team] != iUserTeam(id) )
            continue;
            
        if( 
g_iJump[id] )
        {
            if (++
g_iJumpCount[id] < g_iJump[id])
            {
                new 
Float:fVelocity[3]
                
pev(idpev_velocityfVelocity)
                
fVelocity[2] = 268.328157
                set_pev
(idpev_velocityfVelocity)
                return 
HAM_HANDLED
            
}
        }
    }
    return 
HAM_IGNORED
}

public 
OnSelectKnife(iEnt)
{
    new 
id get_pdata_cbase(iEntm_pPlayer4)
    
    
RefreshModel(id)
}

RefreshModel(const id)
{
    
set_pev(idpev_viewmodel2eData[Knife])
}

public 
fw_SetClientKeyValueid, const szBuffer[], const szKey[], const szValue[] )
{
    if( !
equalszKey"model" ) )
        return 
FMRES_IGNORED;
    
    for(new 
0g_iTotalModelsi++)
    {
        
ArrayGetArray(ModelsieData)
        
        if( 
eData[Team] && eData[Team] != iUserTeam(id) )
            continue;
            
        if(
eData[Model])
        {
            
get_user_info(id"model"g_szCurrentModel[id], charsmax(g_szCurrentModel[]))
                
            if( !
IsUserModeledid ) || !equalg_szCurrentModelid ], eData[Model] ) || !equalszValueeData[Model] ) )
            {
                    
copyg_szCurrentModelid ], charsmaxg_szCurrentModel[] ),eData[Model] );
                    
SetUserModeledid );
                        
                    
set_user_infoid"model"eData[Model] );
                    return 
FMRES_SUPERCEDE;
            }

            if( 
IsUserModeledid ) )
            {
                
SetUserNotModeledid );
                
g_szCurrentModelid ][ ] = 0;
            }
        }
    }
    
    return 
FMRES_IGNORED;
}

public 
fw_PlayerPreThink(id)
{
    for(new 
0g_iTotalModelsi++)
    {
        
ArrayGetArray(ModelsieData)
        
        if( 
eData[Team] && eData[Team] != iUserTeam(id) )
            continue;
            
        if( 
eData[Speed] )
            
set_pev(idpev_maxspeedg_iSpeed[id])
    }
}

public 
OnPlayerSpawn(id)
{
    if(
is_user_alive(id))
    {        
        for(new 
0g_iTotalModelsi++)
        {
            
ArrayGetArray(ModelsieData)
            
            if( 
eData[Team] && eData[Team] != iUserTeam(id) )
                continue;
                
            if (
g_iNextClass[id] != g_iClass[id])
                
g_iClass[id] = g_iNextClass[id]
                
            if( 
eData[Knife] )
            {
                if(
get_user_weapon(id) == CSW_KNIFE)
                {
                    
RefreshModel(id)
                }
            }
            
            if( 
eData[Health] )
                
set_pev(idpev_healthfloat(eData[Health]))
                
            if( 
eData[Armor] )
                
set_pev(idpev_armorvaluefloat(eData[Armor]))
                
            if( 
eData[Gravity] )
                
set_pev(idpev_gravityfloat(eData[Gravity]))
                
            if( 
eData[KnockBack] )
                
g_iKnockBack[id] =  float(eData[KnockBack])
                
            if( 
eData[Speed] )
                
g_iSpeed[id] = float(eData[Speed])
            
            if( 
eData[MultiJump] )
                
g_iJump[id] = eData[MultiJump]
                
            
ExecuteForward(g_iForwards[g_SetModel], iReturnForwardidg_iClass[id])
        }
    }
}

public 
CustomMenu(id)
{
    new 
szData[MAX_MENU_LENGTH], szInfo[128], iPages
        
    formatex
(szInfocharsmax(szInfo), "%L %s"id,  "MENU_TITLE"g_szTeams[iUserTeam(id)])
    
    new 
iMenu menu_create(szInfo"Handler")
    
    for(new 
0g_iTotalModelsi++)
    {
        
ArrayGetArray(ModelsieData)
        
        
// wanna reset an array, use this kind of reset
        
g_szAdditionalText[0] = 0;
        
        if( 
eData[Team] && eData[Team] != iUserTeam(id) )
            continue;
        
        if ( 
eData[Flag] )
            
formatex(szDatacharsmax(szData), "%s%s \y%s \r[Flag: %s] %s %s",
            
access(ideData[Flag]) ? "\w" "\d"eData[Name], eData[Info], eData[Flag], g_szAdditionalText, ( == g_iClass[id] ) ? "\r-=\wSELECTED\r=-" "")
        else
            
formatex(szDatacharsmax(szData), "%s%s \y%s %s %s",
            
access(ideData[Flag]) ? "\w" "\d"eData[Name], eData[Info], g_szAdditionalText, ( == g_iClass[id] ) ? "\r-=\wSELECTED\r=-" "")
        
menu_additem(iMenuszData)
        
        
// Don't call forwards in loops.
        //ExecuteForward(g_iForwards[g_MenuOpened], iReturnForward, id)
    
}
    
    
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(szInfo, charsmax(szInfo), "%L %s ^n\wPage:\d", id, "MENU_TITLE", g_szTeams[iUserTeam(id)])
        menu_setprop(iMenu, MPROP_TITLE, szInfo)
    }*/
    
    
menu_display(idiMenu)
    
ExecuteForward(g_iForwards[g_MenuOpened], iReturnForwardid)
    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;
        }
        
        
g_iClass[id] = iItem
        
        
//ExecuteForward(g_iForwards[g_MenuOpened], iReturnForward, id, g_iClass[id])
        
ExecuteForward(g_iForwards[g_SelectModel], iReturnForwardidg_iClass[id])
        
client_print(idprint_chat"%L"id"INFO_SELECT",
        
eData[Name], eData[Health], eData[Armor], eData[Speed],  floatround(Float:eData[Gravity] * 800.0), floatround(Float:eData[KnockBack] * 100.0), eData[MultiJump])
    }
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED;
}

ReadFile()
{
    if( 
file_exists(g_szFile) )
    {
        new 
iFile fopeng_szFile"rt" );
        
        new 
szData[264], szKey[32], szValue[128]
                
        while(
fgets(iFileszDatacharsmax(szData)))
        {
            
trim(szData);
            
remove_quotes(szData);
                    
            switch( 
szData] )
            {
                case 
EOS'#'';''/''[': continue;
                
//case '[':
                //{
                //    szData[strlen(szData) - 1] = 0;
                //    copy(szData, charsmax(szData), szData[1])
                //    continue;
                //}
                
default:
                {
                    
strtokszDataszKeycharsmax(szKey), szValuecharsmax(szValue), '=' );
                    
trim(szKey); trim(szValue);
                            
                    if( ! 
szValue] || ! szKey] )
                        continue;
                    

                    if(
equal(szKey"MENU_COMMANDS"))
                    {
                        while(
szValue[0] != && strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ','))
                        {
                            
trim(szKey); trim(szValue)
                            
register_clcmd(szKey"CustomMenu")
                        }
                    }
                    else if(
equal(szKey"TEAM_NAMES"))
                    {
                        for(new 
04i++)
                        {
                            
strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ',')
                            
trim(szKey); trim(szValue)
                            
copy(g_szTeams[i], charsmax(g_szTeams[]), szKey)
                        }
                    }
                    else if(
equal(szKey"NAME"))
                        
copy(eData[Name], charsmax(eData[Name]), szValue)
                    else if(
equal(szKey"INFO"))
                        
copy(eData[Info], charsmax(eData[Info]), szValue)
                    else if(
equal(szKey"MODEL"))
                    {
                        while(
szValue[0] != && strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ','))
                        {
                            
trim(szKey); trim(szValue)
                            
copy(eData[Model], charsmax(eData[Model]), szValue)
                        }
                    }
                    else if(
equal(szKey"KNIFE"))
                        
copy(eData[Knife], charsmax(eData[Knife]), szValue)
                    else if(
equal(szKey"FLAG"))
                        
copy(eData[Flag], charsmax(eData[Flag]), szValue)
                    else if(
equal(szKey"HP"))
                        
eData[Health] = str_to_num(szValue)
                    else if(
equal(szKey"ARMOR"))
                        
eData[Armor] = str_to_num(szValue)
                    else if(
equal(szKey"SPEED"))
                        
eData[Speed] = str_to_num(szValue)
                    else if(
equal(szKey"GRAVITY"))
                        
eData[Gravity] = _:str_to_float(szValue)
                    else if(
equal(szKey"KB"))
                        
eData[KnockBack] = _:str_to_float(szValue)
                    else if(
equal(szKey"MJ"))
                        
eData[MultiJump] = str_to_num(szValue)
                    
//else if(equal(szKey, "LEVEL"))
                    //    eData[Level] = str_to_num(szValue)
                    
else if(equal(szKey"TEAM"))
                        
eData[Team] = str_to_num(szValue)
                }
            }
        }
        
fcloseiFile );
    }
    else
    {
        
delete_file(g_szFile)
        new 
iFile fopen(g_szFile"at")
            
        if(
iFile)
        {
            
fputs(iFile"[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]^n")
            
fputs(iFile"[]                    Model Menu API: Configuration file                        []^n")
            
fputs(iFile"[]                              AUTHOR: Supremache                []^n")
            
fputs(iFile"[] Any changes you make here will be automatically loaded at map start. []^n")
            
fputs(iFile"[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]^n^n")
            
fputs(iFile"MENU_COMMANDS = say /skin, say_team /skin, say /model, say_team /model, custommodel^n")
            
fputs(iFile"TEAM_NAMES = Unassigned, Terrorist, Counter-Terrorist, Spectator^n")
            
fputs(iFile"ENABLE_RANK = ^n")
        
            for(new 
0g_iTotalModelsi++)
            {
                
ArrayGetArray(ModelsieData)
        
                
fprintf(iFile"^n[%s]"eData[Name])
                
fprintf(iFile"^nNAME = %s"eData[Name])
    
                
fprintf(iFile"^nINFO = %s"eData[Info])
                        
                
fprintf(iFile"^nMODEL = %s"eData[Model])
                        
                
fprintf(iFile"^nKNIFE = %s"eData[Knife])
                        
                
fprintf(iFile"^nFLAG = %s"eData[Flag])
                    
                
fprintf(iFile"^nHP = %d"eData[Health])
                
                
fprintf(iFile"^nARMOR = %d"eData[Armor])
                    
                
fprintf(iFile"^nSPEED = %d"eData[Speed])
                
                
// dont use "%.2f" if you don't know what is does, use standard "%f" and it should be fine
                
fprintf(iFile"^nGRAVITY = %f"Float:eData[Gravity])
                        
                
fprintf(iFile"^nKB = %f"Float:eData[KnockBack])
                
                
fprintf(iFile"^nMJ = %d"eData[MultiJump])
                
                
fprintf(iFile"^nTEAM = %s^n"g_szTeams[eData[Team]])
            }
            
fcloseiFile );
        }
            
    }
}

/*
ReadFile()
{            
    if( file_exists(g_szFile) )
    {
        new iFile = fopen( g_szFile, "rt" );
        
        new szData[264], szKey[32], szValue[128], iSection = SECTION_NONE
                
        while(fgets(iFile, szData, charsmax(szData)))
        {
            trim(szData);
            remove_quotes(szData);
            
            switch( szData[ 0 ] )
            {
                case EOS, '#', ';', '/', '[': continue;
                default:
                {
                    if(iSection == SECTION_NONE)
                    {
                        continue
                    }

                    strtok( szData, szKey, charsmax(szKey), szValue, charsmax(szValue), '=' );
                    trim(szKey); trim(szValue);
                            
                    if( ! szValue[ 0 ] || ! szKey[ 0 ] )
                        continue;
                    
                    switch(iSection)
                    {
                        case SECTION_SETTINGS:
                        {
                            if(equal(szKey, "MENU_COMMANDS"))
                            {
                                while(szValue[0] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
                                {
                                    trim(szKey); trim(szValue)
                                    register_clcmd(szKey, "CustomMenu")
                                }
                            }
                            else if(equal(szKey, "TEAM_NAMES"))
                            {
                                for(new i = 0; i < 2; i++)
                                {
                                    strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ',')
                                    trim(szKey); trim(szValue)
                                    copy(g_szTeams[i], charsmax(g_szTeams[]), szKey)
                                }
                            }
                        }
                        
                        case SECTION_OPTIONS:
                        {
                            if(equal(szKey, "NAME"))
                                copy(eData[Name], charsmax(eData[Name]), szValue)
                            else if(equal(szKey, "INFO"))
                                copy(eData[Info], charsmax(eData[Info]), szValue)
                            else if(equal(szKey, "MODEL"))
                                copy(eData[Model], charsmax(eData[Model]), szValue)
                            else if(equal(szKey, "KNIFE"))
                                copy(eData[Knife], charsmax(eData[Knife]), szValue)
                            else if(equal(szKey, "FLAG"))
                                copy(eData[Flag], charsmax(eData[Flag]), szValue)
                            else if(equal(szKey, "HP"))
                                eData[Health] = str_to_num(szValue)
                            else if(equal(szKey, "SPEED"))
                                eData[Speed] = str_to_num(szValue)
                            else if(equal(szKey, "GRAVITY"))
                                eData[Gravity] = _:str_to_float(szValue)
                            else if(equal(szKey, "KB"))
                                eData[KnockBack] = _:str_to_float(szValue)
                            else if(equal(szKey, "TEAM"))
                                eData[Team] = str_to_num(szValue)
                                
                            //ArraySetArray(Models, iModel, eData)
                        }
                    }
                            
                }
            }
        }
        fclose( iFile );
    }
}

LoadFile()
{
    new iFile = fopen(g_szFile, "wt")
            
    if(iFile)
    {
            fputs(iFile, "[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]^n")
            fputs(iFile, "[]                    Model Menu API: Configuration file                        []^n")
            fputs(iFile, "[]                              AUTHOR: Supremache                []^n")
            fputs(iFile, "[] Any changes you make here will be automatically loaded at map start. []^n")
            fputs(iFile, "[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]^n^n")
            fputs(iFile, "MENU_COMMANDS = say /skin, say_team /skin, say /model, say_team /model, custommodel^n")
            fputs(iFile, "TEAM_NAMES = Terrorist, Counter-Terrorist^n")
        
        for(new i = 0; i < g_iTotalModels; i++)
        {
            ArrayGetArray(Models, i, eData)
    
            fprintf(iFile, "^n[%s]", eData[Name])
            fprintf(iFile, "^nNAME = %s", eData[Name])

            fprintf(iFile, "^nINFO = %s", eData[Info])
                    
            fprintf(iFile, "^nMODEL = %s", eData[Model])
                    
            fprintf(iFile, "^nKNIFE = %s", eData[Knife])
                    
            fprintf(iFile, "^nFLAG = %s", eData[Flag])
                
            fprintf(iFile, "^nHP = %d", eData[Health])
            
            fprintf(iFile, "^nARMOR = %d", eData[Armor])
                
            fprintf(iFile, "^nSPEED = %d", eData[Speed])
                
            fprintf(iFile, "^nGRAVITY = %.2f", Float:eData[Gravity])
                    
            fprintf(iFile, "^nKB = %.2f", Float:eData[KnockBack])
            
            fprintf(iFile, "^nMJ = %d", eData[MultiJump])
                
            //fprintf(iFile, "^nTEAM = %s", g_szTeams[eData[Team]])
        }
        
        fclose( iFile );
            
    }
}
*/ 


Natsheh 07-09-2021 13:43

Re: Model Menu API
 
Good job shadows adi you turned the script from worst to bad.

Supremache 07-10-2021 09:27

Re: Model Menu API
 
@Shadows Adi, it's my first time using array , but i think i do well and always i trying to optimize the code, but there are small details can destroy the fully plugin, thanks a lot bro for the help :)

Quote:

Originally Posted by Natsheh (Post 2752357)
Good job shadows adi you turned the script from worst to bad.

Why you every time doing that? why don't help other instead of giving your review that is never helping others!!!

Quote:

Originally Posted by Natsheh (Post 2747381)
Its not efficient there are better ways to do this also imagine the map has more than 1 barrier exist.

You did it before and you didn't give me any idea how to do this plugin with other way.

Quote:

Originally Posted by Natsheh (Post 2751403)
Show the whole script or don't bother getting help here.

Quote:

Originally Posted by Natsheh (Post 2751839)
Well mate this is earth its not heaven.

And i don't see any sign of disrespecting.

If you think i meant "Post whole code or get the f**k out." Then the problem is in you.

Quote:

Originally Posted by Natsheh (Post 2751816)
how can newbies learn if they can't even read the rules ?

All you answers are the same please dude we are here for helping other and not to be proud of what we have of experience, if you want help others please give help to them and dont give your bad review :nono:


PS: I don't create this plugin for my self, i creating it for some persons asked for it many time.

Natsheh 07-10-2021 09:58

Re: Model Menu API
 
Excuse me i am here sharing my opinions i am not your teacher nor your employee if you want to gain experience you can start by searching and reading alot of tutorials and topics to improve your knowledge then if you found a dead road you can make a topic here so far you one of the people who spams the forums with nonsense.

Supremache 07-10-2021 11:38

Re: Model Menu API
 
Quote:

Originally Posted by Natsheh (Post 2752429)
Excuse me i am here sharing my opinions i am not your teacher nor your employee if you want to gain experience you can start by searching and reading alot of tutorials and topics to improve your knowledge then if you found a dead road you can make a topic here so far you one of the people who spams the forums with nonsense.

You didn't share any opinions what you do is sharing your review of plugin and say it's bad/good/etc
Read the name of the section !! "Scripting Help"

The Rules of this section:
Spoiler


We understand from all this that who need help or asking for something about scripting should waiting for get the solution not for getting reviews for what he did or what he will do.

I'm one of the people who spams the forums with nonsense ?
Well, i think you understand, The scripter who helping other member called spammer, then you calling all scripters who helping other members are spammers :shock:

I think you don't know what are you talking about.. :wink:


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

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