Raised This Month: $ Target: $400
 0% 

My CVAR Problems/and other questions.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Moe
Member
Join Date: Dec 2009
Location: GTA
Old 07-24-2010 , 00:01   My CVAR Problems/and other questions.
Reply With Quote #1

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!!
Moe is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-24-2010 , 00:07   Re: My CVAR Problems/and other questions.
Reply With Quote #2

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

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?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 07-24-2010 at 00:11.
drekes is offline
Send a message via MSN to drekes
Moe
Member
Join Date: Dec 2009
Location: GTA
Old 07-24-2010 , 00:19   Re: My CVAR Problems/and other questions.
Reply With Quote #3

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.
Moe is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-24-2010 , 00:22   Re: My CVAR Problems/and other questions.
Reply With Quote #4

I thought it checked automaticly for that. i'll mess around with it.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-24-2010 , 00:32   Re: My CVAR Problems/and other questions.
Reply With Quote #5

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
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2010 , 00:47   Re: My CVAR Problems/and other questions.
Reply With Quote #6

Don't retrieve the cvar value in plugin_init(). Probably the earliest you should do it is plugin_cfg().
__________________
fysiks is offline
Moe
Member
Join Date: Dec 2009
Location: GTA
Old 07-24-2010 , 01:01   Re: My CVAR Problems/and other questions.
Reply With Quote #7

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.
Moe is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2010 , 01:08   Re: My CVAR Problems/and other questions.
Reply With Quote #8

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.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-24-2010 , 02:50   Re: My CVAR Problems/and other questions.
Reply With Quote #9

Quote:
Originally Posted by Moe View Post
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
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2010 , 19:47   Re: My CVAR Problems/and other questions.
Reply With Quote #10

Quote:
Originally Posted by nikhilgupta345 View Post
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
Adding ADMIN_ALL to the register_clcmd() does not do anything by itself.

About requirig (), I would assume so but you can always test it.

EDIT: Yes, it's required.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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