PDA

View Full Version : Problem with my plugin (probably random func)


obiwan
06-14-2010, 12:19
Hey, i have problem with plugin. I wrote a simply plugin which types a message every 30 seconds, but it doesnt work properly.

code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <colorchat>
#include <Vexd_Utilities>

new hostName;
new zapraszamy;

public plugin_init() {


register_cvar("amx_tag", "[cs.obiwanek.pl]")
register_cvar("amx_link", "cs.obiwanek.pl")

set_task(30.0,"spam",_,_,_,"b")

hostName = get_cvar_num("amx_tag")
zapraszamy = get_cvar_num("amx_link")

return PLUGIN_CONTINUE

}


public spam()
{
switch(random(3))
{
case 0: ColorChat(0, RED,"%s^x01 Please visit our site^x04 %s.", hostName, zapraszamy);
case 1: ColorChat(0, RED, "%s^x03 xxxxxxxxxxxxxxxxxxxxxx.", hostName);
case 2: ColorChat(0, BLUE,"%s^x01 xxxxxxxxxxxxxxxxxxxxxxxx", hostName);
}
}


I would like to make it say something like (thats only example)

[cs.obiwanek.pl] Please visit our site cs.obiwanek.pl.

But it says

Please visit our site .


What I did wrong ? Its not full plugin, but i think that's most important.

t3hNox
06-14-2010, 12:28
As you want to return text from these cvars, you should use get_cvar_string (http://www.amxmodx.org/funcwiki.php?search=get_cvar_string&go=search) instead of get_cvar_num.

obiwan
06-14-2010, 13:03
As you want to return text from these cvars, you should use get_cvar_string (http://www.amxmodx.org/funcwiki.php?search=get_cvar_string&go=search) instead of get_cvar_num.

thank you! :D

Alucard^
06-14-2010, 13:31
No, you should use get_pcvar_string( ), USE PCVARS!