AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting CVAR value (https://forums.alliedmods.net/showthread.php?t=49461)

Drak 01-04-2007 18:37

Setting CVAR value
 
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.

stupok 01-04-2007 18:49

Re: Setting CVAR value
 
I can't decipher what you're trying to accomplish. It doesn't seem to make any sense.

Drak 01-04-2007 19:10

Re: Setting CVAR value
 
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.

XxAvalanchexX 01-04-2007 19:32

Re: Setting CVAR value
 
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.


All times are GMT -4. The time now is 22:27.

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