AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Format HELP (https://forums.alliedmods.net/showthread.php?t=294565)

DarthMan 03-02-2017 05:44

Format HELP
 
Hello. I need help with formatex or format for my menu. Wo, when u prees the models key, it displays the models from the ini, but the problem is that it displays the whole line. I would like it to only display g_line_model and not also g_line_skins. They're separated by "" so like that : "penguin_r" "10" , for example.In penguin_r case, I would like the menu to only display penguin_r and not "penguin_r" "10".

Code:

for (new i; (i < file_size(conffile_model, 1)); i++)
                {
                        read_file(conffile_model, i, g_model_num, 127, leng)
                        menu_additem(menu_model, g_model_num, "", 0);
                }

This script is sued to display the models in the menu, but it still used the old read_file system, because I am more used to it that the enw one, which lacks some things like like,text and length.

Thanks!

OciXCrom 03-02-2017 07:18

Re: Format HELP
 
PHP Code:

// "penguin_r" "10"

new szLine[64], iLen
read_file
(iFileiLineszLinecharsmax(szLine), iLen)
// Result: szLine = "model name" "10"

new szModel[32], szNumber[32]
parse(szLineszModelcharsmax(szModel), szNumbercharsmax(szNumber))
// Result: szModel = penguin_r
// Result: szNumber = 10 


DarthMan 03-02-2017 08:15

Re: Format HELP
 
Code:

new g_thirdperson=0
new conffile_model[200]
new configdir_model[200]
new file_model[128], leng;

new g_Vault;              //Global var to hold our vault handle
new g_Vault_2;
new g_szAuthID[35];    //Global array to store auth ids of players
new g_iArraySize
new Array:g_models

public plugin_init()
{
        register_plugin("Advanced Menu", "1,0", "DarthMan");
        register_clcmd("say menu", "ShowMenu", _, "");
        register_clcmd("say_team menu", "ShowMenu", _, "");
        get_configsdir(configdir_model,199)
        g_models = ArrayCreate(128, 32)
        fileRead()
}

fileRead()
{
        new szConfigsName[256], szFilename[256]
        get_configsdir(szConfigsName, charsmax(szConfigsName))
        formatex(szFilename, charsmax(szFilename), "%s/models.ini", szConfigsName)
        new iFilePointer = fopen(szFilename, "rt")
       
        if(iFilePointer)
        {
                new szData[128]
               
                while(!feof(iFilePointer))
                {
                        fgets(iFilePointer, szData, charsmax(szData))
                        trim(szData)
                       
                        if(szData[0] == EOS || szData[0] == ';')
                                continue
                               
                        ArrayPushString(g_models, szData)
                }
               
                g_iArraySize = ArraySize(g_models)
                fclose(iFilePointer)
        }
}   

public mh_PMenu(id, menu, item)
{
        new szItem[128];
        if(item == MENU_EXIT)
        {
                menu_cancel(id);
                return PLUGIN_HANDLED;
        }

        new command[6], name[64], access, callback;
        //new local_models[128], local_skins[128],  lineIn[128];

        menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);

        switch(item)
        {
                case 0:
                {
                new menu_model = menu_create("Models Menu", "mh_MMenu")
                for(new i; i < g_iArraySize; i++)
                {
                        ArrayGetString(g_models, i, szItem, charsmax(szItem))
                        menu_additem(menu_model, szItem, "", 0)
                }
               
                menu_setprop(menu_model, MPROP_EXIT, MEXIT_ALL);
                menu_setprop(menu_model, MPROP_BACKNAME, "Back");
                menu_setprop(menu_model, MPROP_NEXTNAME, "Next");
                menu_setprop(menu_model, MPROP_EXITNAME, "Close");
                menu_destroy(menu);
                menu_display(id, menu_model, 0);
                }
                case 1:
                {
                if (g_thirdperson==0)
                    {
                        client_print(id, print_chat, "You have selected Thirdperson View");
                        g_thirdperson=1;
                        set_view(id, CAMERA_3RDPERSON);
                        return PLUGIN_CONTINUE;
                    }
                else
                    {
                        client_print(id, print_chat, "You have selected Firstperson View");
                        g_thirdperson=0;
                        set_view(id, CAMERA_NONE);
                        return PLUGIN_CONTINUE;
                    }               
                }
        }

        return PLUGIN_HANDLED;
}


DarthMan 03-02-2017 09:17

Re: Format HELP
 
Problem solved :)


All times are GMT -4. The time now is 21:02.

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