Jump to content

مشكله بسيطء


saef

Recommended Posts

لسسسسلآم عليكمء كيفكمء شباب عسسسآكم بخير^^

اليوم معي مود ساعات حق واي فاي

ابي لم اسوي له رسترت م تروح الساعات تبقي

اكواد كلنت

  
  
GUIEditor = { 
    checkbox = {}, 
    staticimage = {}, 
    edit = {}, 
    button = {}, 
    window = {}, 
    label = {}, 
    gridlist = {} 
} 
  
    function cr() 
         GUIEditor.window[1] = guiCreateWindow(384, 91, 524, 553, "Give Time By #[iMr]-W[i]Fi,!", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1],false) 
        GUIEditor.gridlist[1] = guiCreateGridList(10, 56, 206, 327, false, GUIEditor.window[1]) 
        local PlayerName =  guiGridListAddColumn(GUIEditor.gridlist[1], "آسـم الاعــب", 0.4) 
        local PlayerTime =  guiGridListAddColumn(GUIEditor.gridlist[1], "ســآعآآت", 0.4) 
        GUIEditor.edit[1] = guiCreateEdit(247, 86, 246, 32, "", false, GUIEditor.window[1]) 
        GUIEditor.label[1] = guiCreateLabel(443, 57, 209, 19, "آلــعــدد :", false, GUIEditor.window[1]) 
        GUIEditor.checkbox[1] = guiCreateCheckBox(243, 149, 151, 18, "تــحــديــد آلــكــل", false, false, GUIEditor.window[1]) 
        GUIEditor.button[1] = guiCreateButton(240, 322, 107, 45, "زيــادةة ++", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF00FF00") 
        GUIEditor.button[2] = guiCreateButton(394, 322, 107, 45, "ســحــب - -", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFF0000") 
        GUIEditor.edit[2] = guiCreateEdit(12, 29, 204, 21, "بــحــث ....", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(1, 390, 566, 15, "_______________________________________________________________________________________________________________________", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[2], "default-bold-small") 
        guiLabelSetColor(GUIEditor.label[2], 255, 0, 0) 
        GUIEditor.label[3] = guiCreateLabel(421, 427, 90, 15, "آلــكــلــمـةة :", false, GUIEditor.window[1]) 
        GUIEditor.edit[3] = guiCreateEdit(385, 452, 129, 18, "", false, GUIEditor.window[1]) 
        GUIEditor.label[4] = guiCreateLabel(62, 427, 90, 15, "آلــســآآعــآآت :", false, GUIEditor.window[1]) 
        GUIEditor.edit[4] = guiCreateEdit(47, 452, 129, 18, "", false, GUIEditor.window[1]) 
        GUIEditor.button[3] = guiCreateButton(216, 500, 133, 37, "مـوآفــق", false, GUIEditor.window[1]) 
        guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FF00FF00") 
        GUIEditor.edit[5] = guiCreateEdit(216, 452, 129, 18, "", false, GUIEditor.window[1]) 
        GUIEditor.label[5] = guiCreateLabel(245, 427, 90, 15, "آلــمـدةة :", false, GUIEditor.window[1]) 
        GUIEditor.staticimage[1] = guiCreateStaticImage(321, 187, 117, 96, "logo.png", false, GUIEditor.window[1]) 
    end 
addEventHandler("onClientResourceStart", resourceRoot,cr) 
addEventHandler("onClientGUIClick",root, 
function () 
 if source == GUIEditor.checkbox[1] then 
  if guiCheckBoxGetSelected(source) then 
  guiGridListSetSelectedItem(GUIEditor.gridlist[1],-1,-1) 
  end 
 elseif source == GUIEditor.gridlist[1] then 
  if guiCheckBoxGetSelected(GUIEditor.checkbox[1]) then 
  guiCheckBoxSetSelected(GUIEditor.checkbox[1],false) 
  end 
  elseif source == GUIEditor.edit[2] then 
   if guiGetText(source) == "بــحــث ...." then 
    guiSetText(source,"") 
   end 
  elseif source == GUIEditor.button[1] and guiGetText(GUIEditor.edit[1]) ~= "" and tonumber(guiGetText(GUIEditor.edit[1])) then 
    if guiCheckBoxGetSelected(GUIEditor.checkbox[1]) then 
    triggerServerEvent("addTime",root,"all",tonumber(guiGetText(GUIEditor.edit[1]))) 
    else 
     triggerServerEvent("addTime",root,guiGridListGetItemText(GUIEditor.gridlist[1],guiGridListGetSelectedItem(GUIEditor.gridlist[1]),1),tonumber(guiGetText(GUIEditor.edit[1]))) 
  end 
    elseif source == GUIEditor.button[2] and guiGetText(GUIEditor.edit[1]) ~= "" and tonumber(guiGetText(GUIEditor.edit[1])) then 
    showCursor(not guiGetVisible(GUIEditor.window[1])) 
  guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) 
    if guiCheckBoxGetSelected(GUIEditor.checkbox[1]) then 
    triggerServerEvent("removeTime",root,"all",tonumber(guiGetText(GUIEditor.edit[1]))) 
    else 
     triggerServerEvent("removeTime",root,guiGridListGetItemText(GUIEditor.gridlist[1],guiGridListGetSelectedItem(GUIEditor.gridlist[1]),1),tonumber(guiGetText(GUIEditor.edit[1]))) 
  end 
  elseif source == GUIEditor.button[3] and guiGetText(GUIEditor.label[3]) ~= "" and guiGetText(GUIEditor.label[4]) ~= "" and guiGetText(GUIEditor.label[5]) ~= "" then 
  triggerServerEvent("ToServer",root,guiGetText(GUIEditor.edit[3]),guiGetText(GUIEditor.edit[4]),guiGetText(GUIEditor.edit[5])) 
  showCursor(not guiGetVisible(GUIEditor.window[1])) 
  guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) 
 end 
end 
) 
addEventHandler("onClientGUIChanged",root, 
function () 
 if source == GUIEditor.edit[2] then 
searchgd(GUIEditor.gridlist[1],guiGetText(source)) 
 end 
end 
) 
function getPlayerTime(plr) 
return getElementData(plr,"PlayTime") 
end 
function SetPlayersInGD( GridList ) 
 if GridList then 
  if getElementType ( GridList ) == "gui-gridlist" then 
   if guiGridListClear ( GridList ) then 
    for i, v in next, getElementsByType ( "player" ) do 
     local Row = guiGridListAddRow ( GridList ) 
      guiGridListSetItemText ( GridList, Row, 1, getPlayerName ( v ), false, false ) 
      guiGridListSetItemText ( GridList, Row, 2, getPlayerTime( v ), false, false ) 
    end 
   end 
  end 
 end 
end 
function searchgd(GridList,name) 
 if guiGridListClear ( GridList ) then 
    for i, v in next, getElementsByType ( "player" ) do 
     if not string.find(getPlayerName(v),name) then return end 
     local Row = guiGridListAddRow ( GridList ) 
      guiGridListSetItemText ( GridList, Row, 1, getPlayerName ( v ), false, false ) 
      guiGridListSetItemText ( GridList, Row, 2, getPlayerTime( v ), false, false ) 
    end 
   end 
end 
addEvent('openn',true) 
addEventHandler('openn',root, 
function () 
  showCursor(not guiGetVisible(GUIEditor.window[1])) 
  guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) 
  SetPlayersInGD(GUIEditor.gridlist[1]) 
  guiSetText(GUIEditor.edit[1],"") 
  guiSetText(GUIEditor.edit[2],"بــحــث ....") 
  guiSetText(GUIEditor.edit[3],"") 
  guiSetText(GUIEditor.edit[4],"") 
  guiSetText(GUIEditor.edit[5],"") 
end 
) 
  

