AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting cvar's num (https://forums.alliedmods.net/showthread.php?t=164774)

dreamedward 08-15-2011 15:51

Getting cvar's num
 
Hello, guys!
So I have a menu and some cvars. I was wondering how can the text in the menus get_pcvar_num(mycvar).

Here is what I want:
menu_additem(menu, "\wMoney Cost - %s$", "1", 0);
I tried with
menu_additem(menu, "\wMoney Cost - %s$", "1", 0, get_pcvar_num(mycvar));
but it didnt compile. Help please!

Nyuszy 08-15-2011 15:53

Re: Getting cvar's num
 
new temp[65]
formatex(temp, 64, "\wMoney Cost - %s$", get_pcvar_num(mycvar))
menu_additem(menu, temp, "1", 0)

dreamedward 08-15-2011 17:20

Re: Getting cvar's num
 
Thanks man!

Hunter-Digital 08-16-2011 22:15

Re: Getting cvar's num
 
Use %d for numbers ! %s is for strings, %f for float, and search for the rest if you're curious.

Also, if you want to know if a function accepts format parameters, search it on funcwiki and see it's accepted arguments, usually indicated by "..." like here: http://www.amxmodx.org/funcwiki.php?go=func&id=22

fysiks 08-16-2011 22:16

Re: Getting cvar's num
 
I like to search for "printf" @ cplusplus.com for a general reference. I do the same for fopen too.


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

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