Jump to content

Search the Community

Showing results for tags 'timecount'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 1 result

  1. so i have this code exports.scoreboard:addScoreboardColumn( 'time', root, 150 ) -- Online time is the element data local DB = dbConnect( "sqlite", "time.db" ) addEventHandler("onResourceStart", resourceRoot, function ( ... ) dbExec( DB, "CREATE TABLE IF NOT EXISTS online( playerACC, weeks,days, hours, minutes, secs )") for i, player in ipairs( getElementsByType("player") ) do local accountN = getAccountName( getPlayerAccount( player ) ) local getData = dbPoll( dbQuery( DB, "SELECT * FROM online WHERE playerACC=?", accountN), -1 ) if ( #getData == 0 ) then setPlayerTime( player, 0, 0, 0, 0, 0 ) else for i, data in ipairs( getData ) do local weeks = data.weeks or 0 local days = data.days or 0 local hours = data.hours or 0 local minutes = data.minutes or 0 local seconds = data.secs or 0 setPlayerTime( player, weeks ,days, hours, minutes, seconds ) end end setTimer( updatePlayerTime, 1000, 0, player ) end end) addEventHandler("onPlayerLogin", root, function ( ... ) local accountN = getAccountName( getPlayerAccount( source ) ) local getData = dbPoll( dbQuery( DB, "SELECT * FROM online WHERE playerACC=?", accountN), -1 ) if ( #getData == 0 ) then setPlayerTime( source, 0, 0, 0, 0, 0 ) else for i, data in ipairs( getData ) do local weeks = data.weeks or 0 local days = data.days or 0 local hours = data.hours or 0 local minutes = data.minutes or 0 local seconds = data.secs or 0 setPlayerTime( source, weeks ,days, hours, minutes, seconds ) end end setTimer( updatePlayerTime, 1000, 0, source ) end) function setPlayerTime( player, weeks ,days, hours, minutes, secs ) local accountN = getAccountName( getPlayerAccount( player ) ) if ( accountN ) then local dbe = dbQuery( DB, "SELECT * FROM online WHERE playerACC=?", accountN) local result = dbPoll( dbe, -1 ) local realTime = table.concat{ weeks.."w ",days.."d "..hours.."h ", minutes.."min.", secs.."s " } --", secs.."s " setElementData( player, "time", realTime ) if ( #result == 0 ) then dbExec( DB, "INSERT INTO online( playerACC, weeks, days, hours, minutes, secs ) VALUES( ?, ?, ?, ?, ?, ? ) ", accountN, tonumber( weeks ), tonumber( days ), tonumber( hours ), tonumber( minutes ), tonumber( secs ) ) else dbExec( DB, "UPDATE online SET playerACC=?, weeks=?, days=?, hours=?, minutes=?, secs=?", accountN, tonumber( weeks ), tonumber( days ), tonumber( hours ), tonumber( minutes ), tonumber( secs) ) end end end function updatePlayerTime( player ) local accountN = getAccountName( getPlayerAccount( player ) ) if ( accountN ) then local getData = dbPoll( dbQuery( DB, "SELECT * FROM online WHERE playerACC=?", accountN), -1 ) if ( getData ) then for index, data in ipairs( getData ) do data.secs = data.secs + 1 if ( data.secs == 5 ) then data.hours = data.hours + 1 data.secs = 0 elseif ( data.minutes == 60 ) then data.hours = data.hours + 1 data.minutes = 0 elseif ( data.hours == 24 ) then data.days = data.days + 1 data.hours = 0 elseif ( data.days == 7 ) then data.weeks = data.weeks + 1 data.days = 0 end setPlayerTime( player, data.weeks, data.days, data.hours, data.minutes, data.secs ) end end end end And i have 3problems and one question . 1st problem WARNING: [gameplay]/killcount-scoreboard/server.lua 62. bad argument @ 'getAccountName' [Expected element at argument 1] [DUP x11] . 2nd problem that it converts seconds 60sec to 1min i tried changing it and it worked but it can't convert second third and fourth only seconds. 3rd problem that it saves data only to one account for example there is 3players it should load time every player but it load 1st only acc for example on sqlite it shows: Dziugasc I 0weeks I 0days I 15hours I 35minutes I 45 seconds Dziugasc I 0weeks I 0days I 15hours I 35minutes I 45 seconds Dziugasc I 0weeks I 0days I 15hours I 35minutes I 45 seconds And question how to make that it would show only time that player was online for example he was online only 1d and 18hours and on scoreboard it would show 1d 18h in my scoreboard it shows 0w 0d 0h 15min. [I don't need 0 that way it would be nicer to look.
×
×
  • Create New...