Jump to content

Top 5 , Data


Mr.Mostafa

Recommended Posts

سلام عليكم

ابي لو كتبت كوماند , يجيب 5 فقط من الي معهم داتا

بشرط ال 5 يكونو اعلي ناس

يعني يترتبوا بترتيب علي حسب اللفلات , الاعلي يكون بالاول وكدا

ـــ

+ كيف احطهم بلوحة دي اكس , تحت بعض الخمسة ذولا ؟

ــ

هادا الكود يجيب كل الي معه داتا الفل , لكن ما يرتبهم ولا يجيب 5 بس ’ لاني ما اعرف كودها

وشكرا مقدما

addCommandHandler("top",
	function()
		outputChatBox("Top 5 Level",root,255,0,0,true)
		for _ , v in ipairs ( getElementsByType ( 'player' ) ) do
			if getElementData(v,"dataLevel") then
				outputChatBox(""..getPlayerName(v).."",root,255,0,0,true)
			end
		end
	end
)

 

Link to comment
addCommandHandler('top', function()
    local players, topPlayers = getElementsByType'player', {};
    for index = 1, #players do
        local data = getElementData(players[index], 'dataLevel')
        if data then
            topPlayers[#topPlayers+1] = {player = players[index], playerData = data};
        end
    end

    table.sort(topPlayers, function(first, second)
        return first.playerData > second.playerData
    end)

    outputChatBox('Top 5 Level', root, 255, 0, 0, true)
    for index = 1, #topPlayers do
        outputChatBox(index..': '..getPlayerName(topPlayers[index].player), root, 255, 0, 0, true)
        if index >= 5 then
            outputChatBox('_________', root, 255, 0, 0, true)
            break
        end
    end
end)

 

Link to comment
  On 21/09/2018 at 00:59, #,xiRocKyz said:

بترجع الداتا والداتا حقته لفل يعني نمبر

Expand  

يا قلبي انا ما اعرف ليه نتجادل :D

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

@_@

+هي ترجع بمتغير طبيعة المتغير وش الله اعلم والله ما ابي افتيلك

تفضل اقرا بالويكي لو تبي تعرف

:D :D 

 

Link to comment
  On 21/09/2018 at 01:04, Master_MTA said:

يا قلبي انا ما اعرف ليه نتجادل :D

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

@_@

+هي ترجع بمتغير طبيعة المتغير وش الله اعلم والله ما ابي افتيلك

تفضل اقرا بالويكي لو تبي تعرف

:D :D 

 

Expand  

جرب بنفسك

addEventHandler('onResourceStart', resourceRoot, function()
    local number = {'first', 'second', 'third'};
    for index = 1, #number do
        local element = createElement('Master-is-wrong', number[index])
        setElementData(element, 'numbersData', index);
    end
end)

addCommandHandler('top', function()
    local players, topPlayers = getElementsByType'Master-is-wrong', {};
    for index = 1, #players do
        local data = getElementData(players[index], 'numbersData')
        if data then
            topPlayers[#topPlayers+1] = {player = players[index], playerData = data};
        end
    end

    table.sort(topPlayers, function(first, second)
        return first.playerData > second.playerData
    end)

    outputChatBox('Top 5 Level', root, 255, 0, 0, true)
    for index = 1, #topPlayers do
        outputChatBox(index..': '..getElementID(topPlayers[index].player), root, 255, 0, 0, true)
        if index >= 3 or index == #topPlayers then
            outputChatBox('_________', root, 255, 0, 0, true)
            break
        end
    end
end)

 

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