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

Wysłany: 2020-03-06, 15:32


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam, ot?? totalnie nie mam pomys?u, jak zrobi? randomowe punkty w dxDrawImage.
Tutaj tabela punkt?w
local mousePoints = {
{screenW * 0.3932, screenH * 0.4787, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.4516, screenH * 0.5213, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.5495, screenH * 0.5528, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.5969, screenH * 0.5065, screenW * 0.0198, screenH * 0.0296},
}
target=0

Tutaj kod na punkty. Chcia?bym go nieco przerobi?, by punkty by?y losowane z tabeli wy?ej
            addEventHandler("onClientRender", root, function()
                if getElementData(localPlayer, "kopalnia:zakonczono") then return end                
                dxDrawImage(mousePoints[target][1], mousePoints[target][2], mousePoints[target][3], mousePoints[target][4],"kolo.png")
            end)

Za pomoc zimne :piwo: :piwo: :piwo:

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-06, 17:57


P.Wiśnia

Programista LUA






Wiek: 25
Na forum: 4185 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 378

Respekt: 100
Respekt: 100

local mousePoints = {
{screenW * 0.3932, screenH * 0.4787, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.4516, screenH * 0.5213, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.5495, screenH * 0.5528, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.5969, screenH * 0.5065, screenW * 0.0198, screenH * 0.0296},
}
target=0
addEventHandler("onClientRender", root, function()
if getElementData(localPlayer, "kopalnia:zakonczono") then return end     
local x,y,w,h = mousePoints[rnd][1],mousePoints[rnd][2],mousePoints[rnd][3],mousePoints[rnd][4]          
dxDrawImage(x, y, w, h, "kolo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-06, 18:15


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W powy?szym kodzie nad linijk?
local x,y,w,h = mousePoints[rnd][1],mousePoints[rnd][2],mousePoints[rnd][3],mousePoints[rnd][4]


musisz dopisa? to:
local rnd = math.random(#mousePoints)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-07, 14:01


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Doda?em wszystko do kodu. Lecz jak wejde w marker, to punkty si? same losuj? i lataj? po ekranie, nie klikaj?c nic punkty same si? losuja i lataj? po ekranie.
kod

            addEventHandler("onClientRender", root, function()
                if getElementData(localPlayer, "kopalnia:zakonczono") then return end        
                local rnd = math.random(#mousePoints)
                local x,y,w,h = mousePoints[rnd][1],mousePoints[rnd][2],mousePoints[rnd][3],mousePoints[rnd][4]                          
                dxDrawImage(x, y, w, h, "kolo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
            end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-07, 14:06


P.Wiśnia

Programista LUA






Wiek: 25
Na forum: 4185 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 378

Respekt: 100
Respekt: 100

"Wilq" napisał/a:

W powy?szym kodzie nad linijk?
local x,y,w,h = mousePoints[rnd][1],mousePoints[rnd][2],mousePoints[rnd][3],mousePoints[rnd][4]


musisz dopisa? to:
local rnd = math.random(#mousePoints)


?le podpowiedzia?e?:
local mousePoints = {
{screenW * 0.3932, screenH * 0.4787, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.4516, screenH * 0.5213, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.5495, screenH * 0.5528, screenW * 0.0323, screenH * 0.0509},
{screenW * 0.5969, screenH * 0.5065, screenW * 0.0198, screenH * 0.0296},
}
local rnd = math.random(1,#mousePoints) -- lub to na dole 
local rnd = math.random(#mousePoints)
target=0
addEventHandler("onClientRender", root, function()
if getElementData(localPlayer, "kopalnia:zakonczono") then return end     
local x,y,w,h = mousePoints[rnd][1],mousePoints[rnd][2],mousePoints[rnd][3],mousePoints[rnd][4]          
dxDrawImage(x, y, w, h, "kolo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end)


Ostatnio zmieniony przez P.Wiśnia 2020-03-07, 15:03, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-03-07, 14:26


Pyrek24







Wiek: 26
Na forum: 3579 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Obraz si? nie wczytuje, punkty te? si? nie wczytuja.
B??d w DB3
Kod:


attempt to index field "?" (a nil value)

B??d w tej linijce

local x,y,w,h = mousePoints[rnd][1],mousePoints[rnd][2],mousePoints[rnd][3],mousePoints[rnd][4]     


Postaw piwo autorowi tego posta
 

 
Tagi: randomowe :: punkty
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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