Timers on client

Hi, I’m trying to make a timer that runs only for the client with “timer.Create” and I just recently figured out it only worked on the server file :P, so how do I make it run only for the client when it’s called. Sorry if this is a noob question, I’m not very good with lua.

What I’m trying to do is take the duration of a song, round it, add 1 and then create a timer with it that runs once and makes the command to reset the songs run. I already have this part I just need the timer.

I didn’t really post my code because I didn’t think any of it would really be helpful since I don’t know how to set this up yet.

If there’s another thread please point me out, I tried searching but didn’t find anything for me.

You’ll need to use usermessages or concommands to send a message to the client saying that “the timer went off, do this”. When you make your usermessage hook or concommand on the client, you’ll specify the code that needs to be run.

I still can’t figure this out, it keeps giving me the ply activator instead of a number? Im really confused and im probably doing it all wrong.

This is part of my client file:
[lua]
function runmtimer( ml )
time = tostring(ml)
RunConsoleCommand( “mtimer”, time )
end
[/lua]
-I tested “time” and it gives me a number string which i want

This is part of my server file:
[lua]
function mtimer( time )
Msg(time)–test
time=tonumber(time)
timer.Create( “stimer”, time, 1, endtime )
end
concommand.Add( “mtimer”, mtimer, time )
[/lua]
-For some reason when i test time in here it changes into Player [1][SparkZ] which is my user in the server.

plz help

The arguments to concommand.Add callback are ply, cmd, args. The first argument being the player who calls the console command.

ok, so do i change the args of “concommand.Add” or “RunConsoleCommand”? and what do i change them too? ive messed around and have gotten the “Msg(time)” to print a table and “mtimer” instead of the player? but still no number =(

[lua]function mtimer( ply, cmd, args )
if args[1] then
local time = tonumber(args[1])
timer.Create(“stimer”, time, 1, endtime) – Where is endtime defined, alos can’t you use timer.Simple here?
end
end
concommand.Add( “mtimer”, mtimer) [/lua]

i got it to work finally thanks =)

No problem.