AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   My CVAR Problems/and other questions. (https://forums.alliedmods.net/showthread.php?t=133309)

Moe 07-24-2010 00:01

My CVAR Problems/and other questions.
 
This compiles perfectly, but nothing shows up where the cvar's string should be. Not when I put it in server.cfg/amxx.cfg or change it manually. I dont know why. My guess is that the get_cvar_string can't global so it doesnt keep the cvars information.
The problematic code:
PHP Code:

#include <amxmodx>
#include <cstrike>
#define PLUGIN "Server Display"
#define VERSION "3.0"
#define AUTHOR "MoE | -hAbd-"
new website[29]
public 
plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR);
 
register_cvar("sd_website""awebsite");
 
get_cvar_string("sd_website"website28);
}
public 
client_putinserver()

 
set_task(1.0"Displayhud"551__"b");
}
public 
Displayhud()
{
 
set_hudmessage02550, -1.00.006.012.0);
 
show_hudmessage(0"Our Website : %s"website[28]);


My second query is my function headers sometime get errors. For example I'll get Error: Start of function body without function header on line -- and then Warning: Symbol is never used: "Displayhud" on line -- and it makes me incredibly annoyed =P So how do they work? Are their specific guidelines I'm not following? Is it just me and my program that are mentally the odd one out?

Thanks to all who help!! :D

drekes 07-24-2010 00:07

Re: My CVAR Problems/and other questions.
 
PHP Code:

show_hudmessage(0"Our Website : %s"website[28]); 

:arrow:
PHP Code:

show_hudmessage(0"Our Website : %s"website); 

Try that, the way you did it was only showing the last character which i think would be blank
because you say it shows nothing.

EDIT:
It is better to make 1 global task instead of 32 individual tasks.
PHP Code:

#include <amxmodx>
#include <cstrike>
#define PLUGIN "Server Display"
#define VERSION "3.0"
#define AUTHOR "MoE | -hAbd-"
new website[29]
public 
plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR);
 
register_cvar("sd_website""awebsite");
 
get_cvar_string("sd_website"website28);

 
set_task(80.0"Displayhud"___"b");
}

public 
Displayhud()
{
 
set_hudmessage02550, -1.00.006.012.0);
 
show_hudmessage(0"Our Website : %s"website);


I don't know what you mean with the function headers. Could you give an example for that?

Moe 07-24-2010 00:19

Re: My CVAR Problems/and other questions.
 
AWESOME! The "website" worked great! =)
Thanks for the help

How can I make it check the server.cfg/amxx.cfg for the cvar? When I put it in now nothing happens, it only works if I change it in-game.

drekes 07-24-2010 00:22

Re: My CVAR Problems/and other questions.
 
I thought it checked automaticly for that. i'll mess around with it.

drekes 07-24-2010 00:32

Re: My CVAR Problems/and other questions.
 
I tried using pcvars, and it works fine now.

PHP Code:

#include <amxmodx>
#include <cstrike>

#define PLUGIN "Server Display"
#define VERSION "3.0"
#define AUTHOR "MoE | -hAbd-"

new cvar_website;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
cvar_website register_cvar("sd_website""awebsite");
    
    
// get_cvar_string("sd_website", website, 28);
    
    
set_task(80.0"Displayhud"___"b");
}

public 
Displayhud()
{    
    new 
website[29];
    
get_pcvar_string(cvar_websitewebsitecharsmax(website));
    
    
set_hudmessage02550, -1.00.006.012.0);
    
show_hudmessage(0"Our Website : %s"website);


I have the website in amxx.cfg

fysiks 07-24-2010 00:47

Re: My CVAR Problems/and other questions.
 
Don't retrieve the cvar value in plugin_init(). Probably the earliest you should do it is plugin_cfg().

Moe 07-24-2010 01:01

Re: My CVAR Problems/and other questions.
 
Thanks a load man, it works with server.cfg also!

This really helped me out, thanks a load man!

Does this work?
PHP Code:

public plugin_init
{
 
register_clcmd("say /ip""DisplayServerIP");
 
register_clcmd("say /map""DisplayServerMap");
}
public 
DisplayServerIP
{
 
client_print0print_chat"The %s server IP is %s"servernameserverip)
}
public 
DisplayServerMap
{
 
client_print0print_chat"The current map is %s"mapname)


Besides the fact that the variables they're using are non-existent.

Why can't you retrieve the cvar value in plugin initiation? It has worked for me before.

fysiks 07-24-2010 01:08

Re: My CVAR Problems/and other questions.
 
You created and retrieved the cvar at the same time. It's not guaranteed, afaik, that the .cfg will be executed in between the time you create the cvar and retrieve the cvar when they are done right after the other.

Moe 07-24-2010 01:20

Re: My CVAR Problems/and other questions.
 
oh ok I understand now. =P

Does that code work?

nikhilgupta345 07-24-2010 02:50

Re: My CVAR Problems/and other questions.
 
Quote:

Originally Posted by Moe (Post 1249776)
Thanks a load man, it works with server.cfg also!

This really helped me out, thanks a load man!

Does this work?
PHP Code:

public plugin_init
{
 
register_clcmd("say /ip""DisplayServerIP");
 
register_clcmd("say /map""DisplayServerMap");
}
public 
DisplayServerIP
{
 
client_print0print_chat"The %s server IP is %s"servernameserverip)
}
public 
DisplayServerMap
{
 
client_print0print_chat"The current map is %s"mapname)


Besides the fact that the variables they're using are non-existent.

Why can't you retrieve the cvar value in plugin initiation? It has worked for me before.

I think that will work, but what I do is in the register_clcmd, i pass the flags as ADMIN_ALL. So register_clcmd("say /ip", "DisplayServerIP', ADMIN_ALL)

hmm and do u need to put () after declaring a function? idk


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

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