TMap.AddSpawnPoint

From Soldat Community Wiki
Revision as of 11:34, 22 August 2013 by Mighty (talk | contribs)
Jump to: navigation, search
function AddSpawnPoint(Spawn:TNewSpawnPoint):TActiveSpawnPoint
 Spawn: new spawn to be created.
 Result: activated spawn 

Description

This function will add a new spawnpoint at position X,Y with target style. It will always be active.

Example

Expand with: Example showing AddSpawnPoint

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;