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

Wysłany: 2020-08-02, 08:40


Kezoto
[Usunięty]









Nie wiem z kad mam wiedziec jak zrobic by jesli sie na ekranie kliknelo w dany obszar to cos sie stalo znaczy, nie o to chodzi, moze dam przyklad:

[lua]elseif isMouseIn(x_2, y_2, 285/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{-2675.89, -5.33, 6.13+0.1})
closeZones()
[/lua]

jest tu takie cos jak: [lua]elseif isMouseIn(x_2, y_2, 285/zoom, 65/zoom)[/lua] i nie wiem z kad mam wziasc te kordynaty obszaru na ekranie mozna mi pomoc?

[ Dodano: 2020-08-02, 08:41 ]
Jakis program/ narzedzie jest do tego?

 

 
Wysłany: 2020-08-02, 10:57


_jvneczek







Wiek: 22
Na forum: 4326 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

chocia?by mo?esz skorzysta? z guieditora w kt?rym takow? pozycje mo?esz 'pobra?'.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-02, 11:32


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

To funkcja, kt?r? musisz w kodzie zdefiniowa? wcze?niej.


Więcej informacji znajdziesz w Wikipedii MTA:

isMouseInPosition


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-02, 12:20


Kezoto
[Usunięty]









I co ja mam do tego editor gui zaladowac? mam taki kod na te przyciski:

[lua]
x,y=36.63,82.19 -- my width
intro_step=math.random(0,850)

local muzyka = false
local tick2 = getTickCount()
local sx,sy=guiGetScreenSize()

local data={ showed=nil, button={}, info=nil, misc=nil, }

local sw,sh = guiGetScreenSize()
local zoom = 1
if sw < 1920 then
zoom = math.min(2, 1920 / sw)
end

function getCenter(x, y)
x,y = x / zoom, y / zoom
return (sw / 2) - (x / 2), (sh / 2) - (y / 2)
end

local sm = {}
sm.moov = 0
sm.object1,sm.object2 = nil,nil

local function removeCamHandler()
if(sm.moov == 1)then
sm.moov = 0
end
end

local function camRender2()
if (sm.moov == 1) then
local x1,y1,z1 = getElementPosition(sm.object1)
local x2,y2,z2 = getElementPosition(sm.object2)
setCameraMatrix(x1,y1,z1,x2,y2,z2)
end
end
addEventHandler("onClientPreRender",root,camRender2)

function smoothMoveCamera2(x1,y1,z1,x1t,y1t,z1t,x2,y2,z2,x2t,y2t,z2t,time)
if(sm.moov == 1)then return false end
sm.object1 = createObject(1337,x1,y1,z1)
sm.object2 = createObject(1337,x1t,y1t,z1t)
setElementAlpha(sm.object1,0)
setElementAlpha(sm.object2,0)
setObjectScale(sm.object1,0.01)
setObjectScale(sm.object2,0.01)
moveObject(sm.object1,time,x2,y2,z2,0,0,0,"InOutQuad")
moveObject(sm.object2,time,x2t,y2t,z2t,0,0,0,"InOutQuad")
sm.moov = 1
setTimer(removeCamHandler,time,1)
setTimer(destroyElement,time,1,sm.object1)
setTimer(destroyElement,time,1,sm.object2)
return true
end

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*sx,cy*sy
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end

local dist = 200
local angler = 0
function getPointFromDistanceRotation(x, y, dist, angler)
local a = math.rad(270 - angler)
local dx = math.cos(a) * dist;
local dy = math.sin(a) * dist;
return x+dx, y+dy;
end

local texture_choose = dxCreateTexture('img/spawn-psrpg.png','argb',true,'clamp')

function renderZoneBox()
local x_1, y_1 = getCenter(400,550)
dxDrawImage(x_1, y_1, 400/zoom, 550/zoom, texture_choose, 0, 0, 0, tocolor(255, 255, 255, 255), false)

smoothMoveCamera2(1621.01, -1873.15, 67.78, 1606.29, -1643.41, 67.78, 1616.59, -1309.99, 101.99, 1671.31, -945.80, 101.99, 45000)
end

function math.round(number, decimals, method)
decimals = decimals or 0
local factor = 10 ^ decimals
if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
else return tonumber(("%."..decimals.."f"):format(number)) end
end