وهذا اكواد حق السيرفر

  
exports.scoreboard:addScoreboardColumn('PlayTime') 
addEvent("addTime",true) 
addEvent("removeTime",true) 
addEvent("ToServer",true) 
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) 
  end 
  else 
   plr = getPlayerFromName(to) 
    if plr then 
    addPlayerTime(plr,time) 
    end 
 end 
end 
) 
addEventHandler("removeTime",root, 
function (to,time) 
 if to == "all" then 
  for _,v in ipairs(getElementsByType("player")) do 
   removePlayerTime(v,time) 
  end 
  else 
   plr = getPlayerFromName(to) 
    if plr then 
    removePlayerTime(plr,time) 
    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 onPlayerQuit ( ) 
    local playeraccount = getPlayerAccount ( source ) 
    if ( playeraccount ) and not isGuestAccount ( playeraccount ) 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 ) 
        setAccountData ( playeraccount, "PlayTime-hour", tostring(hour) ) 
        setAccountData ( playeraccount, "PlayTime-min", tostring(min) ) 
        setAccountData ( playeraccount, "PlayTime-sec", tostring(sec) ) 
        setAccountData ( playeraccount, "PlayTime", tostring(sValue) ) 
  
    end 
    t[ source ] = nil 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local time = getAccountData ( playeraccount, "PlayTime" ) 
    local hou = getAccountData ( playeraccount, "PlayTime-hour") 
    local min = getAccountData ( playeraccount, "PlayTime-min") 
    local sec = getAccountData ( playeraccount, "PlayTime-sec") 
        if ( time ) then 
            setElementData ( source, "PlayTime", time ) 
  
                             t[ source ]["hour"] = tonumber(hou) 
                             t[ source ]["min"] = tonumber(min) 
                             t[ source ]["sec"] = tonumber(sec) 
                else 
            setElementData ( source, "PlayTime",0 ) 
            setAccountData ( playeraccount, "PlayTime",0 ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) 
  
  
  
  
