Difference between revisions of "TMap.AddObject"

From Soldat Community Wiki
Jump to: navigation, search
m
m
 
Line 28: Line 28:
 
begin
 
begin
 
   if Text = 'Medic!' then
 
   if Text = 'Medic!' then
     SpawnMedkit(p.X,p.Y);
+
     SpawnMedkit(p.X,p.Y);z
 
end;
 
end;
  
Line 35: Line 35:
 
     Players[i].OnSpeak := @MyOnSpeak;
 
     Players[i].OnSpeak := @MyOnSpeak;
 
end.
 
end.
 +
</syntaxhighlight>
 +
 +
==Constants==
 +
Global constants with object types.
 +
<syntaxhighlight lang="pascal">
 +
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
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:TMap]]
 
[[Category:TMap]]

Latest revision as of 17:00, 22 January 2016

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