Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2019-07-11, 22:37


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot?? chcia?bym zrobi? co? takiego by nie mierzy?o ostatnich przejazd?w, lecz by by?a topka np top 10 naj czas?w. I jak kto? ma dobry czas niech ten czas si? aktualizuje na lepszy.
Jest to kod na 1/4 mili
s_side
addEvent("mila:koniec",true)
addEventHandler("mila:koniec",resourceRoot,function(czas,veh)
if not czas then return end
if not veh then return end
local uid=getElementData(client,"player:uid")
exports["ogrpg-db"]:dbSet("REPLACE INTO Ranking_14mila (uid, model, time) VALUES(?, ?, ?)"uidgetVehicleName(veh), czas)
end)

str="1/4 TOP 10 !"
local t=createElement("text")
setElementData(t,"scale",1)
setElementPosition(t,-2927.30, -1182.359.82+1.1)
createBlip(-2927.30, -1182.359.8233)

function aktualizujText()
    local q=exports["ogrpg-db"]:dbGet("select DISTINCT Ranking_14mila.*,ogrpg_users.login,ogrpg_users.login2 from Ranking_14mila inner join ogrpg_users on Ranking_14mila.uid=ogrpg_users.id order by time asc limit 10")
    str="\nRanking 1/4 mili(Ostatni czas):"
    for i,v in ipairs(q) do
                if v["login2"] == false then
                    str=""..str.."\n"..i..". "..v["login"].." ("..v["model"]..") - "..string.format("%0.2f",v["time"]).."s"
                else
                    str=""..str.."\n"..i..". "..v["login2"].." - ("..v["model"]..") - "..string.format("%0.2f",v["time"]).."s"
                end
    end
    setElementData(t"name"str)
end
setTimer(aktualizujText500)
aktualizujText()

Za pomoc piwko i rep

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-11, 22:41


DylemaT929

Nikt






Wiek: 28
Na forum: 4041 dni
Posty: 333
Nick w MP: dylemat929

Piwa: 3195

Respekt: 165,8
Respekt: 165,8Respekt: 165,8

to

local q=exports["ogrpg-db"]:dbGet("select DISTINCT Ranking_14mila.*,ogrpg_users.login,ogrpg_users.login2 from Ranking_14mila inner join ogrpg_users on Ranking_14mila.uid=ogrpg_users.id order by time asc limit 10")


zmie? na to

local q=exports["ogrpg-db"]:dbGet("select DISTINCT Ranking_14mila.*,ogrpg_users.login,ogrpg_users.login2 from Ranking_14mila inner join ogrpg_users on Ranking_14mila.uid=ogrpg_users.id order by time DESC LIMIT 10")


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-11, 23:09


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Mordko, jest cos takiego ze 10 miejsce ma najkrotszy czas a 1 miejsce najdluzszy, tak by to odwrocic chcial.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-11, 23:35


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Poczytaj o "order by" w MySQL. Dzi?ki temu w takiej kolejno?ci ci to zwraca.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-12, 09:34


Malentas

Koder mirofali w lua






Wiek: 24
Na forum: 3681 dni
Posty: 146
Nick w MP: Malentas

Piwa: 1626

Respekt: 47,3

Odwr?? tabele

Funkcja na odwracanie tabeli:

function ReverseTable(t)
    local reversedTable = {}
    local itemCount #t
    for kv in ipairs(t) do
        reversedTable[itemCount k] = v
    end
    return reversedTable
end


Przyk?ad

for iv in ipairs(ReverseTable(tabela) do

end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-12, 23:39


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

w tej linicje


    local itemCount #t



taki b??d
Kod:


to get lenght local 't' (a buk value)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-13, 19:11


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wska? w kodzie, jak? tabel? chcesz u?yj w tej odwracaj?cej funkcji. Przypominam, ?e musi to by? tabela.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-13, 20:17


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Funkcja reverseTable kt?ra mi daliscie jest na tabele, a po co mu tabela skoro on ma "zwrot" z mysql.

Dodaj?c po ORDER BY "tabela" DESC

s?owo "desc", odwraca ci wszystko. To ca?a filozofia.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-13, 22:50


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Shuffle To jak to poprawnie zrobi? ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-16, 22:47


Adaskokieblasko







Wiek: 23
Na forum: 2954 dni
Posty: 101

Piwa: 18

Respekt: 100
Respekt: 100

Chcesz odwr?ci? tabele ?
 local q=exports["ogrpg-db"]:dbGet("select DISTINCT Ranking_14mila.*,ogrpg_users.login,ogrpg_users.login2 from Ranking_14mila inner join ogrpg_users on Ranking_14mila.uid=ogrpg_users.id order by time DESC LIMIT 10" 

zmie? na
 local q=exports["ogrpg-db"]:dbGet("select DISTINCT Ranking_14mila.*,ogrpg_users.login,ogrpg_users.login2 from Ranking_14mila inner join ogrpg_users on Ranking_14mila.uid=ogrpg_users.id order by time ASC LIMIT 10"

Powinno by? git

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-16, 23:26


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Wszystko git, tylko ?e pokazuje ostatni czas a nie top 10. Np zrobie czas 1.10 sek. A drugim razem 2.12sek to zapisuje si? nie topowy a ostatni czas.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-17, 01:49


Adaskokieblasko







Wiek: 23
Na forum: 2954 dni
Posty: 101

Piwa: 18

Respekt: 100
Respekt: 100

Musisz doda? por?wnywanie czasu z DB z czasem przejechanym obecnym razem i doda? warunek je?eli obecny czas jest mniejszy ni? ten w DB wtedy nadpisujesz

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-17, 18:58


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Rozumiem, lecz jestem w to zupe?nie zielony pom?g? bys co? wi?cej ?

Postaw piwo autorowi tego posta
 

 
Tagi: top
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku