Wysłany: 2018-02-26, 06:44
Kuks*
Wiek: 15 Na forum: 3030 dni Posty: 246
Nick w MP: Kuks*
Piwa : 2208
Siema, jak ukry? to GUI.
Teraz mam kod, kt?ry po klikni?ciu w przycisk wy?wietla wiadomo?? "test" na chacie, a zamiast tego chc?, aby GUI si? ukry?o, jak mam to zrobi??
Za pomoc daj?
Kod:
local markerZarcie = createMarker (- 2382.43164 , - 584.20868 , 132.11719 - 1 , "cylinder" , 1 , 32 , 102 , 23 )
local sx , sy = guiGetScreenSize ()
local px , py = ( sx / 1366 ),( sy / 768 )
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
addEventHandler ( "onClientRender" , root , function()
if isElementWithinMarker ( localPlayer , markerZarcie ) then
dxDrawLine ( 422 - 1 , 177 - 1 , 422 - 1 , 576 , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 927 , 177 - 1 , 422 - 1 , 177 - 1 , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 422 - 1 , 576 , 927 , 576 , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 927 , 576 , 927 , 177 - 1 , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawRectangle ( 422 , 177 , 505 , 399 , tocolor ( 102 , 102 , 102 , 255 ), false )
dxDrawText ( "Sklep z jedzeniem" , 560 , 187 , 789 , 223 , tocolor ( 255 , 255 , 255 , 255 ), 2.30 , "default" , "left" , "top" , false , false , false , false , false )
dxDrawRectangle ( 451 , 229 , 450 , 43 , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 451 , 282 , 450 , 43 , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 451 , 335 , 450 , 43 , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 549 , 495 , 237 , 71 , tocolor ( 36 , 167 , 73 , 255 ), false )
showCursor ( true )
if isMouseIn ( 549 , 495 , 237 , 71 ) and getKeyState ( "mouse1" ) then
outputChatBox ( "test" )
end
end
end )
Wysłany: 2018-02-26, 08:15
.RiV
Wiek: 25 Na forum: 3588 dni Posty: 554
Nick w MP: Split
Piwa : 2596
U?yj zmiennych. Przed onClientRender dodaj zmienn?
w onClientRender dodaj warunek
if not toggled then return nil end
W miejscu, kt?ry odpowiada za sprawdzanie czy przycisk klikni?ty dodaj
Podpis
Autor OGRPG, na scenie MTA od 2012 roku.
Użytkownik: 08.08.2016
GTAO Member: 06.02.2017
Support-Team: 17.06.2017 & 01.06.2019 - 18.11.2019
Moderator: 14.01.2018 - 09.08.2018
Więcej szczegółów
Wystawiono 1 piw(a):Kuks*
Wysłany: 2018-02-26, 15:56
Kuks*
Wiek: 15 Na forum: 3030 dni Posty: 246
Nick w MP: Kuks*
Piwa : 2208
.WhiteBlue , Aha - tylko teraz tak: GUI si? w??cza po odpaleniu skryptu, a po wy??czeniu GUI i ponownym wej?ciu w marker, nic nie mog? zrobi?.
Kod:
local markerZarcie = createMarker (- 2382.43164 , - 584.20868 , 132.11719 - 1 , "cylinder" , 1 , 32 , 102 , 23 )
local sx , sy = guiGetScreenSize ()
local px , py = ( sx / 1366 ),( sy / 768 )
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
wlaczone = true
addEventHandler ( "onClientRender" , root , function()
if not wlaczone then return end
if isElementWithinMarker ( localPlayer , markerZarcie ) then
dxDrawLine ( 422 - 1 , 177 - 1 , 422 - 1 , 576 , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 927 , 177 - 1 , 422 - 1 , 177 - 1 , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 422 - 1 , 576 , 927 , 576 , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 927 , 576 , 927 , 177 - 1 , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawRectangle ( 422 , 177 , 505 , 399 , tocolor ( 102 , 102 , 102 , 255 ), false )
dxDrawText ( "Sklep z jedzeniem" , 560 , 187 , 789 , 223 , tocolor ( 255 , 255 , 255 , 255 ), 2.30 , "default" , "left" , "top" , false , false , false , false , false )
dxDrawRectangle ( 451 , 229 , 450 , 43 , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 451 , 282 , 450 , 43 , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 451 , 335 , 450 , 43 , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 549 , 495 , 237 , 71 , tocolor ( 36 , 167 , 73 , 255 ), false )
showCursor ( true )
if isMouseIn ( 549 , 495 , 237 , 71 ) and getKeyState ( "mouse1" ) then
wlaczone = nil
showCursor ( false )
end
end
end )
[ Dodano : 2018-02-26, 16:19 ]
Dobra, to ju? zrobi?em, tylko teraz wlacza si? po starcie skryptu
kod:
local markerZarcie = createMarker (- 2382.43164 , - 584.20868 , 132.11719 - 1 , "cylinder" , 1 , 32 , 102 , 23 )
blip = createBlipAttachedTo ( markerZarcie , 10 )
setBlipVisibleDistance ( blip , 500 )
local sx , sy = guiGetScreenSize ()
local px , py = ( sx / 1366 ),( sy / 768 )
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
setTimer (function()
wlaczone = true
end , 100 , 0 )
addEventHandler ( "onClientRender" , root , function()
if not wlaczone then return end
if isElementWithinMarker ( localPlayer , markerZarcie ) then
dxDrawLine ( 422 - 1 * px , 177 - 1 * py , 422 - 1 * px , 576 * py , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 927 * px , 177 - 1 * py , 422 - 1 * px , 177 - 1 * py , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 422 - 1 * px , 576 * py , 927 * px , 576 * py , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 927 * px , 576 * py , 927 * px , 177 - 1 * py , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawRectangle ( 422 * px , 177 * py , 505 * px , 399 * py , tocolor ( 102 , 102 , 102 , 255 ), false )
dxDrawText ( "Sklep z jedzeniem" , 560 * px , 187 * py , 789 * px , 223 * py , tocolor ( 255 , 255 , 255 , 255 ), 2.30 * px , "default" , "left" , "top" , false , false , false , false , false )
dxDrawRectangle ( 451 * px , 229 * py , 450 * px , 43 * py , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 451 * px , 282 * py , 450 * px , 43 * py , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 451 * px , 335 * py , 450 * px , 43 * py , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 549 * px , 495 * py , 237 * px , 71 * py , tocolor ( 36 , 167 , 73 , 255 ), false )
showCursor ( true )
if isMouseIn ( 549 , 495 , 237 , 71 ) and getKeyState ( "mouse1" ) then
wlaczone = nil
showCursor ( false )
end
end
end )
[ Dodano : 2018-02-26, 16:20 ]
A dobra, dzi?ki za pomoc, ju? sb wszystko ogarnalem, piwo masz ;d
[ Dodano : 2018-02-26, 16:32 ]
A jednak - po w??czeniu skryptu i odczekaniu 5s bez ruchu odpala si? gui.
local markerZarcie = createMarker (- 2382.43164 , - 584.20868 , 132.11719 - 1 , "cylinder" , 1 , 32 , 102 , 23 )
blip = createBlipAttachedTo ( markerZarcie , 10 )
setBlipVisibleDistance ( blip , 500 )
local sx , sy = guiGetScreenSize ()
local px , py = ( sx / 1366 ),( sy / 768 )
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
setTimer (function()
wlaczone = true
end , 5000 , 0 )
addEventHandler ( "onClientRender" , root , function()
if not wlaczone then return end
if not isElementWithinMarker ( localPlayer , markerZarcie ) then showCursor ( false ) return end
dxDrawLine ( 422 - 1 * px , 177 - 1 * py , 422 - 1 * px , 576 * py , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 927 * px , 177 - 1 * py , 422 - 1 * px , 177 - 1 * py , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 422 - 1 * px , 576 * py , 927 * px , 576 * py , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawLine ( 927 * px , 576 * py , 927 * px , 177 - 1 * py , tocolor ( 16 , 237 , 141 , 255 ), 1 , false )
dxDrawRectangle ( 422 * px , 177 * py , 505 * px , 399 * py , tocolor ( 102 , 102 , 102 , 255 ), false )
dxDrawText ( "Sklep z jedzeniem" , 560 * px , 187 * py , 789 * px , 223 * py , tocolor ( 255 , 255 , 255 , 255 ), 2.30 * px , "default" , "left" , "top" , false , false , false , false , false )
dxDrawRectangle ( 451 * px , 229 * py , 450 * px , 43 * py , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 451 * px , 282 * py , 450 * px , 43 * py , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 451 * px , 335 * py , 450 * px , 43 * py , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawRectangle ( 549 * px , 495 * py , 237 * px , 71 * py , tocolor ( 36 , 167 , 73 , 255 ), false )
dxDrawText ( "Anuluj" , 628 * px , 511 * py , 719 * px , 548 * py , tocolor ( 255 , 255 , 255 , 255 ), 2.50 * px , "default" , "left" , "top" , false , false , false , false , false )
showCursor ( true )
if isMouseIn ( 549 , 495 , 237 , 71 ) and getKeyState ( "mouse1" ) then
wlaczone = nil
showCursor ( false )
end
end )
Wysłany: 2018-02-28, 16:51
manieks78
Lua ;)
Wiek: 25 Na forum: 3387 dni Posty: 97
Nick w MP: Hexan
Piwa : 5
Kod: function showGUI(value)
if value then
showCursor(true)
addEventHandler("onClientRender", root, renderDX)
else
showCursor(false)
removeEventHandler("onClientRender", root, renderDX)
end
end
Zr?b tak? funkcj? po stronie clienta, a potem je?li chcesz wy??czy? lub w??czy? owe dxDraw, to wpisujesz tak: showGUI(false/true)
Kod:
function renderDX()
dxDrawLine(422 - 1*px, 177 - 1*py, 422 - 1*px, 576*py, tocolor(16, 237, 141, 255), 1, false)
dxDrawLine(927*px, 177 - 1*py, 422 - 1*px, 177 - 1*py, tocolor(16, 237, 141, 255), 1, false)
dxDrawLine(422 - 1*px, 576*py, 927*px, 576*py, tocolor(16, 237, 141, 255), 1, false)
dxDrawLine(927*px, 576*py, 927*px, 177 - 1*py, tocolor(16, 237, 141, 255), 1, false)
dxDrawRectangle(422*px, 177*py, 505*px, 399*py, tocolor(102, 102, 102, 255), false)
dxDrawText("Sklep z jedzeniem", 560*px, 187*py, 789*px, 223*py, tocolor(255, 255, 255, 255), 2.30*px, "default", "left", "top", false, false, false, false, false)
dxDrawRectangle(451*px, 229*py, 450*px, 43*py, tocolor(36, 167, 73, 255), false)
dxDrawRectangle(451*px, 282*py, 450*px, 43*py, tocolor(36, 167, 73, 255), false)
dxDrawRectangle(451*px, 335*py, 450*px, 43*py, tocolor(36, 167, 73, 255), false)
dxDrawRectangle(549*px, 495*py, 237*px, 71*py, tocolor(36, 167, 73, 255), false)
dxDrawText("Anuluj", 628*px, 511*py, 719*px, 548*py, tocolor(255, 255, 255, 255), 2.50*px, "default", "left", "top", false, false, false, false, false)
end
To sobie tak podmie? i je?li ciebie dobrze zrozumia?em to napisz inn? funkcj? z tym pokazywaniem si? dxDraw:
Kod: addEventHandler ("onClientClick", root, function(btn,state)
if btn == "left" and state == "up" then
if isMouseInPosition(442, 471, 145, 36) then
showGUI(true/false)
end
end
end)
Sprawd? czy dzia?a, je?li pope?ni?em b??d jaki? to bardzo przepraszam ale sam dopiero si? ucz? tego. Mam nadziej?, ?e sobie jako? teraz poradzisz.
Tagi: ukrywanie :: gui
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: