condition based on how many clients?
Moderator: Moderators
condition based on how many clients?
Is it possible to make a condition or case statement based on number of clients on the server? How could i do something Like this -
if total_clients is = or < 6 then
play version 1
if total_clients is > 6 and < 15 then
play version 2
if total_clients is > 14 then
play version 3
if total_clients is = or < 6 then
play version 1
if total_clients is > 6 and < 15 then
play version 2
if total_clients is > 14 then
play version 3
Hello,
maybe like this
[/color]
maybe like this
Code: Select all
if ($player.size <= 6)
{
blablabla
}
if (($player.size > 6) && ($player.size < 15))
{
blablabla
}
if ($player.size >= 15)
{
blablabla
}
enddifficulty
Check out this old thread.
http://dynamic.gamespy.com/~map/mohaa/f ... difficulty
It has threads used to remove bots depending on how many allied players there were in the game. You can change it to also count the number of axis and spectators.
There was also a difficulty section added to the script of "gotterdammerung"--it is on my web page (click on my logo below).
http://dynamic.gamespy.com/~map/mohaa/f ... difficulty
It has threads used to remove bots depending on how many allied players there were in the game. You can change it to also count the number of axis and spectators.
There was also a difficulty section added to the script of "gotterdammerung"--it is on my web page (click on my logo below).
Ah blah, ERROR: Command Overflow: Possible Infinate loop in my brain.
like this then
like this then
Code: Select all
count:
while(1)
{
level.allies = 0
level.axis = 0
level.spectator = 0
for(local.dude=1;local.dude <= $player.size;local.dude++)
{
if ($player[local.dude].dmteam == "axis")
level.axis++
if ($player[local.dude].dmteam == "allies")
level.allies++
if ($player[local.dude].dmteam == "spectator")
level.spectator++
}
if (level.allies + level.axis + level.spectator <= 6)
{
blabla
}
if ((level.allies + level.axis + level.spectator > 6) && (level.allies + level.axis + level.spectator < 15))
{
blabla
}
if (level.allies + level.axis + level.spectator >= 15)
{
blabla
}
wait 2
}
endTY guys, i've been working with this (Richards last post). it works for the first condition , but something wierd happens when the second condition occurs.
I think both scripts (cond 1 and 2) are being executed? maybe has something to do with the server trying to run the thread before or while people are still entering the server and gets confused.
I need to think about this. maybe i need to level counts at the end of each map rather than the beginning
I think both scripts (cond 1 and 2) are being executed? maybe has something to do with the server trying to run the thread before or while people are still entering the server and gets confused.
I need to think about this. maybe i need to level counts at the end of each map rather than the beginning
ok, i run this in my messages scr that runs in all my maps, so theoretically it should be counting every 30 seconds and setting the value for totalpeeps every 30 seconds. The counting message is posted every 30 but totalpeeps value does not seem to change
Can someone tell me whats not happening?
i can set totalpeeps with console and the switch statement that bdbodger wrote will select the proper mod version at map restart or next map rotation.
Code: Select all
messages:
local.totalpeeps = (int(getcvar totalpeeps))
thread count
wait 100
iprintln ("The War Legends Server , Visit us at www.thewarlegends.com")
wait 900
iprintln ("We run custom maps, get the map paks at thewarlegends.com")
end
count:
wait 30
thread countpeeps
goto count
countpeeps:
iprintln ("counting")
while(1)
{
level.allies = 0
level.axis = 0
level.spectator = 0
for(local.dude=1;local.dude <= $player.size;local.dude++)
{
if ($player[local.dude].dmteam == "axis")
level.axis++
if ($player[local.dude].dmteam == "allies")
level.allies++
if ($player[local.dude].dmteam == "spectator")
level.spectator++
}
if (level.allies + level.axis + level.spectator <= 6)
{
local.totalpeeps = 1
}
if ((level.allies + level.axis + level.spectator > 6) && (level.allies + level.axis + level.spectator < 15))
{
local.totalpeeps = 2
}
if (level.allies + level.axis + level.spectator >= 15)
{
local.totalpeeps = 3
}
wait 2
}
endi can set totalpeeps with console and the switch statement that bdbodger wrote will select the proper mod version at map restart or next map rotation.
if you want local.totalpeeps to be sent back to the message thread you can do it like this
local.totalpeeps = waitthread countpeeps
countpeeps:
....
....
end local.totalpeeps
You see in the first line that it waits for an answer from the thread and at the bottom the local.totalpeeps after the word end sends back that answer
The way you have it even if you run the messages thread every 30 seconds you used local.totalpeeps = (int(getcvar totalpeeps)) but you don't seem to have set the cvar to the new number anywhere you can do it that way too by putting this in the last thread
setcvar totalpeeps local.totalpeeps
I don't think you need the count thread every time the count thread is run it starts a new instance of the countpeeps: thread so every 30 seconds you hava a new instance of the countpeeps: thread after about 5 minutes you will have 10 instances of the countpeeps: thread running at the same time . I would put a while loop with a 30 second wait in the message thread to print your message every 30 seconds and use the example I put at the top also take the while loop out of the countpeeps: thread . I don't see the need for a cvar at all for this .
local.totalpeeps = waitthread countpeeps
countpeeps:
....
....
end local.totalpeeps
You see in the first line that it waits for an answer from the thread and at the bottom the local.totalpeeps after the word end sends back that answer
The way you have it even if you run the messages thread every 30 seconds you used local.totalpeeps = (int(getcvar totalpeeps)) but you don't seem to have set the cvar to the new number anywhere you can do it that way too by putting this in the last thread
setcvar totalpeeps local.totalpeeps
I don't think you need the count thread every time the count thread is run it starts a new instance of the countpeeps: thread so every 30 seconds you hava a new instance of the countpeeps: thread after about 5 minutes you will have 10 instances of the countpeeps: thread running at the same time . I would put a while loop with a 30 second wait in the message thread to print your message every 30 seconds and use the example I put at the top also take the while loop out of the countpeeps: thread . I don't see the need for a cvar at all for this .
Ok I missed that so that changes things. What you need to do is take the while loop out of the countpeeps: because the count thread is doing the looping every 30 seconds then puti can set totalpeeps with console and the switch statement that bdbodger wrote will select the proper mod version at map restart or next map rotation.
setcvar totalpeeps local.totalpeeps
at the end of the countpeeps: thread to set the cvar I was thinking this was a looping message thread.
ok here is my people counter. I exec this with a global .scr from each map. It counts the number of clients on the server every minute and keeps that value in "totalpeeps". Then - totalpeeps is used at map load to choose the appropriate mod for that number of people.
Question - Does this use enough computing resources that i should think about running it less frequentley? or is it not even worth the worry?
I don't know. I suppose if i had to it could still be pretty accurate every 5 mins.
Question - Does this use enough computing resources that i should think about running it less frequentley? or is it not even worth the worry?
I don't know. I suppose if i had to it could still be pretty accurate every 5 mins.
Code: Select all
countpeeps:
local.totalpeeps = (int(getcvar totalpeeps))
thread countloop
wait 15
iprintln ("Count activated")
end
countloop:
wait 59
thread peepscounter
goto countloop
peepscounter:
level.allies = 0
level.axis = 0
level.spectator = 0
for(local.dude=1;local.dude <= $player.size;local.dude++)
{
if ($player[local.dude].dmteam == "axis")
level.axis++
if ($player[local.dude].dmteam == "allies")
level.allies++
if ($player[local.dude].dmteam == "spectator")
level.spectator++
}
if (level.allies + level.axis + level.spectator <= 1)
{
local.totalpeeps = 1
}
if (level.allies + level.axis + level.spectator == 2)
{
local.totalpeeps = 2
}
if (level.allies + level.axis + level.spectator == 3)
{
local.totalpeeps = 3
}
if (level.allies + level.axis + level.spectator == 4)
{
local.totalpeeps = 4
}
if (level.allies + level.axis + level.spectator == 5)
{
local.totalpeeps = 5
}
if (level.allies + level.axis + level.spectator == 6)
{
local.totalpeeps = 6
}
if (level.allies + level.axis + level.spectator == 7)
{
local.totalpeeps = 7
}
if (level.allies + level.axis + level.spectator == 8)
{
local.totalpeeps = 8
}
if (level.allies + level.axis + level.spectator == 9)
{
local.totalpeeps = 9
}
if (level.allies + level.axis + level.spectator == 10)
{
local.totalpeeps = 10
}
if (level.allies + level.axis + level.spectator == 11)
{
local.totalpeeps = 11
}
if (level.allies + level.axis + level.spectator == 12)
{
local.totalpeeps = 12
}
if (level.allies + level.axis + level.spectator == 13)
{
local.totalpeeps = 13
}
if (level.allies + level.axis + level.spectator == 14)
{
local.totalpeeps = 14
}
if (level.allies + level.axis + level.spectator == 15)
{
local.totalpeeps = 15
}
if (level.allies + level.axis + level.spectator == 16)
{
local.totalpeeps = 16
}
if (level.allies + level.axis + level.spectator == 17)
{
local.totalpeeps = 17
}
if (level.allies + level.axis + level.spectator == 18)
{
local.totalpeeps = 18
}
if (level.allies + level.axis + level.spectator == 19)
{
local.totalpeeps = 19
}
if (level.allies + level.axis + level.spectator >= 20)
{
local.totalpeeps = 20
}
wait 1
setcvar totalpeeps local.totalpeeps
endIf you are counting every body you don't need to do this
$player.size gives you the number of players and your way won't work for free for all games . I mean if a player isn't axis,allies or spectator what are they? Won't this do the same thing ?for(local.dude=1;local.dude <= $player.size;local.dude++)
{
if ($player[local.dude].dmteam == "axis")
level.axis++
if ($player[local.dude].dmteam == "allies")
level.allies++
if ($player[local.dude].dmteam == "spectator")
level.spectator++
}
That would replace your whole thread if you are not useing 0 that is other wisepeepscounter:
if($player.size > 0)
setcvar totalpeeps $player.size
else
setcvar totalpeeps 1
end
will work if you are useing 0 as a numberpeepscounter:
setcvar totalpeeps $player.size
end

