Hello everyone, i'm trying to make this plugin
http://forums.alliedmods.net/showthread.php?t=87586
And so far, i encounted some problems:
The idea of plugin is in one cfg file user sets amount of pistols, shotguns, rifles, e.t.c., sold in sub-buymenu, then, in another cfg file he sets their names, price and command to execute when item is bought (so this menu can support other plugins, like bazooka), plugin reads it all and build menu up.
So the first problem is CVAR...
Code:
public plugin_init()
{
cvar_zp_cs_buymenu_pistol_count = register_cvar("zp_cs_buymenu_pistol_count", "5");
register_plugin(PLUGIN,VERSION,AUTHOR);
register_clcmd("amx_buy", "clcmd_zp_cs_buymenu");
new cfgdir[64];
get_configsdir(cfgdir, sizeof cfgdir - 1);
server_print("[zp_cs_buymenu] Executing: %s/zp_cs_buymenu.cfg",cfgdir);
server_cmd("exec %s/zp_cs_buymenu.cfg", cfgdir);
server_print("[zp_cs_buymenu] Pistols found: %d",get_pcvar_num(cvar_zp_cs_buymenu_pistol_count));
}
Config file has:
Code:
zp_cs_buymenu_pistol_count 3213
Config file is being executed (checked it), but server always says "Pistols found: 5", well, or if i'll make
Code:
register_cvar("zp_cs_buymenu_pistol_count", "1");
the server will say "Pistols found: 1" - can anyone tell me, why does variable value wasn't read from cfg?
The second problem - zp_cs_buymenu_pistol_count determines array size for zp_cs_buymenu_pistol_name[], zp_cs_buymenu_pistol_cost[], and zp_cs_buymenu_pistol_id[]. I tried:
Code:
new zp_cs_buymenu_pistol_name[cvar_zp_cs_buymenu_pistol_count];
and got:
Quote:
Welcome to the AMX Mod X 1.76-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team
Error: Must be a constant expression; assumed zero on line 35
Error: Invalid array size (negative or zero) on line 35
Error: Empty statement on line 35
Error: Too many error messages on one line on line 35
Compilation aborted.
4 Errors.
Could not locate output file D:\Temp\2\cstrike\addons\amxmodx\plugins\zp_o riginal_cs_buymenu.amx (compile failed).
|
How can i make a dynamic array in amxx?
And the last thing - how can i make white, not red, numbers left to menu items? I tried puttin \w in menu item string, but it didn't help.