SetTime: Difference between revisions

From Onset Developer Wiki
m fixed issue with event names not matching between server/client code
No edit summary
Line 6: Line 6:


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|time|Float value between 0 to 24.}}
{{FuncParam|time|Float value between 0.0 and 24.0}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns ''true''.}}


== Example ==
== Example ==

Revision as of 16:26, 17 June 2020

SetTime

Type: Function
Context: Client
Introduced: v1.0

Description

Set the specified time for the client.

Syntax

SetTime(time)

Parameters

  • time
    Float value between 0.0 and 24.0

Return Value

  • Returns true.

Example

-- server side
AddCommand("time", function(player, player_time)
	if player_time == nil then
		return AddPlayerChat(player, "Use /time <0-24>")
	end

	player_time = tonumber(player_time)

	if player_time == nil or player_time < 0 or player_time > 24 then
		return AddPlayerChat(player, "Parameter \"time\" value should be between 0-24")
	end

	CallRemoteEvent(player, "ClientSetTime", player_time)
end)

-- client side
AddRemoteEvent("ClientSetTime", function(time)
	SetTime(time)
end)

See also