Count number of axis players

Post your scripting questions / solutions here

Moderator: Moderators

strafer
Captain
Posts: 237
Joined: Sat Jan 31, 2004 11:29 pm
Location: The Motherland..
Contact:

Count number of axis players

Post by strafer »

How can I make a script to count the number of axis players that are alive? Also, how can I disable the spawn for a certain team if a certain objective has been completed. This is all for AA.
Image
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post by Phil {sfx} »

Off the top of my head.

Code: Select all

main:

thread body_counter
end

//*****************

body_counter:

while(1)
{
level.allies = 0
level.axis = 0
for(local.i=1;local.i<=$player.size;local.i++)
{
   if($player[local.i].dmteam=="allies")
{
   level.allies++
}
   else if($player[local.i].dmteam=="axis")
{
   level.axis++
                       }
                         }
                           iprintln ("Axis: " + (level.axis))
                           iprintln ("Allied: " + (level.allies))
                           wait 5
                         }
                         end           
That will print the team numbers on the left were game messages are shown every 5 seconds.

EDIT:

oops, forgot about your spawn q,

targetname means your spawns targetname.

$targetname enablespawn & $targetname disablespawn turns them on and off.

I could explain the part about triggering them after a obj, but it will be easier for you to look in obj_team3.scr (Omaha) and see how it is done.
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Something like this will do the job,

Code: Select all

level.axis_in_game =0
level.allies_in_game =0

thread get_player_info

//-----------------
get_player_info:
//-----------------

while(1) // or make a call from a trigger instead of looping
{
 for ( local.i=1 ; local.i <= $player.size ; local.i++ )
  {
    waitthread scan_players $player[local.i]
    waitframe
  }
 waitframe
}
end

//------------------------
scan_players local.player:
//------------------------
  
  local.trigger = spawn trigger_multiple 
  local.trigger.origin = local.player.origin
  waitframe
  waitframe
  waitframe
  local.trigger delete
  
  if(isAlive local.player)
  {
    if ( local.player.dmteam == "axis" )
    {
      level.axis_in_game++
      println "Z------ Axis in game = " level.axis_in_game
     }
    else if ( local.player.dmteam == "allies" )
     {
      level.allies_in_game++
      println "Z------ Allies in game = " level.allies_in_game
     }
   }
end
[/size]
strafer
Captain
Posts: 237
Joined: Sat Jan 31, 2004 11:29 pm
Location: The Motherland..
Contact:

Post by strafer »

Phil {sfx} wrote:Off the top of my head.

Code: Select all

main:

thread body_counter
end

//*****************

body_counter:

while(1)
{
level.allies = 0
level.axis = 0
for(local.i=1;local.i<=$player.size;local.i++)
{
   if($player[local.i].dmteam=="allies")
{
   level.allies++
}
   else if($player[local.i].dmteam=="axis")
{
   level.axis++
                       }
                         }
                           iprintln ("Axis: " + (level.axis))
                           iprintln ("Allied: " + (level.allies))
                           wait 5
                         }
                         end           
That will print the team numbers on the left were game messages are shown every 5 seconds.

EDIT:

oops, forgot about your spawn q,

targetname means your spawns targetname.

$targetname enablespawn & $targetname disablespawn turns them on and off.

I could explain the part about triggering them after a obj, but it will be easier for you to look in obj_team3.scr (Omaha) and see how it is done.
Ok so how do I figure out the targetnames for the spawns? I need to figure this out for a stock map.
Image
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post by Phil {sfx} »

Decompile it with a bsp 2 map prog, and look at them in radiant. (N - brings down the entity menu in rad to check the values, if they have any)

Your be lucky tho if all spawns have targetnames set in stock maps, the ones on omaha have them set cos there used.
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
strafer
Captain
Posts: 237
Joined: Sat Jan 31, 2004 11:29 pm
Location: The Motherland..
Contact:

Post by strafer »

Phil {sfx} wrote:Decompile it with a bsp 2 map prog, and look at them in radiant. (N - brings down the entity menu in rad to check the values, if they have any)

