Loading function...

Please make sure JavaScript is enabled. Otherwise you will be unable to see the function documentation.

Returns the amount of time that has passed since the last frame in seconds.

Arguments

None.

Results

Example

Use frame time to move forward at 3 meters per second when a button is pressed, regardless of frame rate.

function main()
	while not SystemIsReady() do
		Wait(0)
	end
	while true do
		if IsButtonPressed(3,0) then
			local h, x, y, z = PedGetHeading(gPlayer), PlayerGetPosXYZ()
			
			-- multiply the distance that we move by the frame time, so we only move that many units per second
			local distance = 3 * GetFrameTime()
			
			PlayerSetPosSimple(x - distance * math.sin(h), y + distance * math.cos(h), z)
		end
		Wait(0)
	end
end

Returns a persistent data table for the current collection. This table is preserved after DSL is reset, and is tied to the name of the current collection.

Arguments

None.

Results

Returns the username set in DSL's main config, or "player" if nothing is set.

Arguments

None.

Results

Returns the value of GetTickCount, primarily intended for use with math.randomseed to improve the random number generator.

Arguments

None.

Results

Runs the same check as PedSetActionNode to determine if a node is both valid and loaded, without actually needing to set the action node.

Arguments

Results

Check if a DSL script is currently running so that you can conditionally make use of features that cannot be used by scripts in Scripts.img.

Arguments

None.

Results

Returns if the game is... paused.

Arguments

None.

Results

Call a function from a native script. The way this is done is by spoofing the game into thinking a certain game script is running, while also temporarily telling DSL that none of its scripts are.

In most cases, this is just as good as actually calling a function from the script in question. The most notable example of that not being the case is with ButtonHistorySetCallbackFailed and its related functions. If you want a simpler way to make this apply to your entire script for a certain function, consider using UseProxyScriptForFunction.

Script should be the name of a native script that is currently running, or a DSL script object. Passing nil instead of any other value will spoof the game into thinking there is no scripts at all. Otherwise, your options will usually consist of main.lua, STimeCycle.lua, the current area script, and the current mission / errand.

If you use this to create something (such as a blip for instance), make sure to delete that something by the time your script ends or it could permanently take up resources in the other script.

Arguments

Results

Versions

DSL5 A DSL script object can be passed for Script to call the function from that script.

Creates a function in the calling environment that will use CallFunctionFromScript to call the function given. Function is presumed to be in the global environment.

For some functions, this can give you a way to make use of things that don't work in DSL. The most notable example is BlipAddXYZ not letting you create ground blips.

Arguments

Results

None.

Example

Add a ground blip in front of the boy's dorm.

UseProxyScriptForFunction("main.lua", "BlipAddXYZ")
UseProxyScriptForFunction("main.lua", "BlipRemove")

gCreatedBlip = -1

function main()
	while not SystemIsReady() do
		Wait(0)
	end
	
	-- since we setup a proxy script for this function, the blip is actually going to be created by main.lua
	gCreatedBlip = BlipAddXYZ(270, -110, 6, 25, 1, 1)
	
end

function MissionCleanup()
	
	-- it is very important we delete the blip ourselves since it doesn't belong to our script, meaning it won't be cleaned up naturally
	if gCreatedBlip ~= -1 then
		BlipRemove(gCreatedBlip)
	end
	
end

Instantly exit the game's process.

Arguments

Results

This function doesn't return.

Forcefully activate the UpdateWindow event to possibly re-style the game's window.

Arguments

None.

Results

None.

Get the game's current internal resolution. You may be looking for GetDisplayResolution instead.

Arguments

None.

Results

Get the size of the primary monitor. Primarily intended for centering the window during the UpdateWindow event.

Arguments

None.

Results