SetTime: Difference between revisions
From Onset Developer Wiki
X7airworker (talk | contribs) No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | <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("syncTimeClient", function(time) | |||
SetTime(time) | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
* [[GetTime]] | * [[GetTime]] |
Revision as of 15:32, 17 November 2019
Description
Set the specified time for the client.
Syntax
SetTime(time)
Parameters
- time
Float value between 0 to 24.
Return Value
- __EDIT_ME__
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("syncTimeClient", function(time)
SetTime(time)
end)