aBo.F[ra]G<3 Posted July 12, 2014 Share Posted July 12, 2014 السلام عليكم ي شباب عندي مشكله بالوقت ماينحفظ ولا عرفت اضبطه اذا سويت رستارت لسيرفر او اذا سويت رستارت للمود نفسهه ينعاد الوقت من 0 ابي الحل اببي الوقت ينحفظ الى يعرف يفيدني Link to comment
Max+ Posted July 12, 2014 Share Posted July 12, 2014 setAccountData getAccountData ---- setElementData getElementData تحفظ الوقت بالطريقة الاولى ولا الثانية ؟ Link to comment
aBo.F[ra]G<3 Posted July 12, 2014 Author Share Posted July 12, 2014 اخوي ابي اذا سواا اذا سويت رستارت لسيرفر او رستارت للمود ابي الوقت يكون محفوظ Link to comment
shwaeki Posted July 12, 2014 Share Posted July 12, 2014 شوف viewtopic.php?f=160&t=59691&p=568901&hilit=%D8%AD%D9%81%D8%B8+%D8%A7%D9%84%D9%88%D9%82%D8%AA#p568901 Link to comment
aBo.F[ra]G<3 Posted July 13, 2014 Author Share Posted July 13, 2014 ي شباب افيدوناا بالله الى يعرف لا يبخل Link to comment
SaRy,#DanGer Posted July 15, 2014 Share Posted July 15, 2014 خلاص بسيطه ض1 الحل عندي خخ Remake the script using ( SQL ) To Save it . ]] exports.scoreboard:addScoreboardColumn('PlayTime') addEventHandler('onResourceStart',resourceRoot, function ( ) executeSQLQuery ( 'CREATE TABLE IF NOT EXISTS Time_Table ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime )' ) outputDebugString ('Execute SQL Loadded !') end ) local t = { } function checkValues( source,arg1,arg2) if (arg2 >= 60) then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 end if (arg1 >= 60) then t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end return arg1, arg2 end setTimer( function( ) for _, v in pairs( getElementsByType( 'player' ) ) do if (not t[ v ]) then t[ v ] = { ['hour'] = 0, ['min'] = 0, ['sec'] = 0 } end t[ v ][ 'sec' ] = tonumber( t[ v ][ 'sec' ] or 0 ) + 1 local min,sec = checkValues ( v, t[ v ][ 'min' ] or 0, t[ v ][ 'sec' ] or 0 ) local hour = tonumber( t[ v ][ 'hour' ] or 0 ) setElementData( v, 'PlayTime', tostring( hour )..':'..tostring( min )..':'..tostring( sec ) ) end end, 1000, 0 ) function SaveDataOnQuit ( ) local sValue = getElementData( source,'PlayTime' ) local hour = tonumber( t[ source ][ 'hour' ] or 0 ) local min = tonumber( t[ source ][ 'min' ] or 0 ) local sec = tonumber( t[ source ][ 'sec' ] or 0 ) local serial = getPlayerSerial ( source ) local Results = executeSQLQuery('SELECT * FROM Time_Table WHERE PlayerSerial=?',serial) if ( type ( Results ) == 'table' and #Results == 0 or not Results ) then executeSQLQuery ( 'INSERT INTO Time_Table ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)',serial,hour,min,sec,sValue ) else executeSQLQuery('UPDATE Time_Table SET Hours =?, Minuts =?, Seconds =?, PlayAllTime =? WHERE PlayerSerial =?', hour, min, sec, sValue, serial) end t[ source ] = nil end addEventHandler('onPlayerQuit',root,SaveDataOnQuit) function SaveDataOnStop ( ) for k,v in ipairs ( getElementsByType('player') ) do local playeraccount = getPlayerAccount ( v ) local sValue = getElementData( v,'PlayTime' ) if not ( t [ v ] ) then t [ v ] = { } end local hour = tonumber( t[ v ][ 'hour' ] or 0 ) local min = tonumber( t[ v ][ 'min' ] or 0 ) local sec = tonumber( t[ v ][ 'sec' ] or 0 ) local serial = getPlayerSerial ( v ) local Results = executeSQLQuery('SELECT * FROM Time_Table WHERE PlayerSerial=?',getPlayerSerial ( v ) ) if ( type ( Results ) == 'table' and #Results == 0 or not Results ) then executeSQLQuery ( 'INSERT INTO Time_Table ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)',serial,hour,min,sec,sValue ) else executeSQLQuery('UPDATE Time_Table SET Hours =?, Minuts =?, Seconds =?, PlayAllTime =? WHERE PlayerSerial =?', hour, min, sec, sValue, serial) end end end addEventHandler('onResourceStop',resourceRoot,SaveDataOnStop) function GetDataOnStart ( ) for _,v in ipairs ( getElementsByType ( 'player' ) ) do local Results = executeSQLQuery('SELECT * FROM Time_Table WHERE PlayerSerial=?',getPlayerSerial ( v ) ) if ( type ( Results ) == 'table' and #Results == 0 or not Results ) then return end if not t[ v ] then t[ v ] = {} end t[ v ]['hour'] = tonumber(Results[1]['Hours']) t[ v ]['min'] = tonumber(Results[1]['Minuts']) t[ v ]['sec'] = tonumber(Results[1]['Seconds']) end end addEventHandler('onResourceStart',resourceRoot,GetDataOnStart) function GetDataOnJoin ( ) local Results = executeSQLQuery('SELECT * FROM Time_Table WHERE PlayerSerial=?',getPlayerSerial ( source ) ) if ( type ( Results ) == 'table' and #Results == 0 or not Results ) then return end setElementData ( source, 'PlayTime', Results[1]['PlayAllTime'] ) if not t[ source ] then t[ source ] = {} end t[ source ]['hour'] = tonumber(Results[1]['Hours']) t[ source ]['min'] = tonumber(Results[1]['Minuts']) t[ source ]['sec'] = tonumber(Results[1]['Seconds']) end addEventHandler('onPlayerJoin',root,GetDataOnJoin) هذى المود كامل بس حطه ملف سيرفر , + هالمود يحفظ على قاعده البيانات يعني مايروح ^ Link to comment
#=|>[A]sMr,\~> Posted July 15, 2014 Share Posted July 15, 2014 اذا سويت ريستارت للمود ( كل الي مسجلين دخولهم تروح ساعاتهم والحل ؟؟؟ انك تتضيف اسم المود في ملف mtaserver ولا تسوي ريستارت والناس داخلين حساباتهم .. Link to comment
SaRy,#DanGer Posted July 15, 2014 Share Posted July 15, 2014 اذا سويت ريستارت للمود ( كل الي مسجلين دخولهم تروح ساعاتهم والحل ؟؟؟انك تتضيف اسم المود في ملف mtaserver ولا تسوي ريستارت والناس داخلين حساباتهم .. خخخخخخخخخ من قال؟ ض1 شوف الكود اله حطيته لو الكل داخل حسابه و رستارت الف مره مايروحون الساعات Link to comment
al-Kobra Posted July 15, 2014 Share Posted July 15, 2014 ^^ ليش ما تذكر المصدر مال الكود ؟ Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now