Interface IWorldService
Provides functionality for adding entities to and controlling the SA:MP world.
public interface IWorldService
Properties
Gravity
Gets or sets the gravity.
float Gravity { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Thrown if value is not between -50.0 and 50.0.
Methods
CreateActor(int, Vector3, float, EntityId)
Creates a new actor in the world.
Actor CreateActor(int modelId, Vector3 position, float rotation, EntityId parent = default)
Parameters
modelIdintThe model identifier.
positionVector3The position of the actor.
rotationfloatThe rotation of the actor.
parentEntityIdThe parent of the entity to be created.
Returns
- Actor
The actor component of the newly created entity.
CreateExplosion(Vector3, ExplosionType, float)
Creates an explosion for all players.
void CreateExplosion(Vector3 position, ExplosionType type, float radius)
Parameters
positionVector3The position of the explosion.
typeExplosionTypeThe explosion type.
radiusfloatThe radius of the explosion.
CreateGangZone(Vector2, Vector2, EntityId)
Creates a gang zone in the world.
GangZone CreateGangZone(Vector2 min, Vector2 max, EntityId parent = default)
Parameters
minVector2The minimum position.
maxVector2The maximum position.
parentEntityIdThe parent of the entity to be created.
Returns
- GangZone
The created gang zone.
CreateGangZone(float, float, float, float, EntityId)
Creates a gang zone in the world.
[Obsolete("Deprecated. Use CreateGangZone(Vector2, Vector2, EntityId) instead.")]
GangZone CreateGangZone(float minX, float minY, float maxX, float maxY, EntityId parent = default)
Parameters
minXfloatThe minimum x.
minYfloatThe minimum y.
maxXfloatThe maximum x.
maxYfloatThe maximum y.
parentEntityIdThe parent of the entity to be created.
Returns
- GangZone
The created gang zone.
CreateMenu(string, Vector2, float, float?, EntityId)
Creates the menu in this world.
Menu CreateMenu(string title, Vector2 position, float col0Width, float? col1Width = null, EntityId parent = default)
Parameters
titlestringThe title of the menu.
positionVector2The position of the menu.
col0WidthfloatWidth of the left column.
col1Widthfloat?Width of the right column or null if the menu should only have one column.
parentEntityIdThe parent of the entity to be created.
Returns
- Menu
The created menu.
CreateNpc(string, EntityId)
Creates a new NPC in the world.
Npc CreateNpc(string name, EntityId parent = default)
Parameters
Returns
- Npc
The NPC component of the newly created entity.
Exceptions
- InvalidOperationException
Thrown when the name is already in use or when the NPC open.mp component has not been loaded.
CreateObject(int, Vector3, Vector3, float, EntityId)
Creates an object in the world.
GlobalObject CreateObject(int modelId, Vector3 position, Vector3 rotation, float drawDistance = 0, EntityId parent = default)
Parameters
modelIdintThe model ID.
positionVector3The position.
rotationVector3The rotation.
drawDistancefloatThe draw distance.
parentEntityIdThe parent of the entity to be created.
Returns
- GlobalObject
The created object.
CreatePickup(int, PickupType, Vector3, int, EntityId)
Creates a pickup in the world.
Pickup CreatePickup(int model, PickupType type, Vector3 position, int virtualWorld = -1, EntityId parent = default)
Parameters
modelintThe model of the pickup.
typePickupTypeThe pickup spawn type.
positionVector3The position where the pickup should be spawned.
virtualWorldintThe virtual world ID of the pickup. Use -1 for all worlds.
parentEntityIdThe parent of the entity to be created.
Returns
- Pickup
The created pickup.
CreatePlayerGangZone(Player, Vector2, Vector2, EntityId)
Creates a gang zone logically scoped to a single player. The gang zone is created in the global pool and
bound to the specified owner via SetLegacyPlayer. Use
Show(Player) / Hide(Player) to control per-player visibility.
PlayerGangZone CreatePlayerGangZone(Player owner, Vector2 min, Vector2 max, EntityId parent = default)
Parameters
ownerPlayerThe player that owns this gang zone.
minVector2The minimum position.
maxVector2The maximum position.
parentEntityIdThe parent of the entity to be created.
Returns
- PlayerGangZone
The created player gang zone.
CreatePlayerObject(Player, int, Vector3, Vector3, float, EntityId)
Creates a player object in the world.
PlayerObject CreatePlayerObject(Player player, int modelId, Vector3 position, Vector3 rotation, float drawDistance = 0, EntityId parent = default)
Parameters
playerPlayerThe player.
modelIdintThe model ID.
positionVector3The position.
rotationVector3The rotation.
drawDistancefloatThe draw distance.
parentEntityIdThe parent of the entity to be created.
Returns
- PlayerObject
The created player object.
CreatePlayerPickup(Player, int, PickupType, Vector3, int, EntityId)
Creates a pickup logically scoped to a single player. The pickup is created in the global pool and bound
to the specified owner via SetLegacyPlayer. Per-player visibility (hiding from
other players) is the caller's responsibility through SetHiddenForPlayer(Player, bool).
PlayerPickup CreatePlayerPickup(Player owner, int model, PickupType type, Vector3 position, int virtualWorld = -1, EntityId parent = default)
Parameters
ownerPlayerThe player that owns this pickup.
modelintThe model of the pickup.
typePickupTypeThe pickup spawn type.
positionVector3The position where the pickup should be spawned.
virtualWorldintThe virtual world ID of the pickup. Use -1 for all worlds.
parentEntityIdThe parent of the entity to be created.
Returns
- PlayerPickup
The created player pickup.
CreatePlayerTextDraw(Player, Vector2, string, EntityId)
Creates the player text draw in the world.
PlayerTextDraw CreatePlayerTextDraw(Player player, Vector2 position, string text, EntityId parent = default)
Parameters
playerPlayerThe player.
positionVector2The position of the text draw.
textstringThe text of the text draw.
parentEntityIdThe parent of the entity to be created.
Returns
- PlayerTextDraw
The created player text draw.
CreatePlayerTextLabel(Player, string, Color, Vector3, float, bool, EntityId)
Creates a player text label in the world.
PlayerTextLabel CreatePlayerTextLabel(Player player, string text, Color color, Vector3 position, float drawDistance, bool testLos = true, EntityId parent = default)
Parameters
playerPlayerThe player.
textstringThe text.
colorColorThe color.
positionVector3The position.
drawDistancefloatThe draw distance.
testLosboolif set to true the line of sight is tested to decide whether the label is drawn.
parentEntityIdThe parent of the entity to be created.
Returns
- PlayerTextLabel
The created text label.
CreateStaticPickup(int, PickupType, Vector3, int, EntityId)
Adds a 'static' pickup to the world. These pickups support weapons, health, armor etc., with the ability to function without scripting them (weapons/health/armor will be given automatically).
Pickup CreateStaticPickup(int model, PickupType type, Vector3 position, int virtualWorld = -1, EntityId parent = default)
Parameters
modelintThe model of the pickup.
typePickupTypeThe pickup spawn type.
positionVector3The position where the pickup should be spawned.
virtualWorldintThe virtual world ID of the pickup. Use -1 for all worlds.
parentEntityIdThe parent of the entity to be created.
Returns
- Pickup
The created pickup.
CreateStaticVehicle(VehicleModelType, Vector3, float, int, int, int, bool, EntityId)
Creates a static vehicle in the world.
Vehicle CreateStaticVehicle(VehicleModelType type, Vector3 position, float rotation, int color1, int color2, int respawnDelay = -1, bool addSiren = false, EntityId parent = default)
Parameters
typeVehicleModelTypeThe model for the vehicle.
positionVector3The coordinates for the vehicle.
rotationfloatThe facing angle for the vehicle.
color1intThe primary color ID.
color2intThe secondary color ID.
respawnDelayintThe delay until the car is respawned without a driver in seconds. Using -1 will prevent the vehicle from respawning.
addSirenboolIf true, enables the vehicle to have a siren, providing the vehicle has a horn.
parentEntityIdThe parent of the entity to be created.
Returns
- Vehicle
The created vehicle.
CreateTextDraw(Vector2, string, EntityId)
Creates a text draw in the world.
TextDraw CreateTextDraw(Vector2 position, string text, EntityId parent = default)
Parameters
positionVector2The position of the text draw.
textstringThe text of the text draw.
parentEntityIdThe parent of the entity to be created.
Returns
- TextDraw
The created text draw.
CreateTextLabel(string, Color, Vector3, float, int, bool, EntityId)
Creates a text label in the world.
TextLabel CreateTextLabel(string text, Color color, Vector3 position, float drawDistance, int virtualWorld = 0, bool testLos = true, EntityId parent = default)
Parameters
textstringThe text.
colorColorThe color.
positionVector3The position.
drawDistancefloatThe draw distance.
virtualWorldintThe virtual world.
testLosboolif set to true the line of sight is tested to decide whether the label is drawn.
parentEntityIdThe parent of the entity to be created.
Returns
- TextLabel
The created text label.
CreateVehicle(VehicleModelType, Vector3, float, int, int, int, bool, EntityId)
Creates a vehicle in the world.
Vehicle CreateVehicle(VehicleModelType type, Vector3 position, float rotation, int color1, int color2, int respawnDelay = -1, bool addSiren = false, EntityId parent = default)
Parameters
typeVehicleModelTypeThe model for the vehicle.
positionVector3The coordinates for the vehicle.
rotationfloatThe facing angle for the vehicle.
color1intThe primary color ID.
color2intThe secondary color ID.
respawnDelayintThe delay until the car is respawned without a driver in seconds. Using -1 will prevent the vehicle from respawning.
addSirenboolIf true, enables the vehicle to have a siren, providing the vehicle has a horn.
parentEntityIdThe parent of the entity to be created.
Returns
- Vehicle
The created vehicle.
GameText(string, int, int)
Shows 'game text' (on-screen text) for a certain length of time for all players.
[Obsolete("Use GameText(string, TimeSpan, GameTextStyle) instead.")]
void GameText(string text, int time, int style)
Parameters
textstringThe text to be displayed.
timeintThe duration of the text being shown in milliseconds.
styleintThe style of text to be displayed.
GameText(string, TimeSpan, GameTextStyle)
Shows 'game text' (on-screen text) for a certain length of time for all players.
void GameText(string text, TimeSpan time, GameTextStyle style)
Parameters
textstringThe text to be displayed.
timeTimeSpanThe duration of the text being shown.
styleGameTextStyleThe style of text to be displayed.
HideGameText(GameTextStyle)
Hides the game text in the specified style/slot for all players.
void HideGameText(GameTextStyle style)
Parameters
styleGameTextStyleThe style/slot of the game text to hide.
SendClientMessage(Color, string)
This function sends a message to all players with a chosen color in the chat. The whole line in the chat box will be in the set color unless color embedding is used.
void SendClientMessage(Color color, string message)
Parameters
SendClientMessage(Color, string, params object[])
This function sends a message to all players with a chosen color in the chat. The whole line in the chat box will be in the set color unless color embedding is used.
void SendClientMessage(Color color, string messageFormat, params object[] args)
Parameters
colorColorThe color of the message.
messageFormatstringThe composite format string of the text that will be displayed (max 144 characters).
argsobject[]An object array that contains zero or more objects to format.
SendClientMessage(string)
This function sends a message to all players in white in the chat. The whole line in the chat box will be in the set color unless color embedding is used.
void SendClientMessage(string message)
Parameters
messagestringThe text that will be displayed.
SendClientMessage(string, params object[])
This function sends a message to all players in white in the chat. The whole line in the chat box will be in the set color unless color embedding is used.
void SendClientMessage(string messageFormat, params object[] args)
Parameters
messageFormatstringThe composite format string of the text that will be displayed (max 144 characters).
argsobject[]An object array that contains zero or more objects to format.
SendDeathMessage(Player, Player, Weapon)
Adds a death to the kill feed on the right-hand side of the screen of all players.
void SendDeathMessage(Player killer, Player killee, Weapon weapon)
Parameters
killerPlayerThe player that killer the
killee.killeePlayerThe player that has been killed.
weaponWeaponThe reason for this player's death.
SendPlayerMessageToPlayer(Player, string)
Sends a message in the name the specified sender to all players. The message will appear in the chat box and can be seen by all
player. The line will start with the the sender's name in their color, followed by the message in white.
void SendPlayerMessageToPlayer(Player sender, string message)
Parameters
SetObjectsDefaultCameraCollision(bool)
Allows camera collisions with newly created objects to be disabled by default.
void SetObjectsDefaultCameraCollision(bool disable)
Parameters
disableboolA value indicating whether camera collision with new objects should be disabled.
SetWeather(int)
Set the weather for all players.
void SetWeather(int weather)
Parameters
weatherintThe weather to set.
UseGangZoneCheck(BaseGangZone, bool)
Enables or disables enter/leave checking for the specified zone. When enabled,
IsPlayerInside(Player) returns the live containment state and the gang-zone
enter/leave events fire.
void UseGangZoneCheck(BaseGangZone zone, bool enable)
Parameters
zoneBaseGangZoneThe gang zone to configure.
enablebool