Jump to content

x[ تعديل ]x مود الساعات


Recommended Posts

سلام عليكم معي مود الساعات فبي تاب

وشغال تمام

الكود

exports.scoreboard:addScoreboardColumn('Played') 
  
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, 
                "Played", 
                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,'Online Time' ) 
        setAccountData ( playeraccount, "Online Time", tostring(sValue) ) 
    end 
    t[ source ] = nil 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local time = getAccountData ( playeraccount, "Online Time" ) 
        if ( time ) then 
            setElementData ( source, "Played", time ) 
                else 
            setElementData ( source, "Played",0 ) 
        setAccountData ( playeraccount, "Played",0 ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) 

لما حطيتها كدا

exports.scoreboard:addScoreboardColumn('Time')

صار م يجي وقت في تاب

Link to comment

جرب

exports.scoreboard:addScoreboardColumn('Time') 
  
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, 
                "Time", 
                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,'Online Time' ) 
        setAccountData ( playeraccount, "Online Time", tostring(sValue) ) 
    end 
    t[ source ] = nil 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local time = getAccountData ( playeraccount, "Online Time" ) 
        if ( time ) then 
            setElementData ( source, "Time", time ) 
                else 
            setElementData ( source, "Time",0 ) 
        setAccountData ( playeraccount, "Time",0 ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) 

Link to comment
exports.scoreboard:addScoreboardColumn('Time') 
  
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, 
                "Time", 
                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,'Time' ) 
        setAccountData ( playeraccount, "Online Time", tostring(sValue) ) 
    end 
    t[ source ] = nil 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local time = getAccountData ( playeraccount, "Online Time" ) 
        if ( time ) then 
            setElementData ( source, "Time", time ) 
                else 
            setElementData ( source, "Time",0 ) 
        setAccountData ( playeraccount, "Time",0 ) 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) 

Link to comment

اهلاً بك عزيزي, قمت بالتعديل على السكربت الاصلي لكي يقوم بحفظ الساعات وتفادي مشكلة فقدان الساعات نهائياً

Server :

--[[ 
------------------------------------------------- 
original script 
credits to Yakuza.Real and solidsnake and kenix 
viewtopic.php?f=91&t=40132 
  
------------------------------------------------- 
  
booo just fix it 
  
]] 
exports.scoreboard:addScoreboardColumn('Time') 
  
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, 
                "Time", 
                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,'Time' ) 
        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, "Time-hour", tostring(hour) ) 
        setAccountData ( playeraccount, "Time-min", tostring(min) ) 
        setAccountData ( playeraccount, "Time-sec", tostring(sec) ) 
        setAccountData ( playeraccount, "Time", tostring(sValue) ) 
    end 
    t[ source ] = nil 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local time = getAccountData ( playeraccount, "Time" ) 
        local hou = getAccountData ( playeraccount, "Time-hour") 
        local min = getAccountData ( playeraccount, "Time-min") 
        local sec = getAccountData ( playeraccount, "Time-sec") 
        if ( time ) then 
            setElementData ( source, "Time", time ) 
            t[ source ]["hour"] = tonumber(hou) 
            t[ source ]["min"] = tonumber(min) 
            t[ source ]["sec"] = tonumber(sec) 
        else 
            setElementData ( source, "Time",0 ) 
            setAccountData ( playeraccount, "Time",0 ) 
            t[ source ]["hour"] = 0 
            t[ source ]["min"] = 0 
            t[ source ]["sec"] = 0 
        end 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) 
  
addEventHandler ( "onPlayerLogout", root, function ( acc ) 
    local sValue = getElementData( source,'Time' ) 
    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 ( acc, "Time-hour", tostring(hour) ) 
    setAccountData ( acc, "Time-min", tostring(min) ) 
    setAccountData ( acc, "Time-sec", tostring(sec) ) 
    setAccountData ( acc, "Time", tostring(sValue) ) 
    t[ source ]["hour"] = 0 
    t[ source ]["min"] = 0 
    t[ source ]["sec"] = 0 
end ) 
  
addEventHandler("onResourceStart", resourceRoot, function () 
    for k,v in ipairs ( getElementsByType ( "player" ) ) do 
        if not ( isGuestAccount ( getPlayerAccount ( v ) ) ) then 
            if ( getAccountData ( getPlayerAccount ( v ), "Time" ) ) then 
                local hou = getAccountData ( getPlayerAccount ( v ), "Time-hour") 
                local min = getAccountData ( getPlayerAccount ( v ), "Time-min") 
                local sec = getAccountData ( getPlayerAccount ( v ), "Time-sec") 
                if not ( t [ v ] ) then 
                    t[ v ] = { 
                        ["hour"] = 0, 
                        ["min"] = 0, 
                        ["sec"] = 0 
                    } 
                end 
                t[ v ]["hour"] = tonumber(hou) 
                t[ v ]["min"] = tonumber(min) 
                t[ v ]["sec"] = tonumber(sec) 
            end 
        end 
    end 
end) 
  
addEventHandler("onResourceStop", resourceRoot, function () 
    for k,v in ipairs ( getElementsByType ( "player" ) ) do 
        if not ( isGuestAccount ( getPlayerAccount ( v ) ) ) then 
            local sValue = getElementData( v,'Time' ) 
            local hour = tonumber( t[ v ][ 'hour' ] or 0 ) 
            local min = tonumber( t[ v ][ 'min' ] or 0 ) 
            local sec = tonumber( t[ v ][ 'sec' ] or 0 ) 
            setAccountData ( getPlayerAccount ( v ), "Time-hour", tostring(hour) ) 
            setAccountData ( getPlayerAccount ( v ), "Time-min", tostring(min) ) 
            setAccountData ( getPlayerAccount ( v ), "Time-sec", tostring(sec) ) 
            setAccountData ( getPlayerAccount ( v ), "Time", tostring(sValue) ) 
        end 
    end 
end) 

Edited by Guest
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...