AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Player Model Menu (https://forums.alliedmods.net/showthread.php?t=294469)

DarthMan 02-27-2017 17:19

[HELP] Player Model Menu
 
Hello everyone. I made a menu plugin and I have problems with setting the model.
Can someone fix it? Replace VAR with the desired variable.

Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <tfcx>
#include <engine>
#include <fakemeta>
#include <fun>

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


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)
        format(conffile_model,199,"%s/models.ini",configdir_model)
}

public plugin_precache()
{
    new conffile_mdl[200]
    new configdir_mdl[200]
 
    get_configsdir(configdir_mdl,199)
    format(conffile_mdl,199,"%s/models.ini",configdir_mdl)
    if(!file_exists(conffile_mdl))
    {
        log_amx("amxmodx/configs/models.ini is missing!")
        return 0
    }
 
    new lines = file_size(conffile_mdl,1)
    new name[128], len
    new model_path[128]
    for(new i=0;i<=lines;i++)
    {
        read_file(conffile_mdl,i,name,127,len)
        if(equal(name,"")) continue;
        if(!equal(name,";",1)) {
            // log_amx("precache: %s", file)
            format(model_path, charsmax(model_path), "models/player/%s/%s.mdl",name,name)
            precache_model(model_path);
        }
    }
    return PLUGIN_HANDLED;
}

/* Player Connect */


/* Player Menu */

public ShowMenu(id)
{
        new menu = menu_create("Player Menu", "mh_PMenu");

        menu_additem(menu, "Models", "", 0); // case 0
        if (g_thirdperson==0)
        {
        menu_additem(menu, "Thirdperson View", "", 0); // case 1
        }
        else
        {
        menu_additem(menu, "Firstperson View", "", 0); // case 1
        }
        menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
        menu_setprop(menu, MPROP_BACKNAME, "Back");
        menu_setprop(menu, MPROP_NEXTNAME, "Next");
        menu_setprop(menu, MPROP_EXITNAME, "Close");

        menu_display(id, menu, 0);

        return PLUGIN_HANDLED;   
}

public mh_PMenu(id, menu, item)
{
        if(item == MENU_EXIT)
        {
                menu_cancel(id);
                return PLUGIN_HANDLED;
        }

        new command[6], name[64], access, callback;

        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 < file_size(conffile_model, 1)); i++)
                {
                        read_file(conffile_model, i, file_model, 127, leng)
                        menu_additem(menu_model, file_model, "", 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;
}

public mh_MMenu(id, menu_model, item)
{
        if(item == MENU_EXIT)
        {
                menu_cancel(id);
                return PLUGIN_HANDLED;
        }

        new command[6], name[64], access, callback;

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

        switch(item)
        {
                case 0:
                {
                //tfc_setmodel(id,VAR,"0");
                //client_print(id, print_chat, "You changed the player model to %s.", VAR);
                }
        }

        menu_destroy(menu_model);

        return PLUGIN_CONTINUE;
}


edon1337 02-27-2017 17:26

Re: [HELP] Player Model Menu
 
What's the problem firstly

DarthMan 02-28-2017 01:13

Re: [HELP] Player Model Menu
 
Quote:

Originally Posted by edon1337 (Post 2499219)
What's the problem firstly

The problem is, in the way I made the vars, idk how I can set it to change the model.
Look at all the global vars and the local i var, and see what can be done.

DarthMan 02-28-2017 05:50

Re: [HELP] Player Model Menu
 
Quote:

Originally Posted by edon1337 (Post 2499219)
What's the problem firstly

When u select an item it should change the model to the specified item and then display the model name as a client_print id message.

DarthMan 02-28-2017 12:01

Re: [HELP] Player Model Menu
 
Let me be more explicit. So what I did was a menu which at the moment can be used to change ur model or view from 1st to 3rd eprson view or vice-versa. There is an issue actually that I can't solve. I've tried some ways and failed. When u select the model tab, it will display all models from the ini file in the menu. However, if u select a model it won't change because I don't know how to do that. So absically what I require is a script on public mh_PMenu(id, menu, item) case 0 that will change the model according to the model name from the selected item. So if for example the 1st tiem from the model menu is abe, the plugin is supossed to change ur model to abe, by using the tfc_setmodel command. I hope that whoever reads the message now will understand what I need. Thanks !

wickedd 02-28-2017 12:50

Re: [HELP] Player Model Menu
 
1.Learn how to use the edit button.
2.What game is this for?

DarthMan 02-28-2017 12:59

Re: [HELP] Player Model Menu
 
Quote:

Originally Posted by wickedd (Post 2499445)
1.Learn how to use the edit button.
2.What game is this for?

It is for Team Fortress Classic.


All times are GMT -4. The time now is 20:43.

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