AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Dude with cvar + set_task (https://forums.alliedmods.net/showthread.php?t=189580)

dasha 07-08-2012 16:27

Dude with cvar + set_task
 
hi x_x
How to use text in cvar and print it?

~example;
Quote:

new text

text = register_cvar("cvar_name", "some text here")

ColorChat(id, GREEN, "your text in cvar: %s", get_pcvar_num(text) )
It won't print the text in cvar, i tried with %s, %d, %f and nothing :\
Can someone also tell me the difference betwen the %d, %f and all those symbs? thanks

---edit

How I can set_task with cvar?
like:

new task_time

task_time = register_cvar("cvar_name", "10")

set_task(here the cvar, "etc", id)

Bugsy 07-08-2012 16:37

Re: Dude with cvar + set_task
 
PHP Code:

new szText50 ];
get_pcvar_stringtext szText charsmaxszText ) );
ColorChat(idGREEN"your text in cvar: %s"szText 
..
set_taskget_pcvar_floattask_time ) , "etc"id


dasha 07-08-2012 16:45

Re: Dude with cvar + set_task
 
And how should I register the cvar? coz this way isn't working :|

szText = register_cvar("szText", "some text")
Error: Array must be indexed (variable "szText") on line 86

or

szText[50] = register_cvar("bla", "some text")
Error: Array index out of bounds (variable "szText") on line 86

YamiKaitou 07-08-2012 16:48

Re: Dude with cvar + set_task
 
PHP Code:

text register_cvar("szText""some text")
...
new 
szText50 ];
get_pcvar_stringtext szText charsmaxszText ) );
ColorChat(idGREEN"your text in cvar: %s"szText 


dasha 07-08-2012 16:59

Re: Dude with cvar + set_task
 
Thanks, working well :3

Liverwiz 07-08-2012 17:32

Re: Dude with cvar + set_task
 
just as a note, to avoid this kind of confusion later....when coders prefix variable names with "sz" it means its a string. Check out the tut section for threads about hungarian notation. You'll see it A LOT around here.


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

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