Castillo Posted March 8, 2012 Share Posted March 8, 2012 Is this possible? Yes it is .You can use getTickCount function https://wiki.multitheftauto.com/wiki/GetTickCount Read example. Take getTickCount when player joins server and subtract it from current tick count. I would suggest splitting the "Online Time" data and then compare it. Link to comment
abu5lf Posted March 8, 2012 Author Share Posted March 8, 2012 I did not understand but try this function joinTime () setElementData ( source, "joinTime", getTickCount() ) setElementData ( source, "Online Time", "0 :, 0 :, 0 :" ) end addEventHandler ( "onPlayerJoin", root, joinTime ) Link to comment
Thelastride Posted March 8, 2012 Share Posted March 8, 2012 (edited) I did not understand but try this Yes good try function joinTime () setElementData ( source, "joinTime", getTickCount() ) end addEventHandler ( "onPlayerJoin", root, joinTime ) function checkonline (player) local timeon =( getTickCount() - getElementData ( player, "joinTime")) /60000 outputChatBox("Time spent in server: "..timeon.. " minutes.",player,255,255,255) end addCommandHandler ( "timeinserver",checkonline) Now you can use a for loop to check who is online for most time. Edited March 9, 2012 by Guest Link to comment
arezu Posted March 8, 2012 Share Posted March 8, 2012 I did not understand but try this Yes good try function joinTime () setElementData ( source, "joinTime", getTickCount() ) end addEventHandler ( "onPlayerJoin", root, joinTime ) function checkonline (player) local timeon = getTickCount() - getElementData ( player, "joinTime") /60000 outputChatBox("Time spent in server: "..timeon.. " minutes.",player,255,255,255) end addCommandHandler ( "timeinserver",checkonline) Now you can use a for loop to check who is online for most time. basic math rule: local timeon = (getTickCount() - getElementData ( player, "joinTime")) /60000 otherwise it would divide the element data with 60000 first Link to comment
abu5lf Posted March 8, 2012 Author Share Posted March 8, 2012 I want it to appear on the screen such as: Cx.83 11:55 Name of the player and the maximum time Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now