Wysłany: 2016-05-28, 13:09
Atroth
Wiek: 23 Na forum: 3677 dni Posty: 1089
Nick w MP: Atroth
Piwa : 4808
GUIEditor = {
button = {},
window = {}
}
addEventHandler ( "onClientResourceStart" , resourceRoot ,
function()
GUIEditor . window [ 1 ] = guiCreateWindow ( 329 , 282 , 362 , 383 , "" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
guiSetVisible ( GUIEditor . window [ 1 ], false )
guiCreateButton [ 1 ] = guiCreateButton ( 67 , 77 , 234 , 99 , "Otworz Brame" , false , GUIEditor . window [ 1 ])
guiCreateButton [ 1 ] = guiCreateButton ( 65 , 233 , 236 , 90 , "Zamknij brame" , false , GUIEditor . window [ 1 ])
end
)
-- marker i brama
marker = createMarker (- 1536 , 480 , 7.18 , 'cylinder' , 1.0 , 255 , 0 , 0 , 255 )
brama1 = createObject ( 969 , - 1534.4000244141 , 482.29998779297 , 6.1999998092651 , 0 , 0 )
-- pokaz gui
function hit ( hitPlayer , matchingDimension )
if hitPlayer ~= localPlayer then return end
showCursor ( true , false )
guiSetVisible ( GUIEditor . window [ 1 ], true )
end
addEventHandler ( "onClientMarkerHit" , marker , hit )
------------------------------------------------------
-- schowaj gui
function hit ( hitPlayer , matchingDimension )
if hitPlayer ~= localPlayer then return end
showCursor ( false , false )
guiSetVisible ( GUIEditor . window [ 1 ], false )
end
addEventHandler ( "onClientMarkerLeave" , marker , hit )
-------------------------------------------------------------------------------------
-- Otwieranie :
addEventHandler ( "onClientGUIClick" , guiCreateButton [ 1 ], function( el , md ) -- po nacisni ? ciu przycisku wm . przycisk1 otwieramy nasz ? bram ?
moveObject ( brama1 , - 1534.4000244141 , 482.29998779297 , 2.7000000476837 )
end )
---------------------------------
-- Zamykanie :
addEventHandler ( "onClientGUIClick" , guiCreateButton [ 2 ], function( el , md ) -- po nacisni ? ciu przycisku wm . przycisk1 zamyka nasz ? bram ?
moveObject ( brama1 , - 1534.4000244141 , 482.29998779297 , 6.1999998092651 )
end )
-------
Tutaj img z db3:
[ Dodano : 2016-05-28, 13:14 ]
Uda?o mi si? to naprawi?, ale teraz jest w db3 warning. "Bad argument, addeventHandler [Excepted element at argument2, got nil] to jest w linijce 51 i 58
Wysłany: 2016-05-28, 13:24
AteX
Wiek: 26 Na forum: 4015 dni Posty: 927
Nick w MP: #AteX
Piwa : 8360
GUIEditor = {
button = {},
window = {}
}
addEventHandler ( "onClientResourceStart" , resourceRoot ,
function()
GUIEditor . window [ 1 ] = guiCreateWindow ( 329 , 282 , 362 , 383 , "" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
guiSetVisible ( GUIEditor . window [ 1 ], false )
GUIEditor . button [ 1 ] = guiCreateButton ( 67 , 77 , 234 , 99 , "Otworz Brame" , false , GUIEditor . window [ 1 ])
GUIEditor . button [ 2 ] = guiCreateButton ( 65 , 233 , 236 , 90 , "Zamknij brame" , false , GUIEditor . window [ 1 ])
end
)
-- marker i brama
marker = createMarker (- 1536 , 480 , 7.18 , 'cylinder' , 1.0 , 255 , 0 , 0 , 255 )
brama1 = createObject ( 969 , - 1534.4000244141 , 482.29998779297 , 6.1999998092651 , 0 , 0 )
-- pokaz gui
function hit ( hitPlayer , matchingDimension )
if hitPlayer ~= localPlayer then return end
showCursor ( true , false )
guiSetVisible ( GUIEditor . window [ 1 ], true )
end
addEventHandler ( "onClientMarkerHit" , marker , hit )
------------------------------------------------------
-- schowaj gui
function hit ( hitPlayer , matchingDimension )
if hitPlayer ~= localPlayer then return end
showCursor ( false , false )
guiSetVisible ( GUIEditor . window [ 1 ], false )
end
addEventHandler ( "onClientMarkerLeave" , marker , hit )
-------------------------------------------------------------------------------------
-- Otwieranie :
addEventHandler ( "onClientGUIClick" , GUIEditor . button [ 1 ], function( el , md ) -- po nacisni ? ciu przycisku wm . przycisk1 otwieramy nasz ? bram ?
moveObject ( brama1 , - 1534.4000244141 , 482.29998779297 , 2.7000000476837 )
end )
---------------------------------
-- Zamykanie :
addEventHandler ( "onClientGUIClick" , GUIEditor . button [ 2 ], function( el , md ) -- po nacisni ? ciu przycisku wm . przycisk1 zamyka nasz ? bram ?
moveObject ( brama1 , - 1534.4000244141 , 482.29998779297 , 6.1999998092651 )
end )
-------
Wysłany: 2016-05-28, 13:27
Atroth
Wiek: 23 Na forum: 3677 dni Posty: 1089
Nick w MP: Atroth
Piwa : 4808
52 i 45 linijka ?le, znowu bad argument
[ Dodano : 2016-05-28, 13:30 ]
Screen:
Wysłany: 2016-05-29, 00:02
Prezes.
Wiek: 27 Na forum: 4370 dni Posty: 75
Nick w MP: Prezes.
Piwa : 17
Szczerze nigdy, przenigdy nie dawa?bym funkcji createObject, moveObject po stronie klienta!! Prawdopobodnie (a nawet na 100%), 1 gracza ta brama b?dzie otwarta, dla drugiego ju? nie. Przenie? ca?y skrypt od bramy na stron? servera, nast?pnie gdy gracz wejdzie w marker triggeruj pokazanie gui na stronie klienta. Od strony klienta 2 triggery - jeden zamykaj?cy drugi otwieraj?cy. Poni?ej masz przyk?adowy kod, dzia?a w 100% - testowany.
c-side
local marker = createMarker (- 1536 , 480 , 7.18 , "cylinder" , 1 , 255 , 0 , 0 , 100 )
bra_wnd = guiCreateWindow ( 329 , 282 , 362 , 383 , "" , false )
guiSetVisible ( bra_wnd , false )
guiWindowSetSizable ( bra_wnd , false )
bra_btnOpen = guiCreateButton ( 67 , 77 , 234 , 99 , "Otworz Brame" , false , bra_wnd )
bra_btnClose = guiCreateButton ( 65 , 233 , 236 , 90 , "Zamknij brame" , false , bra_wnd )
addEventHandler ( "onClientMarkerHit" , marker ,function( el , md )
if not md or el ~= localPlayer then return end
guiSetVisible ( bra_wnd , true )
showCursor ( true )
end )
addEventHandler ( "onClientGUIClick" , bra_btnOpen ,function()
triggerServerEvent ( "checkStateBrama" , localPlayer , 1 )
guiSetVisible ( bra_wnd , false )
showCursor ( false )
end )
addEventHandler ( "onClientGUIClick" , bra_btnClose ,function()
triggerServerEvent ( "checkStateBrama" , localPlayer , 2 )
guiSetVisible ( bra_wnd , false )
showCursor ( false )
end )
s-side:
local brama1 = createObject ( 969 , - 1534.4000244141 , 482.29998779297 , 6.1999998092651 , 0 , 0 , 0 )
bramaZamknieta = true
addEvent ( "checkStateBrama" , true )
addEventHandler ( "checkStateBrama" , root ,function( akcja )
if ( akcja ) == 2 then -- jesli wcisnieto zamknij
if ( not bramaZamknieta ) then -- jesli brama jest otwarta
moveObject ( brama1 , 5000 , - 1534.4000244141 , 482.29998779297 , 6.1999998092651 ) -- zamykamy brame , 5000 = 5sekund si ? bedzie zamyka ? a
bramaZamknieta = true
else
outputChatBox ( "Brama jest ju? zamkni?ta!" )
end
end
if ( akcja ) == 1 then -- jesli wcisnieto zamknij
if ( bramaZamknieta ) then -- jesli brama jest zamknieta
moveObject ( brama1 , 5000 , - 1534.4000244141 , 482.29998779297 , 2.7000000476837 ) -- otwieramy brame , 5000 = 5sekund si ? bedzie zamyka ? a
bramaZamknieta = false
else
outputChatBox ( "Brama jest ju? otwarta!" )
end
end
end )
Wysłany: 2016-05-29, 11:10
Atroth
Wiek: 23 Na forum: 3677 dni Posty: 1089
Nick w MP: Atroth
Piwa : 4808
Podpis
Użytkownik - 10-05-2016
Support Team - 17.06.2017
Moderator - 25.11.2017
Mod-Team - 02.07.2018
Tagi: brama :: gui :: coś :: źle
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: