Ok ... the code was so confusing i decided to go ahead and re-write the code
..... OK i decided cause i was confusing myself... for the meantime i will just add in the models as i want untill i can figure out how to make the plugin read an INI file...
heres a new version of my plugin...
Code:
#include <amxmodx>
#include <amxmisc>
#include <tfcx>
#define PLUGIN "TFM Model Mod"
#define VERSION "0.1"
#define AUTHOR "Watch Your Back"
public plugin_init() {
register_plugin(PLUGIN , VERSION , AUTHOR)
register_clcmd("say /setmodel" , "model_menu");
// register_event("ResetHUD","event_resethud","b");
// Add your code here...
}
// ------------------------------------------------------------------------------------------
// --CUSTOM MODEL LIST----------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
public get_models(array[32][],len) {
// get a list of custom models
new dirpos, output[64], outlen, filledamt;
// go through custom models
while((dirpos = read_dir("models/player",dirpos,output,255,outlen)) != 0) {
if(containi(output,".") == -1) { // if not a file (but a directory)
// check if model is actually there
new modelfile[64];
format(modelfile,63,"models/player/%s/%s.mdl",output,output);
// if it exists
if(file_exists(modelfile)) {
format(array[filledamt],len,"%s",output);
filledamt += 1;
}
// if we are out of array space now
if(filledamt > 32) {
return filledamt;
}
}
}
return filledamt;
}
// ------------------------------------------------------------------------------------------
// --PLUGIN PRECACHE------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
public plugin_precache() {
// get custom models
new models[32][33], num;
num = get_models(models,32);
// loop through them
for(new i=0;i<num;i++) {
new modelstring[64];
format(modelstring,63,"models/player/%s/%s.mdl",models[i],models[i]);
precache_model(modelstring);
}
}
/*public event_resethud(id) {
}*/
public model_menu(id){
new menu = menu_create ( "TFM MODEL MENU" , "model_handler")
menu_additem(menu , "\w Change Model", "1", 0)
menu_additem(menu , "\w Reset Model" , "2" , 0)
menu_setprop(menu , MPROP_EXIT , MEXIT_ALL)
menu_display(id , menu , 0)
}
public model_handler(id , menu , item) {
// ON EXIT CLOSE MENU
if (item == MENU_EXIT){
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
new key = str_to_num(data)
switch(key)
{
case 1:{
new menu_ChangeModel = menu_create ( " Change Your Model" , "changeModel_handler")
menu_additem (menu_ChangeModel , "\w Atomic" , "1" , 0)
menu_additem (menu_ChangeModel , "\w stfu_monkey" , "2" , 0)
menu_setprop (menu_ChangeModel , MPROP_EXIT, MEXIT_ALL)
menu_destroy(menu)
menu_display(id , menu_ChangeModel , 0)
}
case 2:{
tfc_clearmodel(id)
client_print(id, print_chat, "You reset you Model")
menu_destroy(menu)
return PLUGIN_HANDLED
}
}
//lets finish up this function with a menu_destroy, and a return
menu_destroy(menu)
return PLUGIN_HANDLED
}
public changeModel_handler(id , menu_ChangeModel , item) {
// ON EXIT CLOSE MENU
if (item == MENU_EXIT){
menu_destroy(menu_ChangeModel)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu_ChangeModel, item, access, data,5, iName, 63, callback)
new key = str_to_num(data)
switch (key)
{
case 1:{
tfc_setmodel(id, "atomic", "")
client_print(id , print_chat, "Your model has been changed to atomic.")
menu_destroy(menu_ChangeModel)
return PLUGIN_HANDLED
}
case 2:{
tfc_setmodel(id, "stfu_monkey" , "")
client_print(id , print_chat , "Your Model has been changed to stfu_monkey")
menu_destroy(menu_ChangeModel)
return PLUGIN_HANDLED
}
}
menu_destroy(menu_ChangeModel)
return PLUGIN_HANDLED
}
i will also attach the sma..
also, when i run this througth the compiler i run with 0 errors but....
when i am in TFC and i decided to use the "Reset Model" off of the 1st menu, i set the code to
Code:
case 2:{
tfc_clearmodel(id)
client_print(id, print_chat, "You reset you Model")
menu_destroy(menu)
return PLUGIN_HANDLED
}
the error comes up in console as.. somethink like
error model model/player/scout017D/scout017D.mdl could not be found.
or somthing to that nature, i dont know where its getting the 017D part of that ... its just sposed to set the model back to the userclass model... maby someone can help me out a little Thanks!