MOH Central

Medal of Honor Series Forum => MOHAA Series: General => Scripting => Topic started by: =[M.A.W]=DoubleKill on January 03, 2016, 10:11:56 AM

Title: Check Teams Script
Post by: =[M.A.W]=DoubleKill on January 03, 2016, 10:11:56 AM
hi all :)

I have been working in a scritp to detect the size of the teams and if how many they are alive or not and i have finish the script now.

Hope will be handy to someone to use if you find some bug tell me so i can fix :)

greetings

Code (cpp) Select


//--------------------INFO-------------------------
//Allies TOTAL: level.allies_total
//Allies DEAD: level.allies_dead <---- This only works if you have something on the server to detect when someone spawn
// like the AdminPro or spawn protection
//Axis TOTAL: level.axis_total
//Axis DEAD: level.axis_dead <---- This only works if you have something on the server to detect when someone spawn
// like the AdminPro or spawn protection
//-----------------------------------------



main:

thread check_players

end

check_players:

level.allies_total = 0
level.allies_dead = 0
level.axis_total = 0
level.axis_dead = 0
level.a = 1
level.b = 1

while(1)
{
wait 0.5

for(local.i = 1;local.i <= $player.size;local.i++)
{
local.player = $player[local.i]

if(local.player == NULL)
end

iprintlnbold local.player.counted

if(local.player.dmteam == "allies" && local.player.counted == NIL)
{

local.player.counted = 1
level.allies_total++

if(local.player.array != 1)
{

level.allies_array[level.a] = $player[local.i]
local.player.array = 1
level.a++
}

}
if(local.player.dmteam == "allies" && local.player.counted == 2)
{

local.player.counted = 1
level.allies_total++
level.axis_total--

if(local.player.array != 1)
{

level.allies_array[level.a] = $player[local.i]
local.player.array = 1
level.a++
}
}

if(local.player.dmteam == "allies" && !isalive local.player && local.player.dead == NIL)
{
local.player.dead = 1
level.allies_dead++
}

if(local.player.dmteam == "allies" && isalive local.player && local.player.dead == 1 && local.player.spawned == 1)
{
local.player.dead = NIL
level.allies_dead--
}

if(local.player.dmteam == "axis" && local.player.counted == NIL)
{
local.player.counted = 2
level.axis_total++

if(local.player.array != 1)
{

level.axis_array[level.b] = $player[local.i]
local.player.array = 1
level.b++
}
}
if(local.player.dmteam == "axis" && local.player.counted == 1)
{
local.player.counted = 2
level.axis_total++
level.allies_total--

if(local.player.array != 1)
{

level.axis_array[level.b] = $player[local.i]
local.player.array = 1
level.b++
}
}
if(local.player.dmteam == "axis" && !isalive local.player && local.player.dead == NIL)
{
local.player.dead = 1
level.axis_dead++
}

if(local.player.dmteam == "axis" && isalive local.player && local.player.dead == 1 && local.player.spawned == 1)
{
local.player.dead = NIL
level.axis_dead--
}

if(local.player.dmteam == "spectator" && local.player.counted == 1)
{
local.player.counted = NIL
level.allies_total--
}
else if(local.player.dmteam == "spectator" && local.player.counted == 2)
{
local.player.counted = NIL
level.axis_total--
}


}
 
//iprintln ("Allies_arr: " + level.allies_array.size)
//iprintln ("Allies_t: " + level.allies_total)
//iprintln ("Axis_arr: " + level.axis_array.size)
//iprintln ("Axis_t: " + level.axis_total)
//iprintln ("Allies_d: " + level.allies_dead)
//iprintln ("Axis_d: " + level.axis_dead)

waitthread allies_array
waitthread axis_array

}

end


allies_array:

level.allies_invalid = 0

for(local.c = 1;local.c <= level.allies_array.size;local.c++)
{

local.allied_player = level.allies_array[local.c]


if(local.allied_player == NULL )
{

level.allies_invalid++
//iprintlnbold "Player dont exist!"
//wait 1
}

}


if(level.allies_invalid > 0)
{
level.allies_total -= level.allies_invalid

for(local.d = 1;local.d <= $player.size;local.d++)
{
local.player = $player[local.d]

if(local.player.dmteam == "allies" && local.player.array == 1)
{

local.player.array = NIL

}
}

level.allies_invalid = 0
level.allies_array = NIL
level.a = 0
}

end

axis_array:

level.axis_invalid = 0

for(local.c = 1;local.c <= level.axis_array.size;local.c++)
{

local.axis_player = level.axis_array[local.c]

if(local.axis_player == NULL )
{

level.axis_invalid++
//iprintlnbold "Player dont exist!"
//wait 1
}

}

if(level.axis_invalid > 0)
{
level.axis_total -= level.axis_invalid

for(local.d = 1;local.d <= $player.size;local.d++)
{
local.player = $player[local.d]

if(local.player.dmteam == "axis" && local.player.array == 1)
{

local.player.array = NIL

}
}

level.axis_invalid = 0
level.axis_array = NIL
level.b = 0

}

end


Title: Re: Check Teams Script
Post by: Cobra {sfx} on January 03, 2016, 10:50:05 AM
Very nice Double, i like the way you debug as you go too, i do similar