Jump to content

PlayTime


Recommended Posts

26 minutes ago, Mr.Mostafa said:

اطرح سرفر مود الساعات حقك



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) 
      outputChatBox ("#FF0000* #ffffff [#ff0000 تم اعطاك ساعات #ffffff] ",plr,0, 255, 0,true ) 
    else 
      outputChatBox ("#FF0000* #ffffff [#ff0000 تم التوزيع من قبل #ffffff] ",plr,0, 255, 0,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 ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم توزيع ساعات لجميع الاعبين #ffffff] ",plr,0, 255, 0,true ) 
  end 
  else 
   plr = getPlayerFromName(to) 
    if plr then 
    addPlayerTime(plr,time) 
    outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم اضافة ساعات الى حسابك #ffffff] ",plr,0, 255, 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 ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم حذف ساعات من جميع الاعبين #ffffff] ",v,0, 255, 0,true ) 
  end 
  else 
   plr = getPlayerFromName(to) 
    if plr then 
    removePlayerTime(plr,time) 
    outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم حذف ساعات من حسابك #ffffff] ",plr,0, 255, 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('T1', 
function(thePlayer) 
    if getPlayerSerial (thePlayer) == "B83098E832E840D8C1BE0151CE8A58A1" then 
        triggerClientEvent(thePlayer,'openn',thePlayer) 
    end 
end 
) 

addCommandHandler(' هنا الكلمة الي تكتبها في اف 8 عشان تقدر توزيع ساعات ', 
function(thePlayer) 
    if getPlayerSerial (thePlayer) == " هنا حط سريال خويك  لافتح الوحه له " then 
        triggerClientEvent(thePlayer,'openn',thePlayer) 
    end 
end 
) 

 

Link to comment
On 23.06.2018 at 00:17, N3xT said:

addEventHandler ( "onClientGUIClick" , root,	function ( )		if ( source == button1 ) then			triggerServerEvent("addTime", localPlayer, getPlayerName ( localPlayer ), 20)		end	end)

 

نكست انا بدي لما يضغط علا الزر يشتري ساعات محددة بفلوس محددة واذا ماكان معه فلوس يقله ليس لديك المال محاولتي 

addEvent("button5",true)  
addEventHandler("button5",root, 
	function() 
		local playerMoney = getPlayerMoney ( source )
		local addTime = 5000 -- السعر
			if ( playerMoney >= addTime ) then
                triggerServerEvent("addTime", localPlayer, getPlayerName ( localPlayer ), 20)--الساعات 
				takePlayerMoney ( source, addTime )
			else
				outputChatBox("You don't have enough money", source, 255, 255, 255, true)
			end
		end
	end
)

 

Link to comment
8 hours ago, N3xT said:

التحقق من الفلوس خليه بالسيرفر سايد, لأن الكلنت يرجع لك قيمة خاطئة احياناً

لما سويته سيرفر صار يعطي الاعب فلوس المحددة كيف اسويه كلنت والأكواد سيرفر سايد تقصد اسوي ترايقر  ماعرف اسوي ترايقر من سيرفر للكلت 

Link to comment

20 = الساعات

5000 = الفلوس

addEventHandler ( "onClientGUIClick" , root,
	function ( )
		if ( source == button1 ) then
			triggerServerEvent("addTime", localPlayer, "buy", 20, 5000, getPlayerName ( localPlayer ))
		end
	end
)

 

واستبدل ذا باللي عندك



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) 
      outputChatBox ("#FF0000* #ffffff [#ff0000 تم اعطاك ساعات #ffffff] ",plr,0, 255, 0,true ) 
    else 
      outputChatBox ("#FF0000* #ffffff [#ff0000 تم التوزيع من قبل #ffffff] ",plr,0, 255, 0,true ) 
    end 
   end 
  end 
 end 
end 
) 

