momar5700 Posted August 26, 2015 Author Share Posted August 26, 2015 لو سمحت انا ماعرف احطهم لاني لما احطه مايشتغل معي انت مبرمج وخبير فيها وكمان ابي لما احدف او ازود لاحدساعات تجي له رسالة بشات Link to comment
iMr.SFA7 Posted August 26, 2015 Share Posted August 26, 2015 -- Server Side : --[[ ------------------------------------------------- original script credits to Yakuza.Real and solidsnake and kenix viewtopic.php?f=91&t=40132 ------------------------------------------------- booo just fix it Mr.Pres[T]ege : Remake the script using ( SQL ) To Save it . ]] exports.scoreboard:addScoreboardColumn('PlayTime') addEvent("addTime",true) addEvent("removeTime",true) addEvent("ToServer",true) addEventHandler("onResourceStart",resourceRoot, function ( ) executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Prestege2_Save_Time ( PlayerAccount,Hours,Minuts,Seconds,PlayAllTime )" ) outputDebugString ("Execute SQL Loadded !") end ) local t = { } local w = {} addEventHandler("ToServer",root, function (word,get,time) if word and tonumber(get) and tonumber(time) then table.insert(w,{word,get}) setTimer(function () for _,v in ipairs(w) do if v[1] == word and v[2] == get then table.remove(w,i) end end end,time*60*60*1000,1) end end ) addEventHandler("onConsole",root, function (msg) for _,v in ipairs(w) do if msg == v[1] then local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then if not getAccountData ( playeraccount, "time-"..msg) then addPlayerTime(source,v[2]) setAccountData( playeraccount, "time-"..msg,true) end end end end end ) addEventHandler("addTime",root, function (to,time) if to == "all" then for _,v in ipairs(getElementsByType("player")) do addPlayerTime(v,time) outputChatBox ("تم توزيع "..time.." ساعة لـ جميع اللاعبين",v,255,0,0,true ) end else plr = getPlayerFromName(to) if plr then addPlayerTime(plr,time) outputChatBox ("تم أضافة "..time.." ساعة الى حسابككـ",plr,255,0,0,true ) end end end ) addEventHandler("removeTime",root, function (to,time) if to == "all" then for _,v in ipairs(getElementsByType("player")) do removePlayerTime(v,time) outputChatBox ("تم حذف "..time.." ساعة من جمييع الاعبين",v,255,0,0,true ) end else plr = getPlayerFromName(to) if plr then removePlayerTime(plr,time) outputChatBox ("تم حذف "..time.." ساعة من حسآبككـ ",plr,255,0,0,true ) end end end ) function addPlayerTime(plr,time) time = math.floor(time) t[plr]['hour'] = tonumber(t[plr]['hour'] or 0) + time end function removePlayerTime(plr,time) time = math.floor(time) t[plr]['hour'] = tonumber(t[plr]['hour'] or 0) - time end 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 acc = getPlayerAccount (source) if not isGuestAccount (source) then 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 accountName = getAccountName (acc) local Results = executeSQLQuery("SELECT * FROM Prestege2_Save_Time WHERE PlayerAccount=?", accountName) if ( type ( Results ) == "table" and #Results == 0 or not Results ) then executeSQLQuery ( "INSERT INTO Prestege2_Save_Time ( PlayerAccount,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)", accountName,hour,min,sec,sValue ) else executeSQLQuery('UPDATE Prestege2_Save_Time SET Hours =?, Minuts =?, Seconds =?, PlayAllTime =? WHERE PlayerAccount =?', hour, min, sec, sValue, accountName) end t[ source ] = nil end end addEventHandler ("onPlayerQuit", root, SaveDataOnQuit) function SaveDataOnStop () for _,v in ipairs (getElementsByType ("player")) do if not isGuestAccount (getPlayerAccount (v)) then local acc = 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 Results = executeSQLQuery("SELECT * FROM Prestege2_Save_Time WHERE PlayerAccount=?", getAccountName (acc)) if ( type ( Results ) == "table" and #Results == 0 or not Results ) then executeSQLQuery ( "INSERT INTO Prestege2_Save_Time ( PlayerAccount,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)", getAccountName (acc), hour,min,sec,sValue) else executeSQLQuery('UPDATE Prestege2_Save_Time SET Hours =?, Minuts =?, Seconds =?, PlayAllTime =? WHERE PlayerAccount =?', hour, min, sec, sValue, getAccountName (acc)) end end end end addEventHandler ("onResourceStop", resourceRoot, SaveDataOnStop) function GetDataOnStart () for _,v in ipairs (getElementsByType ("player")) do if not isGuestAccount (getPlayerAccount (v)) then local acc = getPlayerAccount (v) local Results = executeSQLQuery("SELECT * FROM Prestege2_Save_Time WHERE PlayerAccount=?", getAccountName (acc)) 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 end addEventHandler("onResourceStart", resourceRoot, GetDataOnStart) function GetDataOnLogin (_, acc) local Results = executeSQLQuery("SELECT * FROM Prestege2_Save_Time WHERE PlayerAccount=?", getAccountName (acc)) 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 ("onPlayerLogin", root, GetDataOnLogin) addCommandHandler('لوحة', function(thePlayer) if getPlayerSerial (thePlayer) == Serial then triggerClientEvent(thePlayer,'openn',thePlayer) end end ) Link to comment
momar5700 Posted August 26, 2015 Author Share Posted August 26, 2015 الحين اكتب لوحة ماتظهر لوحة توزيع ساعات -- Server Side : --[[ ------------------------------------------------- original script credits to Yakuza.Real and solidsnake and kenix viewtopic.php?f=91&t=40132 ------------------------------------------------- booo just fix it Mr.Pres[T]ege : Remake the script using ( SQL ) To Save it . ]] exports.scoreboard:addScoreboardColumn('PlayTime') addEvent("addTime",true) addEvent("removeTime",true) addEvent("ToServer",true) addEventHandler("onResourceStart",resourceRoot, function ( ) executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Prestege2_Save_Time ( PlayerAccount,Hours,Minuts,Seconds,PlayAllTime )" ) outputDebugString ("Execute SQL Loadded !") end ) local t = { } local w = {} addEventHandler("ToServer",root, function (word,get,time) if word and tonumber(get) and tonumber(time) then table.insert(w,{word,get}) setTimer(function () for _,v in ipairs(w) do if v[1] == word and v[2] == get then table.remove(w,i) end end end,time*60*60*1000,1) end end ) addEventHandler("onConsole",root, function (msg) for _,v in ipairs(w) do if msg == v[1] then local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then if not getAccountData ( playeraccount, "time-"..msg) then addPlayerTime(source,v[2]) setAccountData( playeraccount, "time-"..msg,true) end end end end end ) addEventHandler("addTime",root, function (to,time) if to == "all" then for _,v in ipairs(getElementsByType("player")) do addPlayerTime(v,time) outputChatBox ("تم توزيع "..time.." ساعة لـ جميع اللاعبين",v,255,0,0,true ) end else plr = getPlayerFromName(to) if plr then addPlayerTime(plr,time) outputChatBox ("تم أضافة "..time.." ساعة الى حسابككـ",plr,255,0,0,true ) end end end ) addEventHandler("removeTime",root, function (to,time) if to == "all" then for _,v in ipairs(getElementsByType("player")) do removePlayerTime(v,time) outputChatBox ("تم حذف "..time.." ساعة من جمييع الاعبين",v,255,0,0,true ) end else plr = getPlayerFromName(to) if plr then removePlayerTime(plr,time) outputChatBox ("تم حذف "..time.." ساعة من حسآبككـ ",plr,255,0,0,true ) end end end ) function addPlayerTime(plr,time) time = math.floor(time) t[plr]['hour'] = tonumber(t[plr]['hour'] or 0) + time end function removePlayerTime(plr,time) time = math.floor(time) t[plr]['hour'] = tonumber(t[plr]['hour'] or 0) - time end 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 acc = getPlayerAccount (source) if not isGuestAccount (source) then 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 accountName = getAccountName (acc) local Results = executeSQLQuery("SELECT * FROM Prestege2_Save_Time WHERE PlayerAccount=?", accountName) if ( type ( Results ) == "table" and #Results == 0 or not Results ) then executeSQLQuery ( "INSERT INTO Prestege2_Save_Time ( PlayerAccount,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)", accountName,hour,min,sec,sValue ) else executeSQLQuery('UPDATE Prestege2_Save_Time SET Hours =?, Minuts =?, Seconds =?, PlayAllTime =? WHERE PlayerAccount =?', hour, min, sec, sValue, accountName) end t[ source ] = nil end end addEventHandler ("onPlayerQuit", root, SaveDataOnQuit) function SaveDataOnStop () for _,v in ipairs (getElementsByType ("player")) do if not isGuestAccount (getPlayerAccount (v)) then local acc = 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 Results = executeSQLQuery("SELECT * FROM Prestege2_Save_Time WHERE PlayerAccount=?", getAccountName (acc)) if ( type ( Results ) == "table" and #Results == 0 or not Results ) then executeSQLQuery ( "INSERT INTO Prestege2_Save_Time ( PlayerAccount,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)", getAccountName (acc), hour,min,sec,sValue) else executeSQLQuery('UPDATE Prestege2_Save_Time SET Hours =?, Minuts =?, Seconds =?, PlayAllTime =? WHERE PlayerAccount =?', hour, min, sec, sValue, getAccountName (acc)) end end end end addEventHandler ("onResourceStop", resourceRoot, SaveDataOnStop) function GetDataOnStart () for _,v in ipairs (getElementsByType ("player")) do if not isGuestAccount (getPlayerAccount (v)) then local acc = getPlayerAccount (v) local Results = executeSQLQuery("SELECT * FROM Prestege2_Save_Time WHERE PlayerAccount=?", getAccountName (acc)) 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 end addEventHandler("onResourceStart", resourceRoot, GetDataOnStart) function GetDataOnLogin (_, acc) local Results = executeSQLQuery("SELECT * FROM Prestege2_Save_Time WHERE PlayerAccount=?", getAccountName (acc)) 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 ("onPlayerLogin", root, GetDataOnLogin) addCommandHandler('لوحة', function(thePlayer) if getPlayerSerial (thePlayer) == "1D1EEF105D056B8A2F98F3F024E530E3" then triggerClientEvent(thePlayer,'openn',thePlayer) end end ) Link to comment
iMr.SFA7 Posted August 26, 2015 Share Posted August 26, 2015 (edited) تأكد من سيريالككـ وأفتح الدي بق /debugscript 3 وشف يقول فيه خطأ ولا لا ؟ ؟ Edited August 26, 2015 by Guest Link to comment
momar5700 Posted August 26, 2015 Author Share Posted August 26, 2015 متاكد من سيريال وش الدي Link to comment
iMr.SFA7 Posted August 26, 2015 Share Posted August 26, 2015 تأكد من سيريالككـ وأفتح الدي بق /debugscript 3 وشف يقول فيه خطأ ولا لا ؟ ؟ Link to comment
iMr.SFA7 Posted August 26, 2015 Share Posted August 26, 2015 أكتب باف8 debugscript 3 وسوي ريستارت للمود وصور الشآشة ؟ ؟ 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