Hello all!
I read model's name from file, then copy name to structure and morph to that string and get (model_name)
// ERROR
WPN_PM.MDL
: cant open
///////////
typedef struct
{
...
STRING* mdl_name;// Model name
} weapon_stats_struct;
void EquipWeapon(var _weapon)
{
current_weapon = _weapon;
ent_morph(weapon_ent, weapon_box[_weapon].mdl_name);// This!!!
snd_play(weapon_box[_weapon].draw_snd, 30, 0);
}
#define TYPE_TEXT 1
#define TYPE_VAR 2
function load_cfg(var _id, var _type, STRING* _file)
{
var asc_return;
var line = 0;
var start_read = 0;
var line_length = 0;
var longest_line_length = 0;
var delimit_vars = str_to_asc("=");
var delimit_varm = str_to_asc("#");
var delimit_varn = 10;// \n
var errors = 0;
STRING* temp2_str = "#100";
STRING* temp_str = str_create("0");
str_cpy((tooltips_text.pstring)[0], "");
var fhandle = file_open_game(_file);
while (line != _id && errors == 0)
{
if (fhandle == 0) {errors = 1; break;}
if (asc_return == -1) {errors = 2; break;}
asc_return = file_asc_read(fhandle);
if (asc_return == delimit_varn) {line++;}
}
while (start_read != 1 && errors == 0)
{
if (fhandle == 0) {errors = 1; break;}
asc_return = file_asc_read(fhandle);
if (asc_return == delimit_vars) {start_read = 1;}
if (asc_return == delimit_varn) {errors = 3; break;}
if (asc_return == -1) {errors = 2; break;}
}
while (1)
{
if (fhandle == 0 && errors == 0) {errors = 1; break;}
asc_return = file_asc_read(fhandle);
if (asc_return == delimit_varn) {break;}
str_for_asc(temp_str, asc_return);
str_cat((tooltips_text.pstring)[0], temp_str);
if (asc_return == -1){errors = 2; break;}
}
if (errors == 1) {str_cpy((tooltips_text.pstring)[0], "File not found");}
if (errors == 2) {str_cpy((tooltips_text.pstring)[0], "Params not found");}
if (errors == 3) {str_cpy((tooltips_text.pstring)[0], "icon = not found");}
file_close(fhandle);
if (_type == TYPE_VAR) {return str_to_num((tooltips_text.pstring)[0]);}
}
...
And init weapons
..
weapon_box[WEAPON_NULL].mdl_name = load_cfg(1, TYPE_TEXT, "wpn_pm.cfg");
P.S. Sorry for my bad english
Last edited by JackShephard; 04/13/08 17:40.