If the client knows what time it started and the duration of the timer then its completely possible
[QUOTE=King Penisless;47145392]If the client knows what time it started and the duration of the timer then its completely possible[/QUOTE]
Yea, client knows the duration since its in a table and I could make it know when it started.
Are you suggesting a timer on the client? That wouldn't work since the function server-side checks your inventory and if its found the item, it sets a timer.
The only way I could think of was just fetching the serverside timer if it exists.
[QUOTE='[CLRP]extra;47145429']Yea, client knows the duration since its in a table and I could make it know when it started.
Are you suggesting a timer on the client? That wouldn't work since the function server-side checks your inventory and if its found the item, it sets a timer.
The only way I could think of was just fetching the serverside timer if it exists.[/QUOTE]
Explain what you are trying to do and I will tell you how to do it
[QUOTE=King Penisless;47145443]Explain what you are trying to do and I will tell you how to do it[/QUOTE]
Im trying to make the client display a timer set serverside that's only created if another serverside value is true.
Is it a timer or a countdown?
If it's a simple timer you just need to tell the client to start it from the server using the net Library, heres how it would work.
[CODE]
-- CLIENT
START_TIME = 0
TIMER = false
function StartTimer()
START_TIME = CurTime()
TIMER = true
end
hook.Add("Think", "LolImAHook", function ()
if TIMER then
print(CurTime() - START_TIME)
end
end)
[/CODE]
[QUOTE=_FR_Starfox64;47145468]Is it a timer or a countdown?
If it's a simple timer you just need to tell the client to start it from the server using the net Library, heres how it would work.
[CODE]
-- CLIENT
START_TIME = 0
TIMER = false
function StartTimer()
START_TIME = CurTime()
TIMER = true
end
hook.Add("Think", "LolImAHook", function ()
if TIMER then
print(CurTime() - START_TIME)
end
end)
[/CODE][/QUOTE]
I don't think that would work in this case.
Heres some code to help.
[code]
--Client
CCraftButton.DoClick = function()
net.Start("CheckCraftable")
net.WriteString(v.Class)
net.WriteString(v.ENT_Model)
net.WriteString(v.CraftXP)
net.WriteString(v.C_level)
net.WriteString(v.CraftTimer)
net.SendToServer()
end
[/code]
[code]
--Serverside
if timer.Exists("CraftingObjectItem:"..ply:UniqueID().." Class:"..Class.."") or ply.CraftingShit then return end
if ply:GetCExp() < level then return end
if ply:GetItem( Class ) then --If the player has the shit in his inventory, then do this
ply.CraftingShit = true
timer.Create("CraftingObjectItem:"..ply:UniqueID().." Class:"..Class.."",time,1,function()
--Code for my shit
end)
[/code]
Ok what you need to display on the client is a countdown, All you need to send to the client is when the timer will run it's callback which is [B]CurTime() + time[/B]
[CODE]
net.Receive("ReceiveTimer", function()
TIMER_END = net.ReadInt()
end)
hook.Add("Think", "LolImAHook", function ()
if CurTime() <= TIMER_END then
print(TIMER_END - CurTime())
end
end)
[/CODE]
[QUOTE=_FR_Starfox64;47145524]Ok what you need to display on the client is a countdown, All you need to send to the client is when the timer will run it's callback which is [B]CurTime() + time[/B]
[CODE]
net.Receive("ReceiveTimer", function()
TIMER_END = net.ReadInt()
end)
hook.Add("Think", "LolImAHook", function ()
if CurTime() <= TIMER_END then
print(TIMER_END - CurTime())
end
end)
[/CODE][/QUOTE]
That worked. Thanks :)
Sorry, you need to Log In to post a reply to this thread.