Could anyone help me with this code?UTime ulx command

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()


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)

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


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)

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?

https://github.com/Nayruden/Ulysses/blob/master/utime/lua/autorun/sh_utime.lua#L30-L32

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]

Try this:



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)


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.

Thanks for the help!

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


You have played on the server: 4501.6200146675

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.

On that page I showed you, is a function that does exactly that: https://github.com/Nayruden/Ulysses/blob/master/utime/lua/autorun/sh_utime.lua#L34-L46

I know but how do i implant it?

It should already be in the file addons/utime/lua/autorun/sh_utime.lua

You can see the freaking path on github dude

http://puu.sh/8zlT3.png

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 :smiley: Thanks for the help everyone!