AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Writing more than 1 cvar (https://forums.alliedmods.net/showthread.php?t=26066)

Locks 03-26-2006 12:12

Writing more than 1 cvar
 
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)         }     } }

Sandurr 03-26-2006 12:15

register_cvar()

Locks 03-26-2006 12:24

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

VEN 03-26-2006 12:27

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")

Sandurr 03-26-2006 12:28

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)

Locks 03-26-2006 12:31

Thanks, guys.

VEN 03-26-2006 12:44

Sandurr: your code the same as mine because -1 parameter is by default.

Sandurr 03-26-2006 12:53

ok I didn't know that plus I posted when you were posting so I didn't see your post ;)

v3x 03-26-2006 17:27

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   } }

Twilight Suzuka 03-26-2006 17:29

v3x, speed isn't everything.


All times are GMT -4. The time now is 16:37.

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