Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.
GTAONLINE.PL
Tematy otagowane jako: sortowanie
1. Sortowanie
Siemano, pom?g?by kto? z sortowaniem po id (oto m?j scoreboard), mam problem z funkcj? table.sort.
kod
[lua]
Class = {}


Class.Scroll = {

1,
5,
5,

}

function gui()

local screenW, screenH = guiGetScreenSize()


dxDrawImage(screenW * 0.2625, screenH * 0.1398, screenW * 0.4755, screenH * 0.3009, texture.background, 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText("Hej, Pyrek", screenW * 0.2625, screenH * 0.1491, screenW * 0.4135, screenH * 0.1898, tocolor(255, 255, 255, 255), 1.00, exports.amta_gui:pobierzFont('bfont25'), "center", "center", false, false, false, false, false)
dxDrawText("100/100", screenW * 0.6828, screenH * 0.1398, screenW * 0.7380, screenH * 0.1806, tocolor(255, 255, 255, 255), 1.00, exports.amta_gui:pobierzFont('bfont25'), "center", "center", false, false, false, false, false)
dxDrawText("Online:", screenW * 0.6427, screenH * 0.1398, screenW * 0.6828, screenH * 0.1806, tocolor(255, 255, 255, 255), 1.00, exports.amta_gui:pobierzFont('bfont25'), "center", "center", false, false, false, false, false)
dxDrawText("MoveRPG", screenW * 0.4625, screenH * 0.1343, screenW * 0.5380, screenH * 0.2046, tocolor(255, 255, 255, 255), 1.00, exports.amta_gui:pobierzFont('bfont35'), "center", "center", false, false, false, false, false)
dxDrawImage(screenW * 0.2625...
2. Sortowanie ID na tabie
Witam ot?? mam kod na scorboarda. Chcia?bym by id sortowa?o si? pokolei 1,2,3,4,5,6,7,8,9,10... itd.
kod
[lua]--[[
Autor: Asperek
Zakaz u?ywania bez zgody autora!
Zakaz udost?pniania bez zgody autora!
]]

--[[
Wszelkie prawa odkupione przez STOPseba!
]]--


local screenW, screenH = guiGetScreenSize()
local dxfont0_CaviarDreams_Bold = dxCreateFont(":guied/fonts/CaviarDreams_Bold.ttf", 30)
local dxfont1_CaviarDreams_Bold = dxCreateFont(":guied/fonts/CaviarDreams_Bold.ttf", 16)
local dxfont2_CaviarDreams_Bold = dxCreateFont(":guied/fonts/CaviarDreams_Bold.ttf", 14)
local dxfont3_CaviarDreams_Bold = dxCreateFont(":guied/fonts/CaviarDreams_Bold.ttf", 11)
local px,sy = guiGetScreenSize()
local px,py = (screenW/1920),(screenH/1080)
local zoom = 1
local fh = 1920
if px < fh then
zoom = math.min(2,fh/px)
end

-- tego nie ruszaj
local k = 1
local n = 19

local score = false

local font = dxCreateFont("font.ttf", 13) or "default-bold"

local ping = {}

local logo = false -- wylaczanie/wlaczanie loga w scoreboardzie

function dxDrawShadowText(text,x,y,w,h,color,size,font,x1,x2)

end

addEventHandler("onClientRender", root, function()
score = getKeyState("tab")
local gracze = getElementsByType("player")
if score ~= true then return end
-- werjsa z logiem
if logo == true then
dxDrawRectangle(screenW * 0.3068, screenH * 0.0370, screen...
3. Sortowanie danych otrzymanych z bazy danych.
Witam, pisz? skrypt na przechowywalnie pojazd?w i mam problem. Chcia?bym dodawa? otrzymane wyniki z bazy danych (id, model) do gridlist'y w gui przechowywalni, ale nie mam poj?cia, jak posortowa? dane, aby m?c je tam doda?. Co? z tablicami mo?e? Oto wynik, jaki otrzymuje:

1 - ID
411 - MODEL
10 - ID
411 - MODEL

function odbieramDane(result)
guiGridListClear(GUIEditor.gridlist[1])
if not result then return end
for rid, row in ipairs (result) do
for column, value in pairs (row)
if(column == "model_id") then
outputChatBox(value.." - MODEL")
end
if(column == "id") then
outputChatBox(value.." - ID")
local waluta =
end
end
end
end
addEvent("odbierzD", true)
addEventHandler( "odbierzD", localPlayer, odbieramDane )

Chcia?bym otrzymywa? dwie zmienne (id, model_id)
4. Sortowanie po autorze
Witam!

Mam pytanie jakich funkcji mam u?y? aby w gridliscie wyswietla? zazasoby serwera tylko te kt?rych jestem autorem. Poprostu zeby wy?wietlaly si? te w kt?rych moj nick == autor.

Za pomoc :piwo:
5. Sortowanie wartości w tabeli sqlite
Cze??. Pisz? skrypt na pr?b? czasow? i potrzebuj? posortowa? wyniki w tabeli sqlite od najmniejszej do najwi?kszej tylko za bardzo nie wiem jakiej funkcji u?y? albo zapytania(o ile tak to si? nazywa w sqlite - nie ogarniam tego praktycznie) dlatego przychodz? do was poprosi? o pomoc :D Za pomoc stawiam piwko ;)
6. sortowanie id
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?.

[lua]
--[[
Nadawanie ID graczom podczas po??czenia
Odszukiwanie graczy po id/fragmencie nicku
@author Lukasz Biegaj <[email protected]>
@copyright 2011-2013 Lukasz Biegaj <[email protected]>
@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=findFre...