SetTime: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|SetTime(time)}} {{FuncParameters}} {{FuncParam|time|__EDIT_ME__}} {{FuncReturnValue|__EDIT_ME__}}..." |
No edit summary |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Client|1.0}} | {{Info|Function|Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Set the specified time for the client.}} | ||
{{FuncSyntax|SetTime(time)}} | {{FuncSyntax|SetTime(time)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|time| | {{FuncParam|time|Float value between 0.0 and 24.0}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns '''true'''.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua> | |||
-- 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) | |||
</syntaxhighlight> | |||
Early morning: | |||
[[File:LightingMorning.jpg|700px]] | |||
Noon: | |||
[[File:LightingNoon.jpg|700px]] | |||
Evening: | |||
[[File:LightingEvening.jpg|700px]] | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
* [[GetTime]] |
Latest revision as of 09:46, 1 September 2020
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)
Early morning:
Noon:
Evening: