AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_cvar_num(more than one thing in here?) (https://forums.alliedmods.net/showthread.php?t=48494)

Mini_Midget 12-13-2006 04:20

get_cvar_num(more than one thing in here?)
 
I'm trying to make my zombie mod work with more bot programs so I took a look at some and changed the minimal bots depending on the real players in game.

I was wondering if i could add more cvars in the get_cvar_num() command so i don't have to make so many new variables.
For eg. i wanna do something like
PHP Code:

bot_num get_cvar_num("bot_quota","pb min_bots","jb_minbots"

PHP Code:

public round_start()
{
    new 
player_numbot_numrplayer_num
    player_num 
get_playersnum()
    
bot_num get_cvar_num("bot_quota")
    
rplayer_num player_num bot_num
    
    
if (rplayer_num && rplayer_num 3) {
        
set_cvar_num("min_bots",2)
        
set_cvar_num("bot_quota"2)
        
set_cvar_num("pb min_bots"2)
        
set_cvar_num("jb_botsmin"2)
    }
    if (
rplayer_num && rplayer_num 5) {
        
set_cvar_num("min_bots",3)
        
set_cvar_num("bot_quota"3)
        
set_cvar_num("pb min_bots"3)
        
set_cvar_num("jb_botsmin"3)
    }
    if (
rplayer_num && rplayer_num 7) {
        
set_cvar_num("min_bots",4)
        
set_cvar_num("bot_quota"4)
        
set_cvar_num("pb min_bots"4)
        
set_cvar_num("jb_botsmin"4)
    }
    if (
rplayer_num && rplayer_num 9) {
        
set_cvar_num("min_bots",5)
        
set_cvar_num("bot_quota"5)
        
set_cvar_num("pb min_bots"5)
        
set_cvar_num("jb_botsmin"5)
    }
    if (
rplayer_num && rplayer_num 11) {
        
set_cvar_num("min_bots",6)
        
set_cvar_num("bot_quota"6)
        
set_cvar_num("pb_minbots"6)
        
set_cvar_num("jb_botsmin"6)
    }
    if (
rplayer_num 10 && rplayer_num 13) {
        
set_cvar_num("min_bots",7)
        
set_cvar_num("bot_quota"7)
        
set_cvar_num("pb min_bots"7)
        
set_cvar_num("jb_botsmin"7)
    }
    if (
rplayer_num 12 && rplayer_num 15) {
        
set_cvar_num("min_bots",8)
        
set_cvar_num("bot_quota"8)
        
set_cvar_num("pb min_bots"8)
        
set_cvar_num("jb_botsmin"8)
    }
    if (
rplayer_num 14 && rplayer_num 17) {
        
set_cvar_num("min_bots",9)
        
set_cvar_num("bot_quota"9)
        
set_cvar_num("pb min_bots"9)
        
set_cvar_num("jb_botsmin"9)
    }
    return 
PLUGIN_CONTINUE



jim_yang 12-13-2006 04:51

Re: get_cvar_num(more than one thing in here?)
 
off-topic
Code:
if( 0 < rplayer_num < 17 ) {         new r_num = rplayer_num / 2 + rplayer_num % 2 + 1         set_cvar_num("min_bots", r_num)         set_cvar_num("bot_quota", r_num)         set_cvar_num("pb min_bots", r_num)         set_cvar_num("jb_botsmin", r_num) }

SweatyBanana 12-13-2006 09:28

Re: get_cvar_num(more than one thing in here?)
 
switch statement and set the single cvar to multiple values?

nick123 12-13-2006 12:00

Re: get_cvar_num(more than one thing in here?)
 
get_pcvar_string?

Mini_Midget 12-21-2006 07:16

Re: get_cvar_num(more than one thing in here?)
 
Quote:

Originally Posted by nick123 (Post 414937)
get_pcvar_string?

Can you elaborate on that?
Such as can you show me how to use it as I don't know how to use it what so ever

Simon Logic 12-21-2006 09:37

Re: get_cvar_num(more than one thing in here?)
 
Don't listen to him.

You can get/set only cvars and execute commands. You can't get console output after a command has been executed. If bot plugin does not have interface (i mean cvars to read them), you never detect what the value is.

By the way, "pb min_bots" - is a command.

And after all, you can work with cvars sequentally only: one by one. It a normal and sensible practice of programming. If you wanna minimize your code then store cvar names and commands in array and execute them in loop.

The Specialist 12-21-2006 20:35

Re: get_cvar_num(more than one thing in here?)
 
executing arrays in a loop are extremly CPU exspensive and it is not advised .

http://wiki.amxmodx.org/index.php/Optimizing_Plugins

Hawk552 12-21-2006 20:51

Re: get_cvar_num(more than one thing in here?)
 
Quote:

Originally Posted by The Specialist (Post 418341)
executing arrays in a loop are extremly CPU exspensive and it is not advised .

http://wiki.amxmodx.org/index.php/Optimizing_Plugins

Please stop spreading misinformation.

It's encouraged to use arrays, if you do them properly.

The Specialist 12-21-2006 20:54

Re: get_cvar_num(more than one thing in here?)
 
so you would recomend using an array in a loop ? and whoever wrote that article on wiki is wrong ? :shock:

Hawk552 12-21-2006 20:55

Re: get_cvar_num(more than one thing in here?)
 
Quote:

Originally Posted by The Specialist (Post 418348)
so you would recomend using an array in a loop ? and whoever wrote that article on wiki is wrong right ? :shock:

They're not wrong, you're just not reading it correctly. It didn't say to "not use arrays in loops", it said to "not re-index arrays in loops". That doesn't apply to this, since it's only being used once inside the loop at a time.

I would recommend it, assuming it's implemented correctly.


All times are GMT -4. The time now is 06:52.

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