Author: Gizd
Core Version: 2.6.5
Places player or bot on a position on map. Respawns player if he's dead.
Result is ID of spawned bot and it should be the ID of moved player.
Name: "% <id>" to move existing player(including bots), "<bot name>" to place a new bot
X, Y: coordinates
Team: team to move player to
function PlacePlayer(X, Y: single; Name: string; Team: byte): byte;
var
Act: array[1..254] of byte;
c, i, Sb: byte;
Xb, Yb: single;
Ab: boolean;
begin
c:= 0;
for i:= 1 to 254 do if GetSpawnStat(i,'Style') = Team then if GetSpawnStat(i,'Active') then begin
c:= c + 1;
Act[c]:= i;
SetSpawnStat(i,'Active',false);
end;
Sb:= GetSpawnStat(254,'Style');
Xb:= GetSpawnStat(254,'X');
Yb:= GetSpawnStat(254,'Y');
Ab:= GetSpawnStat(254,'Active');
SetSpawnStat(254,'Style',Team);
SetSpawnStat(254,'X',X);
SetSpawnStat(254,'Y',Y);
SetSpawnStat(254,'Active',true);
if RegExpMatch('^% \d+$',Name) then Name:= '/setteam' + IntToStr(Team) + ' ' + GetPiece(Name,' ',1) else
Name:= '/addbot' + IntToStr(Team) + ' ' + Name;
result:= Command(Name);
SetSpawnStat(254,'Style',Sb);
SetSpawnStat(254,'X',Xb);
SetSpawnStat(254,'Y',Yb);
SetSpawnStat(254,'Active',Ab);
if c > 0 then for i:= 1 to c do SetSpawnStat(Act[i],'Active',true);
end;