local Serial = { 
"8523AD61CFF15B5F74785FF90960DA43", 
"26E5822441E3E178C15C2BA5848576F2", 
} 
  
addCommandHandler('لوحة', 
function(thePlayer) 
    if getPlayerSerial(thePlayer) ~= Serial then 
        outputChatBox('* Welcome !',thePlayer,0,155,255,true) 
        triggerClientEvent(thePlayer,'openn',thePlayer) 
        else 
        outputChatBox('* You not have permission to Access',thePlayer,255,0,0,true) 
    end 
end 
) 
  
  

Link to comment

-- # 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') 
  
addEventHandler("onResourceStart",resourceRoot, 
    function (      ) 
            executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Prestege_Save_Time ( 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 Prestege_Save_Time WHERE PlayerSerial=?",serial) 
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then 
        executeSQLQuery ( "INSERT INTO Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)",serial,hour,min,sec,sValue ) 
    else 
        executeSQLQuery('UPDATE Prestege_Save_Time 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 Prestege_Save_Time WHERE PlayerSerial=?",getPlayerSerial ( v ) ) 
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then 
        executeSQLQuery ( "INSERT INTO Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)",serial,hour,min,sec,sValue ) 
    else 
        executeSQLQuery('UPDATE Prestege_Save_Time 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 Prestege_Save_Time 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 Prestege_Save_Time 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
-- # 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') 
  
addEventHandler("onResourceStart",resourceRoot, 
    function (      ) 
            executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Prestege_Save_Time ( 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 Prestege_Save_Time WHERE PlayerSerial=?",serial) 
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then 
        executeSQLQuery ( "INSERT INTO Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)",serial,hour,min,sec,sValue ) 
    else 
        executeSQLQuery('UPDATE Prestege_Save_Time 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 Prestege_Save_Time WHERE PlayerSerial=?",getPlayerSerial ( v ) ) 
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then 
        executeSQLQuery ( "INSERT INTO Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)",serial,hour,min,sec,sValue ) 
    else 
        executeSQLQuery('UPDATE Prestege_Save_Time 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 Prestege_Save_Time 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 Prestege_Save_Time 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
-- # 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') 
  
addEventHandler("onResourceStart",resourceRoot, 
    function (      ) 
            executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Prestege_Save_Time ( 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 Prestege_Save_Time WHERE PlayerSerial=?",serial) 
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then 
        executeSQLQuery ( "INSERT INTO Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)",serial,hour,min,sec,sValue ) 
    else 
        executeSQLQuery('UPDATE Prestege_Save_Time 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 Prestege_Save_Time WHERE PlayerSerial=?",getPlayerSerial ( v ) ) 
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then 
        executeSQLQuery ( "INSERT INTO Prestege_Save_Time ( PlayerSerial,Hours,Minuts,Seconds,PlayAllTime ) VALUES(?,?,?,?,?)",serial,hour,min,sec,sValue ) 
    else 
        executeSQLQuery('UPDATE Prestege_Save_Time 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 Prestege_Save_Time 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 Prestege_Save_Time 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
:) لو تتعلم البرمجة احسن لك لأنك بعد كذا تقدر تسوي مثل ذا المود او حتي تقدر تعدل عليه من نفسك

انا اعرف وسط بس ي الغالي ابيه يحفظ على الحسسساب

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