addEventHandler("addTime",root, 
	function (to,time,prize,name) 
		if to == "all" then 
			for _,v in ipairs(getElementsByType("player")) do 
				addPlayerTime(v,time) 
				outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم توزيع ساعات لجميع الاعبين #ffffff] ",plr,0, 255, 0,true ) 
			end 
		if to == "buy" then
			if ( name and name ~= "" ) then
				if ( prize and prize ~= 0 ) then
					local plr = getPlayerFromName ( name )  
					if ( plr ) then
						if ( getPlayerMoney ( plr ) >= prize ) then
							addPlayerTime(plr,time) 
							outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم اضافة ساعات الى حسابك #ffffff] ",plr,0, 255, 0,true ) 
							takePlayerMoney ( plr, prize )
						else
							outputChatBox ("#FF0000* #ffffff ليس لديك مال كافي",plr,0, 255, 0,true ) 
						end
					end
				end
			end
		else 
			local plr = getPlayerFromName(to) 
			if plr then 
				addPlayerTime(plr,time) 
				outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم اضافة ساعات الى حسابك #ffffff] ",plr,0, 255, 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 ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم حذف ساعات من جميع الاعبين #ffffff] ",v,0, 255, 0,true ) 
  end 
  else 
   plr = getPlayerFromName(to) 
    if plr then 
    removePlayerTime(plr,time) 
    outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم حذف ساعات من حسابك #ffffff] ",plr,0, 255, 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('T1', 
function(thePlayer) 
    if getPlayerSerial (thePlayer) == "B83098E832E840D8C1BE0151CE8A58A1" then 
        triggerClientEvent(thePlayer,'openn',thePlayer) 
    end 
end 
) 

addCommandHandler(' هنا الكلمة الي تكتبها في اف 8 عشان تقدر توزيع ساعات ', 
function(thePlayer) 
    if getPlayerSerial (thePlayer) == " هنا حط سريال خويك  لافتح الوحه له " then 
        triggerClientEvent(thePlayer,'openn',thePlayer) 
    end 
end 
) 

 

Link to comment
12 hours ago, N3xT said:

20 = الساعات

5000 = الفلوس


addEventHandler ( "onClientGUIClick" , root,	function ( )		if ( source == button1 ) then			triggerServerEvent("addTime", localPlayer, "buy", 20, 5000, getPlayerName ( localPlayer ))		end	end)

 

واستبدل ذا باللي عندك


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)       outputChatBox ("#FF0000* #ffffff [#ff0000 تم اعطاك ساعات #ffffff] ",plr,0, 255, 0,true )     else       outputChatBox ("#FF0000* #ffffff [#ff0000 تم التوزيع من قبل #ffffff] ",plr,0, 255, 0,true )     end    end   end  end end ) addEventHandler("addTime",root, 	function (to,time,prize,name) 		if to == "all" then 			for _,v in ipairs(getElementsByType("player")) do 				addPlayerTime(v,time) 				outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم توزيع ساعات لجميع الاعبين #ffffff] ",plr,0, 255, 0,true ) 			end 		if to == "buy" then			if ( name and name ~= "" ) then				if ( prize and prize ~= 0 ) then					local plr = getPlayerFromName ( name )  					if ( plr ) then						if ( getPlayerMoney ( plr ) >= prize ) then							addPlayerTime(plr,time) 							outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم اضافة ساعات الى حسابك #ffffff] ",plr,0, 255, 0,true ) 							takePlayerMoney ( plr, prize )						else							outputChatBox ("#FF0000* #ffffff ليس لديك مال كافي",plr,0, 255, 0,true ) 						end					end				end			end		else 			local plr = getPlayerFromName(to) 			if plr then 				addPlayerTime(plr,time) 				outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم اضافة ساعات الى حسابك #ffffff] ",plr,0, 255, 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 ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم حذف ساعات من جميع الاعبين #ffffff] ",v,0, 255, 0,true )   end   else    plr = getPlayerFromName(to)     if plr then     removePlayerTime(plr,time)     outputChatBox ("#FF0000* #ffffff [ #ff0000"..time.." #ffffff]  #ffffff [#ff0000 تم حذف ساعات من حسابك #ffffff] ",plr,0, 255, 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('T1', function(thePlayer)     if getPlayerSerial (thePlayer) == "B83098E832E840D8C1BE0151CE8A58A1" then         triggerClientEvent(thePlayer,'openn',thePlayer)     end end ) addCommandHandler(' هنا الكلمة الي تكتبها في اف 8 عشان تقدر توزيع ساعات ', function(thePlayer)     if getPlayerSerial (thePlayer) == " هنا حط سريال خويك  لافتح الوحه له " then         triggerClientEvent(thePlayer,'openn',thePlayer)     end end ) 

 

الأكواد غلط بدلته ماعاد يطلع في التاب الساعات ولا شي

هي اكواد السيرفر الي عندي

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) 
      outputChatBox ("#000000||=[Twze3_System]=|| :#00FF00 تم اعطائك الساعات ", source, 0, 255, 0) 
    else 
      outputChatBox ("#000000||=[Twze3_System]=|| :#FF0000 تم اعطائك ساعات من قبل", source, 255, 0, 0) 
    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) == "0201F96FC2B860A7CE6716140C7828F3" then 
        triggerClientEvent(thePlayer,'openn',thePlayer) 
    end 
