Table of Contents

Interface IWorldService

Namespace
SampSharp.Entities.SAMP
Assembly
SampSharp.OpenMp.Entities.dll

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

float

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

modelId int

The model identifier.

position Vector3

The position of the actor.

rotation float

The rotation of the actor.

parent EntityId

The 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

position Vector3

The position of the explosion.

type ExplosionType

The explosion type.

radius float

The 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

min Vector2

The minimum position.

max Vector2

The maximum position.

parent EntityId

The 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

minX float

The minimum x.

minY float

The minimum y.

maxX float

The maximum x.

maxY float

The maximum y.

parent EntityId

The 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

title string

The title of the menu.

position Vector2

The position of the menu.

col0Width float

Width of the left column.

col1Width float?

Width of the right column or null if the menu should only have one column.

parent EntityId

The 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

name string

The name of the created NPC.

parent EntityId

The parent of the entity to be created.

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

modelId int

The model ID.

position Vector3

The position.

rotation Vector3

The rotation.

drawDistance float

The draw distance.

parent EntityId

The 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

model int

The model of the pickup.

type PickupType

The pickup spawn type.

position Vector3

The position where the pickup should be spawned.

virtualWorld int

The virtual world ID of the pickup. Use -1 for all worlds.

parent EntityId

The 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

owner Player

The player that owns this gang zone.

min Vector2

The minimum position.

max Vector2

The maximum position.

parent EntityId

The 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

player Player

The player.

modelId int

The model ID.

position Vector3

The position.

rotation Vector3

The rotation.

drawDistance float

The draw distance.

parent EntityId

The 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

owner Player

The player that owns this pickup.

model int

The model of the pickup.

type PickupType

The pickup spawn type.

position Vector3

The position where the pickup should be spawned.

virtualWorld int

The virtual world ID of the pickup. Use -1 for all worlds.

parent EntityId

The 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

player Player

The player.

position Vector2

The position of the text draw.

text string

The text of the text draw.

parent EntityId

The 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

player Player

The player.

text string

The text.

color Color

The color.

position Vector3

The position.

drawDistance float

The draw distance.

testLos bool

if set to true the line of sight is tested to decide whether the label is drawn.

parent EntityId

The 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

model int

The model of the pickup.

type PickupType

The pickup spawn type.

position Vector3

The position where the pickup should be spawned.

virtualWorld int

The virtual world ID of the pickup. Use -1 for all worlds.

parent EntityId

The 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

type VehicleModelType

The model for the vehicle.

position Vector3

The coordinates for the vehicle.

rotation float

The facing angle for the vehicle.

color1 int

The primary color ID.

color2 int

The secondary color ID.

respawnDelay int

The delay until the car is respawned without a driver in seconds. Using -1 will prevent the vehicle from respawning.

addSiren bool

If true, enables the vehicle to have a siren, providing the vehicle has a horn.

parent EntityId

The 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

position Vector2

The position of the text draw.

text string

The text of the text draw.

parent EntityId

The 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

text string

The text.

color Color

The color.

position Vector3

The position.

drawDistance float

The draw distance.

virtualWorld int

The virtual world.

testLos bool

if set to true the line of sight is tested to decide whether the label is drawn.

parent EntityId

The 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

type VehicleModelType

The model for the vehicle.

position Vector3

The coordinates for the vehicle.

rotation float

The facing angle for the vehicle.

color1 int

The primary color ID.

color2 int

The secondary color ID.

respawnDelay int

The delay until the car is respawned without a driver in seconds. Using -1 will prevent the vehicle from respawning.

addSiren bool

If true, enables the vehicle to have a siren, providing the vehicle has a horn.

parent EntityId

The 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

text string

The text to be displayed.

time int

The duration of the text being shown in milliseconds.

style int

The 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

text string

The text to be displayed.

time TimeSpan

The duration of the text being shown.

style GameTextStyle

The 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

style GameTextStyle

The 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

color Color

The color of the message.

message string

The text that will be displayed.

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

color Color

The color of the message.

messageFormat string

The composite format string of the text that will be displayed (max 144 characters).

args object[]

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

message string

The 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

messageFormat string

The composite format string of the text that will be displayed (max 144 characters).

args object[]

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

killer Player

The player that killer the killee.

killee Player

The player that has been killed.

weapon Weapon

The 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

sender Player

The player which has sent the message.

message string

The message that will be sent.

SetObjectsDefaultCameraCollision(bool)

Allows camera collisions with newly created objects to be disabled by default.

void SetObjectsDefaultCameraCollision(bool disable)

Parameters

disable bool

A value indicating whether camera collision with new objects should be disabled.

SetWeather(int)

Set the weather for all players.

void SetWeather(int weather)

Parameters

weather int

The 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

zone BaseGangZone

The gang zone to configure.

enable bool

true to enable checking; false to disable.