Difference between revisions of "TMap.Spawns"
m (+ Example from AddSpawnPoint) |
Savage0795 (talk | contribs) |
||
Line 4: | Line 4: | ||
==Description== | ==Description== | ||
Array of [[TActiveSpawnPoint]], holding all spawn points on the map.<br> | Array of [[TActiveSpawnPoint]], holding all spawn points on the map.<br> | ||
− | '''Note: it's an array[1.. | + | '''Note: it's an array[1..254], NOT [0..255]. Calling Spawns[0] or Spawns[255] will cause an error''' |
==Example== | ==Example== | ||
Line 19: | Line 19: | ||
Player_X := Players[ID].X; | Player_X := Players[ID].X; | ||
Player_Y := Players[ID].Y; | Player_Y := Players[ID].Y; | ||
− | for i := 1 to | + | for i := 1 to 254 do |
if (Map.SpawnPoints[i].Style = Players[ID].Team) and | if (Map.SpawnPoints[i].Style = Players[ID].Team) and | ||
(Distance(Map.SpawnPoints[i].X,Map.SpawnPoints[i].Y,Player_X,Player_Y) < 50) | (Distance(Map.SpawnPoints[i].X,Map.SpawnPoints[i].Y,Player_X,Player_Y) < 50) |
Revision as of 23:50, 16 June 2018
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;