Wysłany: 2016-02-14, 16:13
P.Wiśnia
Programista LUA
Wiek: 24 Na forum: 4045 dni Posty: 568
Nick w MP: P.Wiśnia
Piwa : 376
Jak w tym skrypcie zrobi? ?eby id by?o przy nicku.
Prosze o pomoc a nie danie linka do funkcji.
Kod: 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("Znaleziono wiecej niz jednego gracza o pasujacym nicku, podaj wiecej liter.", 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-02-14, 16:25
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
Musisz do kodu na nametagi, doda? (getElementData(localPlayer, "id))
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Wysłany: 2016-02-14, 17:10
P.Wiśnia
Programista LUA
Wiek: 24 Na forum: 4045 dni Posty: 568
Nick w MP: P.Wiśnia
Piwa : 376
czyli gdzie prosze o pomoc
Wysłany: 2016-02-14, 20:05
Fanciak
BOT
Wiek: 25 Na forum: 4446 dni Posty: 728
Nick w MP: Fanciak
Piwa : 1572
No pewnie tam, gdzie masz system nick?w, nie? I nie prosisz o pomoc, tylko o gotowca, a to wieeeelka r??nica.
Otwierasz sw?j system nametag?w, szukasz linijki z tworzeniem nicku i obok nicku dodajesz np .
( "..getElementData(plr, " ID ").." ) i lecisz, metod? pr?b i b??d?w.
Tagi: przy :: nicku
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: