TMap.Spawns

From Soldat Community Wiki
Revision as of 00:50, 17 June 2018 by Savage0795 (talk | contribs)
Jump to: navigation, search
property Spawns[ID: Byte]: TActiveSpawnPoint
 Access mode: R

Description

Array of TActiveSpawnPoint, holding all spawn points on the map.
Note: it's an array[1..254], NOT [0..255]. Calling Spawns[0] or Spawns[255] will cause an error

Example

The below example will check whether the player spawned somewhere far off of his team's spawnpoints. If he is too far away, he gets killed to spawn in the right place.

procedure onPlayerRespawn(ID:Byte);
var 
 i:Byte;
 Player_X,
 Player_Y:Single;
begin
 if Players[ID].Human then begin
  Player_X := Players[ID].X;
  Player_Y := Players[ID].Y;
  for i := 1 to 254 do
   if (Map.SpawnPoints[i].Style = Players[ID].Team) and
      (Distance(Map.SpawnPoints[i].X,Map.SpawnPoints[i].Y,Player_X,Player_Y) < 50) 
   then Exit;
 end;
 Players[ID].Damage(ID,200);
 Players[ID].writeConsole('You spawned too far away from your team''s spawnpoint.');
end;