How do i code a persons online time?
mob/var/minute = 0
mob/var/seconds = 0
client
New()
..()
there
spawn(1)
sleep(10)
usr.second += 1
src.onlinetime()
spawn(1)
goto there
Del()
..()
mob
proc
onlinetime()
if(usr.second => 60)
usr.minute += 1
usr.second = 0
mob
Stat()
stat("Online time:","[usr.minute]")
all this done by top of my imagination. i dont have a clue if this would work, if any one have any help or advice about my coding please let me know and teach me how to code a time code!
i know how to code a clock, i learn it on byond tutorial.
thank you guys
ID:173993
Oct 16 2003, 1:07 am
|
|
If you want to calculate in-game time by the number of server ticks the player has been on then do something like this:
client var/start_time New() .=..() start_time=world.time proc/return_gametime() return world.time/start_time For realistic in-game time: client var/start_time New() .=..() start_time=world.realtime proc/return_realtime() return world.realtime/start_time |
In response to Loduwijk
|
|
Loduwijk wrote:
If you want to calculate in-game time by the number of server ticks the player has been on then do something like this: Something like that, but with correct math. Division isn't going to get you very far here; subtraction is what you need. Lummox JR |
No put usr in proc. Ungh.
The best way to keep track of time is to mark the time of arrival and then substract that from the current time whenever you want to check. Bear in mind that world.time is in ticks, which are not necessarily 1/10 second because they take place in game time, not real time. world.realtime does give you real time, but because it's such a large floating point number it rounds off by several seconds so there's no kind of accuracy to it at all. Lummox JR |
Something from a demo I never got around to releasing:
mob Works fine in all tests. |
In response to Lummox JR
|
|
Oops... hit the wrong key. Darn it all, I keep doing stuff like that and you keep correcting me. Something must be wrong with me lately.
|
In response to Green Lime
|
|
mob/var/minute = 0 that should do it!..i think i learning alot on this forum! thanks alot..if you guys have other way to code a online time! please show me ! thank you again |
Looks pretty good to me. Only problem you might have with the above code is refrences. Which im not very good at and would have to examine them on paper.
For this I would probley just spawn(10) and then run the assignment statements.
One more thing that caught my eye. Your var name when defined is seconds while the others were second. :) dont get var names confused.