Jump to content

Is this possible?


abu5lf

Recommended Posts

Posted
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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 ) 
  

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

Posted (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 by Guest
Posted
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

Posted

I want it to appear on the screen such as:

Cx.83 11:55

Name of the player and the maximum time

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...