Jump to content

تصحيح كود


Recommended Posts

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

ابي مساعدة بشيئين

معي مشكلة بكون ابي اطلع ساعات الاعب في سكور بورد التكتيك

محاولتي

exports.scoreboard:addScoreboardColumn('PlayTime')

function getPlayerTime ( Player )
	local TimeData = getElementData(Player,'PlayTime') or '0:0';
	if ( TimeData ) then
		return tonumber(split(TimeData,':')[1]) , tonumber(split(TimeData,':')[2]);
	end 
end

ثاني شئ في التكتيك الفلوس تكون مخفية وش اسوي مشان اظهرها مابي تختفي حتي لو خرجت ودخلت او قتلت

ابيها ظاهرة دائما وشكراا

Link to comment
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 )

@Abdul KariM

صح كدا؟؟

سويتة كدا ماظهرت في تاب التكتيك

Link to comment
1 minute ago, No_name said:

@Abdul KariM

اسم التاب ماعرفة اسم تاب التكتيك ماعرفة

لانة مشفر

آكتب ببحث آلمودآت بلوحة آلآدمن كلمة

score

بتحصل يمكن scoreboard1 آو 2

آلمهم آلآسم آلي تحصله وآلمود تحصله شغآل حط آسم آلمود بآلآكسبورت ..

Link to comment
12 minutes ago, No_name said:

Mr.Mostafa

اخي قولت لك التاب تبع مود التكتيك ومود التكتيك مشففررر

ماهو مشفر يقدر يخش ملف arena.lua - ctf.lua و بيلاقي داتا حق التاب يقدر يبدل الدمج - كيلز - او الديث و يحط بداله PlayTime او حسب الداتا عنده

اهم شيء بس يحفظ الساعات - لانه لو رستر القيم مود او السيرفر تتصفر :)

Edited by [T]|O|[P]George
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...