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?
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)
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
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.
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]
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.
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.
[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]
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.
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