function onClick(btn,state)
if btn=="left" and state=="down" then
local x_2, y_2 = getCenter(285,-302)
local _, y_3 = getCenter(285,-92)
local _, y_4 = getCenter(285,118)
local _, y_5 = getCenter(285,325)

if isMouseIn(x_2, y_5, 285/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{1722.14, -1716.34, 13.52+0.1})
closeZones()
elseif isMouseIn(x_2, y_4, 285/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{1896.07, 2317.70, 10.82+0.1})
closeZones()
elseif isMouseIn(x_2, y_2, 285/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{-2675.89, -5.33, 6.13+0.1})
closeZones()
elseif isMouseIn(x_2, y_3, 285/zoom, 65/zoom) and data.showed then
local domek=getElementData(localPlayer,"player:house")
if not domek then
setElementData(localPlayer,"player:spawn",{1477.68, -1705.58, 14.05+0.1})
outputChatBox("Nie posiadasz domku!")
end
closeZones()
end
end
end


function closeZones()
showChat(true)
showCursor(false)
fadeCamera(false)
setElementAlpha(localPlayer,255)
stopSound(muzyka)
showPlayerHudComponent("all",false)
showPlayerHudComponent("radar",true)
showPlayerHudComponent("crosshair",true)
showPlayerHudComponent("weapon",true)
showPlayerHudComponent("health",true)
showPlayerHudComponent("breath",true)
showPlayerHudComponent("clock",true)
showPlayerHudComponent("ammo",true)
data.showed=false
local tick2 = getTickCount()
triggerServerEvent("core:spawnPlayer", localPlayer)
setTimer(triggerEvent, 250, 1, "gui:start", localPlayer)
removeEventHandler("onClientRender", root, renderZoneBox)
removeEventHandler("onClientPreRender",root,camRender2)
blur = false
end

function showZones(misc)
muzyka=misc
data.showed=true
showPlayerHudComponent("all",false)
guiSetInputMode("no_binds_when_editing")
local tick2 = getTickCount()
addEventHandler("onClientRender", root, renderZoneBox)
addEventHandler("onClientClick", root, onClick)
end[/lua]

 

 
Wysłany: 2020-08-02, 20:52


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W miejscu gdzie kto? ma co? klikn?? wybierasz opcj? "Draw -> Draw rectangle" i tworzysz go w tym miejscu. Nast?pnie wybierasz opcj? "Output" i masz gotowe koordynaty, kt?re odpowiednio sobie skalujesz.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-03, 15:15


Kezoto
[Usunięty]









no i mam takie cos :

[lua]

local screenW, screenH = guiGetScreenSize()

addEventHandler("onClientRender", root,
function()
dxDrawRectangle(screenW * 0.4663, screenH * 0.4115, screenW * 0.0578, screenH * 0.0286, tocolor(255, 255, 255, 255), false)
end
)[/lua] i po co mi to jak nie wiem jak to uzyc potrzebuje 2 kordynaty X i Z i nie wiem z kad to pobrac H Height to mozna zaliczyc jako Z ale z kad X i jak to zrobic? myslalem tak:

[lua] elseif isMouseIn(x_2, y_2, 328/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{-2015.83, -97.76, 35.39+0.1})
closeZones()
[/lua] to jest jeden z spawnow a ja zrobilem tak:

[lua] elseif isMouseIn(x_0.4663, y_0.4115, 328/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{-2015.83, -97.76, 35.39+0.1})
closeZones()
[/lua]

i nie wiem czemu nie dziala?

 

 
Wysłany: 2020-08-03, 17:12


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Bo musisz poda? albo liczb?, albo zmienn? pod kt?ra masz pozycje. Po prostu zawsze kopiuj i wklejaj pozycj? z guieditora. Na pocz?tku pliku wklej tylko 1 linijke z guieditora z funkcj? guiGetScreenSize i potem podmieniaj ca?e warto?ci pozycji.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-03, 21:35


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Cytat:

po co mi to jak nie wiem jak to uzyc potrzebuje 2 kordynaty X i Z i nie wiem z kad to pobrac H Height to mozna zaliczyc jako Z ale z kad X i jak to zrobic



