I have an nst_wpn old system weapons cso and I want when you type nst_wpn in console on the menu
1 PISTOLS
2 RIFLES
I want to show insteand 2 RIFLES more menu weapons ex: "AUTOMATIC" , "HEAVY" etc like this
1 PISTOLS
2 RIFLES
3 AUTOMATIC
4 HEAVY
etc
So in present the plugin chose what weapons to show in the RIFLES menu from a .ini file that look like this
PISTOLS = ddeagle, infinityss, infinityex2
RIFLES = dualkriss, dmp7a1
and I want to be like this
PISTOLS = ddeagle, infinityss, infinityex2
RIFLES = dualkriss, dmp7a1
AUTOMATIC = dmp7a1, thompson_gold
HEAVY = crossbow, cv47, m1887g
Here is my code where take from the .ini file and put in the RIFLES menu
PHP Code:
// CREATE INI FILE
mywpn_create_ini(run)
{
// Build customization file file_url
new file_url[64]
get_configsdir(file_url, charsmax(file_url))
format(file_url, charsmax(file_url), "%s/%s", file_url, NST_MYWPN_SETTING_FILE)
// File not present
if (!file_exists(file_url))
{
write_file(file_url, "", -1)
return;
}
// Set up some vars to hold parsing info
new linedata[1024], key[64], value[960], i, lineset[1024]
// Open customization file for reading
new file = fopen(file_url, "rt")
while (file && !feof(file))
{
// Read one line at a time
fgets(file, linedata, charsmax(linedata))
// Replace newlines with a null character to prevent headaches
replace(linedata, charsmax(linedata), "^n", "")
// Blank line or comment
if (!linedata[0] || linedata[0] == ';')
{
i++
continue;
}
// Get key and value(s)
strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
// Trim spaces
trim(key)
trim(value)
new name_type[64], typewpn = TYPE_WPN
if (typewpn == NST_WPN_RIFLES)
{
name_type = "RIFLES"
}
else if (typewpn == NST_WPN_PISTOLS)
{
name_type = "PISTOLS"
}
// update weapon
if (equali(key, name_type))
{
// update list weapons
if (run==NST_WPN_INI_SAVE)
{
// get list weapon
new valueset[512]
for (new e=0; e<MAX_MYWPN; e++)
{
if (!g_mywpn[e]) continue;
format(valueset, charsmax(valueset), "%s, %s", valueset, c_model[g_mywpn[e]])
}
// save list weapon
format(lineset, charsmax(lineset), "%s = %s", key, valueset[2])
write_file(file_url, lineset, i)
//client_print(0, print_chat, "da cap nhat xong")
}
// set value for g_mywpn in new round
else if (run==NST_WPN_INI_READ)
{
strtolower(value)
new e
while (e<MAX_MYWPN && value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
{
trim(key)
trim(value)
format(g_mywpn_cache[e], 31, "%s", key)
e++
}
}
}
i++
}
}
I tried here
PHP Code:
new name_type[64], typewpn = TYPE_WPN
if (typewpn == NST_WPN_RIFLES)
{
name_type = "RIFLES"
}
else if (typewpn == NST_WPN_PISTOLS)
{
name_type = "PISTOLS"
}
// update weapon
if (equali(key, name_type))
{
and make it like this =====>
PHP Code:
new name_type[64], name_type2[64], name_type3[64], typewpn = TYPE_WPN
if (typewpn == NST_WPN_RIFLES)
{
name_type = "RIFLES"
name_type2 = "AUTOMATIC"
name_type3 = "HEAVY"
}
else if (typewpn == NST_WPN_PISTOLS)
{
name_type = "PISTOLS"
}
{
And I write 3 times this if(equali) with different name_type/2/3
// update weapon
if (equali(key, name_type))
{
with the same code code is up
}
// update weapon
if (equali(key, name_type2))
{
with the same code, code is up
}
// update weapon
if (equali(key, name_type3))
{
with the same code, code is up
}
But this try was = 0 and everyting is the same and in my menu AUTOMATIC or Heavy are the same weapons like in RIFLES menu...
If anyone is able to take a look of what I am asking here if understand please!
Thank You !