end 
) 

 

Edited by MR_Mahmoud
Link to comment
4 minutes ago, N3xT said:

الديبق؟

كنت مخربط فوق حاطط اكواد مود ثاني اكواد المود هي هية 

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) 
      outputChatBox ("#000000||=[Twze3_System]=|| :#00FF00 تم اعطائك الساعات ", source, 0, 255, 0) 
    else 
      outputChatBox ("#000000||=[Twze3_System]=|| :#FF0000 تم اعطائك ساعات من قبل", source, 255, 0, 0) 
    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) == "0201F96FC2B860A7CE6716140C7828F3" then 
        triggerClientEvent(thePlayer,'openn',thePlayer) 
    end 
end 
) 

 

Link to comment

لو سويتها بسكربت لحاله أفضل
باستخدام 

triggerEvent ( "addTime", source, getPlayerName(source),tonumber(1) )

بدون ما تعدل بمود الساعات

جرب بمود مستقل *
Server

addEvent("BuyTime",true)
addEventHandler("BuyTime",root,
	function ()
		if not isGuestAccount(getPlayerAccount(source)) then
			if getPlayerMoney(source) >= tonumber(50000) then	
				takePlayerMoney(source,50000)
				triggerEvent ( "addTime", source, getPlayerName(source),tonumber(1) ) -- 1 عدد الساعات
				outputChatBox("* تم الشراء ",source,0,255,0)
			else
				outputChatBox("* You Don't Have Enough Money",source,255,0,0)
			end
		else
			outputChatBox("* You Are Not Logged In",source,255,0,0)
		end
	end
)

Client 

addEventHandler("onClientGUIClick",root,
	function ()
		if source == buy then
				triggerServerEvent("BuyTime",localPlayer)
			end
	end
)

واذا كان فيه خطأ اتمنى المعذرهـ *
لأن ما افهم كثير بالتريقر

Edited by بويكا
  • Thanks 1
Link to comment

استبدل ذا بالسيرفر, واستعمل كودي الاول حق الزر عشان تعطيه الساعات

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) 
      outputChatBox ("#000000||=[Twze3_System]=|| :#00FF00 تم اعطائك الساعات ", source, 0, 255, 0) 
    else 
      outputChatBox ("#000000||=[Twze3_System]=|| :#FF0000 تم اعطائك ساعات من قبل", source, 255, 0, 0) 
    end 
   end 
  end 
 end 
end 
) 

addEventHandler("addTime",root, 
	function (to,time,prize,name) 
		if to == "all" then 
			for _,v in ipairs(getElementsByType("player")) do 
				addPlayerTime(v,time) 
				outputChatBox ("تم توزيع "..time.." ساعة لـ جميع اللاعبين",v,255,0,0,true ) 
			end 
		elseif to == "buy" then
			if ( name and name ~= "" ) then
				if ( prize and prize ~= 0 ) then
					local plr = getPlayerFromName ( name )  
					if ( plr ) then
						if ( getPlayerMoney ( plr ) >= prize ) then
							addPlayerTime(plr,time) 
							outputChatBox ("تم أضافة "..time.." ساعة الى حسابككـ",plr,255,0,0,true ) 
							takePlayerMoney ( plr, prize )
						else
							outputChatBox ("#FF0000* #ffffff ليس لديك مال كافي",plr,0, 255, 0,true ) 
						end
					end
				end
			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) == "0201F96FC2B860A7CE6716140C7828F3" then 
        triggerClientEvent(thePlayer,'openn',thePlayer) 
    end 
end 
) 

 

  • Like 1
Link to comment

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