Page cover image

๐Ÿ•น๏ธGame Rules

These rules will work permanently for the duration of the mission (it doesn't matter if you did it in the first stage, it will continue until the last one if you don't cancel them).

How's work

The rules are as they describe the word, if the player breaks them, he can select his punishment, from finishing the mission or sending him a message to comply with it. (How to make a counter that if it ends you lose the mission)

GameRules.VehicleCanNotBeDestroyed()

This function creates a thread that continuously checks if a specified vehicle still exists and has health greater than 0. If the vehicle is destroyed, the onDestroy function is called.

GM().GameRules.VehicleCanNotBeDestroyed(vehicle, onDestroy)

Example

local playerVehicle = GetVehiclePedIsIn(PlayerPedId())

GM().GameRules.VehicleCanNotBeDestroyed(playerVehicle, function()
    --- Boom!
    -- This functions acts when vehicle is destroyed.
    GM().EndGame(true, "Vehicle destroyed")
end)

GameRules.PlayerMustBeInArea()

This rule states that the player MUST stay in the area.

GameRules.PlayerMustBeInVehicle()

This rule states that the player MUST be stabilized in a vehicle and in a defined holding position.

GameRules.PlayerInVehicleMustRespectSpeedLimit()

This rule is flexible, since it indicates that the player must respect an adequate speed, that is, he must not exceed it. (Taxi? Chase missions?)

GameRules.CancelRule()

This function is used to cancel or remove a specific rule that has been previously set up using the ruleName. Different rule names correspond to different types of rules that can be canceled.

GM().GameRules.CancelRule(ruleId, params...)

Example

-- Cancel the "PlayerMustBeInArea" rule with the zoneId "missionArea"
GM().GameRules.CancelRule("PlayerMustBeInArea", "missionArea")

-- Cancel the "PlayerMustBeInVehicle" rule for a specific vehicle entity
GM().GameRules.CancelRule("PlayerMustBeInVehicle", vehicle)

-- Cancel the "PlayerInVehicleMustRespectSpeedLimit" rule
GM().GameRules.CancelRule("PlayerInVehicleMustRespectSpeedLimit")

Last updated

Was this helpful?