TMap.AddObject

From Soldat Community Wiki
Jump to: navigation, search
function AddObject(Obj: TNewMapObject):TActiveMapObject
 Obj: new object to be placed on the map
 Result: newly created object

Description

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

Example

The below example will spawn a medkit on the players position whenever he types "Medic!"

var
  i: integer;

procedure SpawnMedkit(posx,posy: single);
var temp: TNewMapObject;
begin
  temp := TNewMapObject.Create; 
  temp.X := posx;
  temp.Y := posy;
  temp.Style := 16; // medkit
  Map.AddObject(temp);
  temp.Free; // IMPORTANT!
end;

procedure MyOnSpeak(p: TActivePlayer; Text: string);
begin
  if Text = 'Medic!' then
    SpawnMedkit(p.X,p.Y);z
end;

begin
  for i:=1 to 32 do
    Players[i].OnSpeak := @MyOnSpeak;
end.

Constants

Global constants with object types.

OBJECT_ALPHA_FLAG   
OBJECT_BRAVO_FLAG
OBJECT_POINTMATCH_FLAG
OBJECT_USSOCOM
OBJECT_DESERT_EAGLE
OBJECT_HK_MP5
OBJECT_AK74
OBJECT_STEYR_AUG
OBJECT_SPAS12
OBJECT_RUGER77
OBJECT_M79
OBJECT_BARRET_M82A1
OBJECT_MINIMI
OBJECT_MINIGUN
OBJECT_RAMBO_BOW
OBJECT_MEDICAL_KIT
OBJECT_GRENADE_KIT
OBJECT_FLAMER_KIT
OBJECT_PREDATOR_KIT
OBJECT_VEST_KIT
OBJECT_BERSERK_KIT
OBJECT_CLUSTER_KIT
OBJECT_PARACHUTE
OBJECT_COMBAT_KNIFE
OBJECT_CHAINSAW
OBJECT_LAW
OBJECT_STATIONARY_GUN