Raised This Month: $ Target: $400
 0% 

Some newbie problems


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 03-15-2009 , 04:03   Some newbie problems
Reply With Quote #1

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.

Last edited by SonicSonedit; 03-15-2009 at 04:08.
SonicSonedit is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:03.


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