Could anyone help me with this code?UTime ulx command
18 replies, posted
So i've tried to make a ulx utime code. I've came this far.
I tried this code first but it didnt seem to get GetUTimeTotalTime()
[CODE]function timecommand(ply, text, teamonly )
if (text == "!time" or "/time") then
ply:PrintMessage(HUD_PRINTTALK,msg, "You have played on the server:" .. GetUTimeTotalTime() ".")
end
end
hook.Add( "PlayerSay", "Chat", timecommand)[/CODE]
I've tried this code which doesnt seem to get localplayer. So i pasted this code into cl_utime but ulx didnt get it was ulx command
[CODE]function timecommand(ply, text, teamonly )
if (text == "!time" or "/time") then
ply:PrintMessage(HUD_PRINTTALK,msg, "You have played on the server:" ..( timeToStr( LocalPlayer():GetUTimeTotalTime() ) )
.. ( timeToStr( LocalPlayer():GetUTimeSessionTime() ) )
..".")
end
end
hook.Add( "PlayerSay", "Chat", timecommand)[/CODE]
Thanks in advance
LocalPlayer only works on client-side scripts. GetUTimeTotalTime() sounds like a custom ulx function, have you checked it actually exists?
Yeah it's from utime, but i might be wrong
Do you get an error with the first piece of code? Does it say that there's no function called GetUTimeTotalTime()?
Yeah
bump
Do you have these lines in this file?
[url]https://github.com/Nayruden/Ulysses/blob/master/utime/lua/autorun/sh_utime.lua#L30-L32[/url]
How do you mean? If you mean in the ulx command script then no if you mean the utime addon then yes
Try this in a server side file
[lua]
function timecommand(ply, text, teamonly )
if (string.lower(text) == "!time") or (string.lower(text) == "/time") then
ply:PrintMessage(HUD_PRINTTALK,"You have played on the server: " .. timeToStr(ply:GetUTimeTotalTime()))
end
end
hook.Add( "PlayerSay", "Chat", timecommand)
[/lua]
[QUOTE=Icejjfish;44712607]So i've tried to make a ulx utime code. I've came this far.
I tried this code first but it didnt seem to get GetUTimeTotalTime()
[CODE]function timecommand(ply, text, teamonly )
if (text == "!time" or "/time") then
ply:PrintMessage(HUD_PRINTTALK, "You have played on the server:" .. GetUTimeTotalTime() ".")
end
end
hook.Add( "PlayerSay", "Chat", timecommand)[/CODE]
[/QUOTE]
Try this:
[code]
function timecommand(ply, text, teamonly )
if(string.sub( text, 1, 5) == "!time" or string.sub( text, 1, 5) == "/time" ) then
ply:PrintMessage(HUD_PRINTTALK, "You have played on the server:" .. GetUTimeTotalTime() ".")
end
end
hook.Add( "PlayerSay", "Chat", timecommand)
[/code]
inside lua/autorun/server/whatever.lua
That script works for me, minus the GetUTimeTotalTime since I don't have whatever addon/script that is installed.
[QUOTE=Adzter;44722350]Try this:
[code]
function timecommand(ply, text, teamonly )
if(string.sub( text, 1, 5) == "!time" or string.sub( text, 1, 5) == "/time" ) then
ply:PrintMessage(HUD_PRINTTALK,msg, "You have played on the server:" .. GetUTimeTotalTime() ".")
end
end
hook.Add( "PlayerSay", "Chat", timecommand)
[/code]
inside lua/autorun/server/whatever.lua
That script works for me, minus the GetUTimeTotalTime since I don't have whatever addon/script that is installed.[/QUOTE]
Thanks for the help!
[QUOTE=Icejjfish;44722187]How do you mean? If you mean in the ulx command script then no if you mean the utime addon then yes[/QUOTE]
Download ulx from the github and replace the one that's currently on your server and your script should work flawlessly.
Adzter got helped me all i need help with now is how to change how it prints out the minutes
it prints out like this
[CODE]You have played on the server: 4501.6200146675[/CODE]
Need to change it to weeks, days, hours,minutes and seconds(not needed). I'm sorry but new to lua And again Thanks Adzter for the help and to you too SvenskungAnka.
[QUOTE=Icejjfish;44722783]Adzter got helped me all i need help with now is how to change how it prints out the minutes
it prints out like this
[CODE]You have played on the server: 4501.6200146675[/CODE]
Need to change it to weeks, days, hours,minutes and seconds(not needed). I'm sorry but new to lua And again Thanks Adzter for the help and to you too SvenskungAnka.[/QUOTE]
On that page I showed you, is a function that does exactly that: [url]https://github.com/Nayruden/Ulysses/blob/master/utime/lua/autorun/sh_utime.lua#L34-L46[/url]
I know but how do i implant it?
It should already be in the file [B]addons/utime/lua/autorun/sh_utime.lua[/B]
You can see the freaking path on github dude
[IMG]http://puu.sh/8zlT3.png[/IMG]
[QUOTE=Svenskunganka;44722942]It should already be in the file [B]addons/utime/lua/autorun/sh_utime.lua[/B]
You can see the freaking path on github dude
[IMG]http://puu.sh/8zlT3.png[/IMG][/QUOTE] Are you stupid? It won't help by just adding it. I need to add a code that tells it to use the function.
I already posted a working solution.
"You have played on the server: 00w 2d 17h 58m 01s"
Fixed the code :D Thanks for the help everyone!
Sorry, you need to Log In to post a reply to this thread.