Wysłany: 2016-05-26, 21:01
Xaar
Wiek: 25 Na forum: 5450 dni Posty: 47
Nick w MP: PLWESOLYKOSTEK
Piwa : 82
Mam taki kod od ID, lecz nie sortuje od najmniejszego do najwi?kszego, tzn. mam w tabie 0,2,1,4,5 (chcia?bym je mie? kolejno). Nie wiem jak to zrobi?.
--[[
Nadawanie ID graczom podczas po ?? czenia
Odszukiwanie graczy po id / fragmencie nicku
@ author Lukasz Biegaj < wielebny @ bestplay . pl >
@ copyright 2011 - 2013 Lukasz Biegaj < wielebny @ bestplay . pl >
@ license Dual GPLv2 / MIT
]]--
function findPlayer ( plr , cel )
local target = nil
if ( tonumber ( cel ) ~= nil ) then
target = getElementByID ( "p" .. cel )
else -- podano fragment nicku
for _ , thePlayer in ipairs ( getElementsByType ( "player" )) do
if string . find ( string . gsub ( getPlayerName ( thePlayer ): lower (), "#%x%x%x%x%x%x" , "" ), cel : lower (), 1 , true ) then
if ( target ) then
outputChatBox ( "Found more than 1 player. Please enter more letters" , plr )
return nil
end
target = thePlayer
end
end
end
return target
end
local function findFreeValue ( tablica_id )
table . sort ( tablica_id )
local wolne_id = 0
for i , v in ipairs ( tablica_id ) do
if ( v == wolne_id ) then wolne_id = wolne_id + 1 end
if ( v > wolne_id ) then return wolne_id end
end
return wolne_id
end
function assignPlayerID ( plr )
local gracze = getElementsByType ( "player" )
local tablica_id = {}
for i , v in ipairs ( gracze ) do
local lid = getElementData ( v , "id" )
if ( lid ) then
table . insert ( tablica_id , tonumber ( lid ))
end
end
local free_id = findFreeValue ( tablica_id )
setElementData ( plr , "id" , free_id )
setElementID ( plr , "p" .. free_id )
return free_id
end
function getPlayerID ( plr )
if not plr then return "" end
local id = getElementData ( plr , "id" )
if ( id ) then
return id
else
return assignPlayerID ( plr )
end
end
addEventHandler ( "onPlayerJoin" , getRootElement (), function()
assignPlayerID ( source )
end )
Wysłany: 2016-05-26, 21:29
mtm
</3
Wiek: 26 Na forum: 3716 dni Posty: 181
Piwa : 252
a do czego? konkretnego Ci to potrzebne, przecie? kolejno?? rekord?w nie ma znaczenia
Wysłany: 2016-05-26, 21:35
Xaar
Wiek: 25 Na forum: 5450 dni Posty: 47
Nick w MP: PLWESOLYKOSTEK
Piwa : 82
Po prostu chcia?bym mie? ?ad w panelu scoreboard, te? b?dzie szybciej odszuka? dan? osob? po id.
Wysłany: 2016-05-29, 00:16
Prezes.
Wiek: 27 Na forum: 4370 dni Posty: 75
Nick w MP: Prezes.
Piwa : 17
To nie b?dzie w skrypcie kt?ry Ci ustawia ID dla gracza.
Tylko w samym scoreboard, musisz przeanalizowa? sortowanie zawarte w scoreboard (dok?adnie jest do dxscoreboard_client.lua). Raczej nikt Ci tutaj nie da gotowego kodu, bo szczerze jest z tym troche 'zabawy'.
Wysłany: 2016-05-29, 09:56
Xaar
Wiek: 25 Na forum: 5450 dni Posty: 47
Nick w MP: PLWESOLYKOSTEK
Piwa : 82
Okej, dzi?ki. Mo?na zamkn??.
Tagi: sortowanie
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: