AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Some newbie problems (https://forums.alliedmods.net/showthread.php?t=87666)

SonicSonedit 03-15-2009 04:03

Some newbie problems
 
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.

Zombie Lurker 03-15-2009 05:22

Re: Some newbie problems
 
Quote:

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.
How did your words even happen to turn red?? Its supposed to be white at default isnt it? There must be some script which is wrongly done somewhere.

SonicSonedit 03-15-2009 16:51

Re: Some newbie problems
 
Not words, numbers left to the words.

Left is what i want, Right is what i got
http://xmages.net/out.php/i144898_1.jpeg

fysiks 03-15-2009 17:40

Re: Some newbie problems
 
Dynamic Arrays: I started by looking at mapchooser.sma Follow "g_mapName" for a string example.

Menu: What menu system are you using? Maybe the "new" menu system does it automatically.

minimiller 03-15-2009 18:23

Re: Some newbie problems
 
\r makes the string after it go red
\w makes the string after it go white
\d makes the string after it go grey
\R alligns the menu to the right

fysiks 03-15-2009 18:54

Re: Some newbie problems
 
Quote:

Originally Posted by minimiller (Post 781454)
\r makes the string after it go red
\w makes the string after it go white
\d makes the string after it go grey
\R alligns the menu string after it to the right

:)

SonicSonedit 03-15-2009 19:08

Re: Some newbie problems
 
Quote:

\r makes the string after it go red
\w makes the string after it go white
\d makes the string after it go grey
\R alligns the menu to the right
Quote:

I tried putting \w in menu item strings, but it didn't help.

fysiks
Yes, new menu system.
Is there any way to change it?

Thank you for dynamic arrays hint!

SonicSonedit 03-15-2009 21:01

Re: Some newbie problems
 
Quote:

Is there any way to change it?
Ok, i found the solution)
PHP Code:

menu_setprop(zp_cs_buymenuMPROP_NUMBER_COLOR"\w"); 

The new question - how can i make indentation like this?
http://xmages.net/out.php/i145022_1.jpg

fysiks 03-16-2009 00:10

Re: Some newbie problems
 
"1. 9X19mm Sidearm\R400"

SonicSonedit 03-16-2009 00:56

Re: Some newbie problems
 
Oh, thank you!)

New question - how to block default buymenu?

My buymenu called by player's "buy" command, so for a moment you can see old buymenu...and how to create buyzone entity for the whole map?


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

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