• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Player online time

VirrageS

←•†ĿuĀ && ©¤¤•→
Joined
May 30, 2010
Messages
984
Reaction score
63
Location
Poland
Hello!
I have one question. So is any function with which
i can know how much is player online from login to now.

Legend:
(login -> now -> logout)

A little confused but I think that you will understand :D


For help rep++ :)
 
I don't need to define the function in OTS/data/lib/050-function ???

You can if you want to use it in more scripts. Otherwise pasting it into your script is enough ;p

@edit
Now I understand what you mean. this is not default TFS function so - yes, you need to include it.
 
I made scrpit with this function but it doesn't work.
Here is script:
Code:
function onLogin(cid)
local playtime = getPlayerUptime(cid)
	if playtime == 30 and isPlayer(cid) then
		doPlayerSendTextMessage(cid,22,"You are playing 30 sec.")
	else
		doPlayerSendTextMessage(cid,22,"Somethink is wrong.")
	end
end

I include this function in 050-function.lua:
Code:
function getPlayerUptime(cid)
	return os.time() - getPlayerLastLogin(cid)
end
Problem: When i try to login i get instantly disconnect.
 
@up Thx :D.

But now when i login apear this message:
Code:
doPlayerSendTextMessage(cid,22,"[COLOR="Red"]Somethink is wrong.[/COLOR]"
 
@up Thx :D.

But now when i login apear this message:
Code:
doPlayerSendTextMessage(cid,22,"[COLOR="Red"]Somethink is wrong.[/COLOR]"

hehe, thats because your script is executed when player login (onLogin), right? So getPlayerUptime(cid) == 0 in that case, thats why your script show you this message.

What effect are you trying to achieve? Maybe better make a command which will show player uptime?
 
hehe, thats because your script is executed when player login (onLogin), right? So getPlayerUptime(cid) == 0 in that case, thats why your script show you this message.

What effect are you trying to achieve? Maybe better make a command which will show player uptime?

I want to make scrpit which will every hour uptime (player) show text message like this:
"You are playing ' .. playtime .. ' nonstop. Stop because you will be addicted."
 
Last edited:
Back
Top