Co ty za bzdury kolego opowiadasz, jakie Z? X,Y,Z to wspo?rz?dne mapowe/3D. My m?wimy o ekranie 2D, wi?c mamy do dyspozycji X oraz Y. 3 i 4 argument to szerokosc i wysoko?? tego "prostok?ta" w ktorym kod ma wiedzie?, ?e po wjechaniu myszk? na niego co? ma si? sta?. Powtarzam kolego znowu - nie pcha? si? w takie rzeczy bez podstawowej wiedzy, bo zajedziesz si? tylko i zniech?cisz.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-03, 23:07


Kezoto
[Usunięty]









tak zrobilem ale dalej nie dziala:

ss z guieditora: https://imgur.com/gallery/7lZHpqY
kod:

[lua]function onClick(btn,state)
if btn=="left" and state=="down" then
local x_2, y_2 = getCenter(328,-122)
local _, y_3 = getCenter(328,40)
local _, y_4 = getCenter(328,200)
local _, y_5 = getCenter(328,355)
local x_6, y_6 = getCenter(637,319)

if isMouseIn(x_2, y_5, 328/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{-2673.64, -5.47, 6.13+0.1})
closeZones()
elseif isMouseIn(x_2, y_4, 328/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{2182.57, 1115.87, 12.65+0.1})
closeZones()
elseif isMouseIn(x_6, y_6, 328/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{1012.77, -1441.49, 13.55+0.1})
closeZones()
elseif isMouseIn(x_2, y_2, 328/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{-2015.83, -97.76, 35.39+0.1})
closeZones()
elseif isMouseIn(x_2, y_3, 328/zoom, 65/zoom) and data.showed then
local domek=getElementData(localPlayer,"player:house")
if not domek then
setElementData(localPlayer,"player:spawn",{-1915.49, 881.90, 35.41+0.1})
outputChatBox("Nie posiadasz domku!")
end
closeZones()
end
end
end
[/lua]

dalej nie dziala no mnie tu zaraz rozwali

[ Dodano: 2020-08-03, 23:08 ]
to co ja dodawalem to te

[lua] local x_6, y_6 = getCenter(637,319)[/lua]
oraz
[lua] elseif isMouseIn(x_6, y_6, 328/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{1012.77, -1441.49, 13.55+0.1})
closeZones()[/lua]

 

 
Wysłany: 2020-08-03, 23:37


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Na screenie ktory dales masz jasno i wyraznie podane koordynaty X,Y,W,H..

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-04, 11:11


Kezoto
[Usunięty]









no to robie

[lua]
local x_6, y_6 = getCenter(637,319)

elseif isMouseIn(x_6, y_6, 328/zoom, 65/zoom) and data.showed then
setElementData(localPlayer,"player:spawn",{1012.77, -1441.49, 13.55+0.1})
closeZones()

function getCenter2(x, y)
x,y = x / zoom, y / zoom
return (sw / 77) - (x / 638), (sh / 16) - (y / 318)
end

[/lua]

ale nie dziala

 

 
Wysłany: 2020-08-04, 11:17


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wklejaj po prostu same liczby tam, gdzie je potrzebujesz. Je?li nie potrafisz u?ywa? tych funkcji, kt?rych sam nie zrobi?e? to si? w to nie baw. U?ywaj samych surowych liczb.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-04, 16:17


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

local x_6y_6 getCenter(637,319)


Po co takie co?? Nie pro?ciej podzieli? liczby przez 2?


Co do koordynat?w, nie kombinuj z liczbami, zr?b w guieditorze rectangle w polu gdzie chcesz zeby wykonywa?a si? akcja po najechaniu na niego myszk?, nast?pnie output, 4 pierwsze liczby skopiuj i wklej w isMouseIn.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-08-05, 17:08


Kezoto
[Usunięty]









wkleilem poprostu te kordy ale dalej nie dziala

[lua] elseif isMouseIn(638, 318, 77, 16) and data.showed then
setElementData(localPlayer,"player:spawn",{1012.77, -1441.49, 13.55+0.1})
closeZones()
[/lua]

 

 
Wysłany: 2020-08-05, 17:12


MeeShuffle

Programista/Grafik






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

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Podmie? swoj? funkcj? isMouseIn na ta:

function isMouseIn xywidthheight )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sxsy guiGetScreenSize ( )
    local cxcy getCursorPosition ( )
    local cxcy = ( cx sx ), ( cy sy )
    
    return ( ( cx >= and cx <= width ) and ( cy >= and cy <= height ) )
end



I napisz rezultat

Postaw piwo autorowi tego posta
 

 
Tagi: jak :: robicie :: gui?
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