Raised This Month: $ Target: $400
 0% 

Setting CVAR value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Drak
Veteran Member
Join Date: Jul 2005
Old 01-04-2007 , 18:37   Setting CVAR value
Reply With Quote #1

Code:
public CheckFile() {     if(!get_pcvar_num(dynamic)) return PLUGIN_HANDLED;         new szFile[64]     get_configsdir(szFile,sizeof(szFile))     trim(szFile)     format(szFile , 63 , "%s/dynamic.ini",szFile)         if(!file_exists(szFile)) {         server_print("[AMXX] Dynamic config file not found!^nCreating...")         //log_amx("[AMXX] Dynamic config file not found, Created!")         write_file(szFile,NEW_FILE);            }         new info_month[8],info_date[8],info_cvar[8],info_command[33],info_extra[8]     new readdata[200],txtlen         new str_month     new str_date         new fsize = file_size(szFile,1)         for(new line = 0; line <= fsize; line++) {         read_file(szFile,line+1,readdata,199,txtlen)                 //Format: #month #date "command" "extra"         parse(readdata,info_month,7,info_date,7,info_command,32,info_extra,7)                 str_month = str_to_num(info_month)         str_date = str_to_num(info_date)                 server_command(info_command,str_month,str_date,info_extra);     }     return PLUGIN_HANDLED } public server_command(command[],file_month,file_date,extra[]) {     if(!get_pcvar_num(dynamic)) return PLUGIN_HANDLED;         get_time("%d",server_date,9) //date     get_time("%m",server_month,9) //month         new g_month = str_to_num(server_month)     new g_date = str_to_num(server_date)         if(equali(extra,"cvar")) {         if(g_month || g_date == file_month || file_date) {             server_cmd(command) //Don't use SERVER_CMD?             //set_cvar_num(command)         }     }     else     {         if(g_month || g_date == file_month || file_date) {             server_cmd(command)             //Set Non-Cvar         }     }     return PLUGIN_HANDLED }
What i'm trying todo, is that there's a value being past threw the command(server_command function) section, now it's sometimes a value or a string (Reading from file), how can I make it so it reads if it's a value or a string and set the correct cvar value/string? I also realized that i'm using the old way of reading/writing files.

Last edited by Drak; 01-04-2007 at 19:11.
Drak is offline
Send a message via MSN to Drak
stupok
Veteran Member
Join Date: Feb 2006
Old 01-04-2007 , 18:49   Re: Setting CVAR value
Reply With Quote #2

I can't decipher what you're trying to accomplish. It doesn't seem to make any sense.
stupok is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 01-04-2007 , 19:10   Re: Setting CVAR value
Reply With Quote #3

I figured D: I'll just re-explane it, it reads a command from a file. I want to know if that command is a cvar string or a value, example:
"sv_cheats 1" Wouldn't this be a cvar value?
"hostname Server #1" Wouldn't this be a cvar string?
Now if the file reads "hostname Server #1" how do i get that to set? I realize server_cmd works, but the wiki says that's a bad way of setting it.
Drak is offline
Send a message via MSN to Drak
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-04-2007 , 19:32   Re: Setting CVAR value
Reply With Quote #4

Use strbreak to separate the cvar name from its value. Then, most likely, you can simply use set_cvar_string whether the value is int, float, or string, since the cvar will still be retrieved by the game under the correct type.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 22:27.


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