Raised This Month: $ Target: $400
 0% 

get_cvar_num(more than one thing in here?)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 12-13-2006 , 04:20   get_cvar_num(more than one thing in here?)
Reply With Quote #1

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

__________________
It's a mystery.
Mini_Midget is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 12-13-2006 , 04:51   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #2

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) }
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>

Last edited by jim_yang; 12-13-2006 at 04:57.
jim_yang is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 12-13-2006 , 09:28   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #3

switch statement and set the single cvar to multiple values?
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
nick123
BANNED
Join Date: Dec 2006
Old 12-13-2006 , 12:00   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #4

get_pcvar_string?
nick123 is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 12-21-2006 , 07:16   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #5

Quote:
Originally Posted by nick123 View Post
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
__________________
It's a mystery.
Mini_Midget is offline
Simon Logic
Senior Member
Join Date: Nov 2006
Location: RF
Old 12-21-2006 , 09:37   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #6

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.
Simon Logic is offline
Send a message via Skype™ to Simon Logic
The Specialist
BANNED
Join Date: Nov 2006
Old 12-21-2006 , 20:35   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #7

executing arrays in a loop are extremly CPU exspensive and it is not advised .

http://wiki.amxmodx.org/index.php/Optimizing_Plugins
The Specialist is offline
Send a message via AIM to The Specialist
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-21-2006 , 20:51   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #8

Quote:
Originally Posted by The Specialist View Post
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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
The Specialist
BANNED
Join Date: Nov 2006
Old 12-21-2006 , 20:54   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #9

so you would recomend using an array in a loop ? and whoever wrote that article on wiki is wrong ?
The Specialist is offline
Send a message via AIM to The Specialist
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-21-2006 , 20:55   Re: get_cvar_num(more than one thing in here?)
Reply With Quote #10

Quote:
Originally Posted by The Specialist View Post
so you would recomend using an array in a loop ? and whoever wrote that article on wiki is wrong right ?
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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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 06:52.


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