Jump to content

Is this possible?


abu5lf

Recommended Posts

Posted (edited)
function onResourceStart()XX 
  

Is it possible to save the time that I played it when I get out and enter?

Edited by Guest

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

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

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

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

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

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

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

Posted
getPlayerAccount -- To get player account. 
setAccountData -- To save the time on his account. 
getAccountData -- To obtain the saved time from his account. 
getElementData -- To get player time. 
setElementData -- To set player time.  

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 am a newbie, :(

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

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

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

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

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

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

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

Posted

Well, then it's time to learn.

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
Well, then it's time to learn.

I will try ^_^

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

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

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

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

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

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

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

Posted (edited)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx

Edited by Guest

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

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

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

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

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

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

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

Posted

That's just a mess, go back to the wiki and start from the beginning.

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 know that, but what in the hand trick I will try again

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

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

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

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

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

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

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

Posted

What do you think?

function SaveTime ( thePlayer ) 
    setElementData (player, "joinTime", getTickCount() )  
    setElementData (player, "Online Time", "0 :, 0 :, 0 :" )  
    local timeOnline = (getTickCount() - getElementData ( player, "joinTime" ))     
    local player = getPlayerAccount ( thePlayer ) 
     local Time = getAccountData (player ) 
    if ( account ) then 
        setAccountData ( account ) 
    end 
end 
  

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

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

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

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

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

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

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

Posted

It's still wrong.

function saveTime(player, account) 
    if (account and not isGuestAccount(account)) then 
        local joinTime = getElementData(player,"joinTime") 
        setAccountData(account,"joinTime",joinTime) 
    end 
end 
  
addEventHandler("onPlayerLogout",root, 
    function (prev) 
        saveTime(source, prev) 
    end 
) 
  
addEventHandler("onPlayerQuit",root, 
    function () 
        saveTime(source, getPlayerAccount(source)) 
    end 
) 

That should get the element data "joinTime" from the player when he logs out or leaves the server, and save it on player account. This won't load it, I leave that to you.

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 Did you mean when it comes out from the server?

I have tried!

  
addEventHandler("onPlayerLogout",root, 
 function logouot(player, account) 
  if (account and not isGuestAccount(account)) then 
        local joinTime = getElementData(player,"joinTime") 
        setAccountData(account,"joinTime",joinTime) 
) 

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

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

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

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

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

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

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

Posted
I did not understand Did you mean when it comes out from the server?

I have tried!

  
  
  
addEventHandler("onPlayerLogout",root, 
 function saveTime(player, account) 
  if (account and not isGuestAccount(account)) then 
        local joinTime = getElementData(player,"joinTime") 
        setAccountData(account,"joinTime",joinTime) 
) 

addEventHandler ( 'onPlayerLogout', root, 
    function ( _, account ) 
         if ( account and not isGuestAccount ( account ) ) then 
                 local joinTime = getElementData ( _, 'joinTime' ) 
                 setAccountData ( account, 'joinTime', joinTime ) 
         end 
    end 
) 

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

You need to use end, to end each block.

exports["scoreboard"]:addScoreboardColumn("joinTime") 
function saveTime(player, account) 
    if (account and not isGuestAccount(account)) then 
        local joinTime = getElementData(player,"joinTime") 
        setAccountData(account,"joinTime",joinTime) 
    end 
end 
  
addEventHandler("onPlayerLogout",root, 
    function (prev) 
        saveTime(source, prev) 
    end 
) 
  
addEventHandler("onPlayerQuit",root, 
    function () 
        saveTime(source, getPlayerAccount(source)) 
    end 
) 
  
addEventHandler("onPlayerLogin", root, 
function(_,account) 
local joinTime = getAccountData(account,"joinTime") 
if not joinTime then joinTime = 0 end 
setElementData(source,"joinTime",joinTime) 
end) 

This will make a scoreboard column with the online time of everyplayer.

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted
function onResourceStart() 
    call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Online Time") 
    for index, player in pairs (getElementsByType("player")) do 
        setElementData (player, "joinTime", getTickCount() ) 
        setElementData (player, "Online Time", "0 :, 0 :, 0 :" )         
    end 
end 
addEventHandler("onResourceStart",resourceRoot,onResourceStart) 
  
function joinTime() 
    setElementData (source, "joinTime", getTickCount() ) 
    setElementData (source, "Online Time", "0 :, 0 :, 0 :" ) 
end 
addEventHandler ( "onPlayerJoin", root, joinTime ) 
  
function all() 
    for index , player in ipairs ( getElementsByType ( "player" ) ) do 
        local s = getElementData(player,"joinTime") or getTickCount() 
         s = (getTickCount() - s) / 1000 
        local string = string.format("%02d:%02d:%02d", s/3600, s%3600/60, s%60) 
        setElementData(player,"Online Time",string) 
    end 
end 
setTimer(all,1000,0) 
  
exports["scoreboard"]:addScoreboardColumn("Online Time") 
function saveTime(player, account) 
    if (account and not isGuestAccount(account)) then 
        local Online Time = getElementData(player,"Online Time") 
        setAccountData(account,"OnlineTime",Online Time) 
    end 
end 
  
addEventHandler("onPlayerLogout",root, 
    function (prev) 
        saveTime(source, prev) 
    end 
) 
  
addEventHandler("onPlayerQuit",root, 
    function () 
        saveTime(source, getPlayerAccount(source)) 
    end 
) 
  
addEventHandler("onPlayerLogin", root, 
function(_,account) 
local Online Time = getAccountData(account,"Online Time") 
if not Online Time then Online Time = 0 end 
setElementData(source,"Online Time",Online Time) 
end) 

WARNING: Loading script failed: OnLineTime5\OnLine.lua:35: ')' expected near 'Time' 

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

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

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

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

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

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

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

Posted
function onResourceStart () 
    call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Online Time") 
     
    for index, player in pairs ( getElementsByType("player") ) do 
        setElementData (player, "joinTime", getTickCount() ) 
        setElementData (player, "Online Time", "0 :, 0 :, 0 :" )         
    end 
end 
addEventHandler("onResourceStart",resourceRoot,onResourceStart) 
  
function joinTime () 
    setElementData ( source, "joinTime", getTickCount() ) 
    setElementData ( source, "Online Time", "0 :, 0 :, 0 :" ) 
end 
addEventHandler ( "onPlayerJoin", root, joinTime ) 
  
function all() 
    for index , player in ipairs ( getElementsByType ( "player" ) ) do 
        local s = getElementData( player, "joinTime" ) or getTickCount( ) 
        s = ( getTickCount() - s ) / 1000 
        local string = string.format( "%02d:%02d:%02d", s/3600, s%3600/60, s%60 ) 
        setElementData( player, "Online Time", string ) 
    end 
end 
setTimer( all, 1000, 0) 
  
function saveTime( player, account ) 
    if ( account and not isGuestAccount(account) ) then 
        local OnlineTime = getElementData( player, "joinTime" ) 
        setAccountData(account, "OnlineTime", OnlineTime) 
    end 
end 
  
addEventHandler ( "onPlayerLogout", root, 
    function ( prev ) 
        saveTime( source, prev ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        saveTime( source, getPlayerAccount( source ) ) 
    end 
) 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( _, account ) 
        local OnlineTime = getAccountData( account, "Online Time" ) 
        if ( not OnlineTime ) then OnlineTime = 0 end 
        setElementData( source, "joinTime", OnlineTime ) 
    end 
) 

Your problem(s) we're:

1: You can't make a variable with spaces, e.g: Online Time = "hello world", it has to be: OnlineTime = "hello world".

2: You we're saving the time string, not the milliseconds.

3: It still won't work though, when you login back, it'll set it to 9 hours and something.

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

They no longer show the time in the scoreboard

I do not know is it saves time or not

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

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

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

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

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

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

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

Posted

Copy the code again and try 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

We have succeeded thanks to you

But I got a new idea I want to appear on the screen with the best time, but I can not do so :(

addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
         
        best = guiCreateLabel(31,409,105,17,"BesT TimeOnLine :",false) 
        guiLabelSetColor(best,255,255,0) 
        guiSetFont(best,"default-bold-small") 
  
        playername = guiCreateLabel(133,407,135,20,"",false) 
  
        besttime = guiCreateLabel(140,428,81,20,"",false) 
    end 
) 
function() 
        call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Online Time") 
        call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "Name") 
        call(getResourceFromName("scoreboard"), "removeScoreboardColumn", "joinTime") 
    end 
) 

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

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

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

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

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

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

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

Posted

I'm afraid I don't understand you, what do you mean by "best time"?

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 mean like the best drift

The best time to OnLine in the server

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

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

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

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

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

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

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

Posted

Oh, you're talking about the player who has the most online time?

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

Yes I mean this

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

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

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

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

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

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

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

Posted

Is this possible?

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

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

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

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

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

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

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

Posted

Can you help me a bit.

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

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

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

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

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

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

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