Your be lucky tho if all spawns have targetnames set in stock maps, the ones on omaha have them set cos there used.
Do you know where I can find a bsp to map converter? I searched at mohfiles.com and groundforce1.com and I couldn't find one. I know I have seen one before, but I can't remember where I found it at.
Image
User avatar
At0miC
General
Posts: 1164
Joined: Fri Feb 27, 2004 11:29 pm
Location: The Netherlands

Post by At0miC »

Search for MohBSPToMohMAP on google :wink:
strafer
Captain
Posts: 237
Joined: Sat Jan 31, 2004 11:29 pm
Location: The Motherland..
Contact:

Post by strafer »

Ok I have it converted and opened in MOHRadiant. I pressed N and a little menu popped up with a list of different objects, but it seems to list everything that you find in .pk3 files. It doesn't show the entities.
Image
strafer
Captain
Posts: 237
Joined: Sat Jan 31, 2004 11:29 pm
Location: The Motherland..
Contact:

Post by strafer »

OK. This is what I have done so far:

I made a script that is enabled once a certain amount of objectives have been accomplished. It then takes away the players weapons and gives him noclip. So basically it is like he is in spectator. It then does not count him as being alive. That part works just fine. All I need now is a way to do this to axis players that are dead ONLY. I only know the way to find out if a player is alive. How do I find out if they are dead?
Image
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post by Phil {sfx} »

Just a quick edit of the above script to this should do it for you, I dont know how exactly you want it to work but that should give you the idea of how to do it.

Code: Select all

main:

level.allies_dead = 0 
level.axis_dead = 0 
end


while(1) 
{ 
for(local.i=1;local.i<=$player.size;local.i++) 
{ 
   if($player[local.i].dmteam=="allies") 
{ 
  $player[local.i] waittill death 
  level.allies_dead++ 
} 
   else if($player[local.i].dmteam=="axis") 
{ 
  $player[local.i] waittill death
   level.axis_dead++ 
} 
} 
} 
end     
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
strafer
Captain
Posts: 237
Joined: Sat Jan 31, 2004 11:29 pm
Location: The Motherland..
Contact:

Post by strafer »

Sorry. I forgot to post an update. :oops:

I figured out how to figure out if they are dead. 8-)

What another guy and I are trying to figure out is how to disable the spawn for the axis only on an objective map. Like on SH TOW if the spawn was destroyed, they can no longer respawn. Yes, I looked at the script on SH, but couldn't find the script to not allow the players to respawn. :(
Image
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post by agentmad007 »

lol strafer i did too .

thats really weird there

if objective1 Takeover

iprintln " allies cant respanw" or somethink like that.

something similar.......


But i did not find how to disable the spawn even in tow_dm.scr!
Deadly and slient.
strafer
Captain
Posts: 237
Joined: Sat Jan 31, 2004 11:29 pm
Location: The Motherland..
Contact:

Post by strafer »

agentmad007 wrote:lol strafer i did too .

thats really weird there

if objective1 Takeover

iprintln " allies cant respanw" or somethink like that.

something similar.......


But i did not find how to disable the spawn even in tow_dm.scr!
It may just be a SH map script...no idea. :oops:
Image
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Takeover, setcurrent etc are set in the map bsp in SH.
TOW maps have control nodes and targets for triggers etc, ie; if a trigger is set it will update the setcurrent id to =1 or =0 depending on the team. Look in the SH sdk docs, there is a tute for TOW maps.
To enable - disable specific spawns then those spawns need to have a targetname so they can be controlled from script.
The other way I know of is to add right at the very top of your scr above main: new info_player_allied or axis spawn locations of the same number of original ones. Some players might still spawn in the old locations but most will spawn at the new ones. These new spawns can have targetnames that can be enabled/disabled in your scr..
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

They didn't give the spawnpoints targetnames in all of the stock maps so that won't help you . Also instead of decompileing the maps just open the bsp in notepad or wordpad and do a find for info_player_allied or info_player_axis it will be in the bsp in text form so you can tell if they have targetnames or not .
Image
Post Reply