Author Topic: function PlacePlayer(X, Y: single; Name: string; Team: byte): byte;  (Read 2095 times)

0 Members and 1 Guest are viewing this topic.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
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

Code: [Select]
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;

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: function PlacePlayer(X, Y: single; Name: string; Team: byte): byte;
« Reply #1 on: April 18, 2010, 04:00:22 am »
Nice, beats the old PlaceBot(). If only if only you could hide the "X has joined" message and disable invincible timer.


Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: function PlacePlayer(X, Y: single; Name: string; Team: byte): byte;
« Reply #2 on: April 18, 2010, 04:05:08 am »
Nice, beats the old PlaceBot(). If only if only you could hide the "X has joined" message and disable invincible timer.
Yeah, would be awesome :(

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: function PlacePlayer(X, Y: single; Name: string; Team: byte): byte;
« Reply #3 on: April 18, 2010, 04:10:02 am »
Nice, beats the old PlaceBot().
Actually there is one better, but it hasn't been released in any way :P

Gizd Noob! ;D Good work.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: function PlacePlayer(X, Y: single; Name: string; Team: byte): byte;
« Reply #4 on: April 18, 2010, 04:49:50 am »
Actually there is one better, but it hasn't been released in any way :P
Bring it on.