Raised This Month: $ Target: $400
 0% 

Writing more than 1 cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Locks
Senior Member
Join Date: Sep 2005
Old 03-26-2006 , 12:12   Writing more than 1 cvar
Reply With Quote #1

How do I make this write more than 1 cvar into a .CFG?

Ive tried this and it wont work.
Code:
public ExecCvars() {     if(get_cvar_num("kz_on") && get_cvar_num("kz_management"))     {         new szConfigsdir[50],szLocation[50]         get_configsdir(szConfigsdir,49)         format(szLocation,49,"%s/kz.cfg",szConfigsdir)         if(file_exists(szLocation))             server_cmd("exec %s",szLocation)         else         {             write_file(szLocation,"mp_autoteambalance 0",0)             write_file(szLocation,"mp_limitteams 99",0)             server_cmd("exec %s",szLocation)         }     } }
Locks is offline
Sandurr
Senior Member
Join Date: Aug 2005
Old 03-26-2006 , 12:15  
Reply With Quote #2

register_cvar()
Sandurr is offline
Locks
Senior Member
Join Date: Sep 2005
Old 03-26-2006 , 12:24  
Reply With Quote #3

Im talking about this part
Code:
            write_file(szLocation,"mp_autoteambalance 0",0)             write_file(szLocation,"mp_limitteams 99",0)

It only writes mp_limitteams 99 into the .CFG
it wont write the mp_autoteambalance 0
Locks is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-26-2006 , 12:27  
Reply With Quote #4

Do not use 0 parameter if you want do that.
0 is a line number (i.e first line)

Code:
write_file(szLocation,"mp_autoteambalance 0") write_file(szLocation,"mp_limitteams 99")
VEN is offline
Sandurr
Senior Member
Join Date: Aug 2005
Old 03-26-2006 , 12:28  
Reply With Quote #5

Replace:

Code:
            write_file(szLocation,"mp_autoteambalance 0",0)             write_file(szLocation,"mp_limitteams 99",0)

With:

Code:
            write_file(szLocation,"mp_autoteambalance 0",-1)             write_file(szLocation,"mp_limitteams 99",-1)
Sandurr is offline
Locks
Senior Member
Join Date: Sep 2005
Old 03-26-2006 , 12:31  
Reply With Quote #6

Thanks, guys.
Locks is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-26-2006 , 12:44  
Reply With Quote #7

Sandurr: your code the same as mine because -1 parameter is by default.
VEN is offline
Sandurr
Senior Member
Join Date: Aug 2005
Old 03-26-2006 , 12:53  
Reply With Quote #8

ok I didn't know that plus I posted when you were posting so I didn't see your post ;)
Sandurr is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-26-2006 , 17:27  
Reply With Quote #9

Yay for speeeeeeeeed!

Code:
#include <amxmodx> new g_MyCvar; public plugin_init() {   //   g_MyCvar = register_cvar("my_cvar" , "1"); } public my_func() {   if(get_pcvar_num(g_MyCvar))   {     // :o   } }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-26-2006 , 17:29  
Reply With Quote #10

v3x, speed isn't everything.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
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 16:37.


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