Wysłany: 2016-08-16, 17:37
AlaneqYT
Uczeń LUA
Wiek: 25 Na forum: 3884 dni Posty: 37
Piwa : 20
Witam, zrobi?em sobie gui do premium ale jak odpalam to mam miliard tych okien zamiast 1
Jak mo?na to naprawi??
KOD:
local data ={ showed = nil , button ={}}
local screenW , screenH = guiGetScreenSize ()
local sx , sy = guiGetScreenSize ()
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
GUIEditor = {
button = {},
window = {},
label = {},
memo = {}
}
function renderZoneBox ()
showCursor ( true )
GUIEditor . window [ 1 ] = guiCreateWindow ( 478 , 233 , 924 , 553 , "Us?uga PREMIUM" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
GUIEditor . button [ 1 ] = guiCreateButton ( 41 , 450 , 212 , 87 , "Sprawd?" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 1 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . button [ 2 ] = guiCreateButton ( 305 , 450 , 212 , 87 , "Zamknij" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 2 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . label [ 1 ] = guiCreateLabel ( 285 , 22 , 919 , 97 , "Za pomoc? tego formularza mo?esz zakupi? konto premium.\n REGULAMIN:\nZa b??dne wpisanie numeru lub tre?ci sms nie odpowiadamy.\n Za zakupiony premium nie oddajemy pieni?dzy." , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 2 ] = guiCreateLabel ( 10 , 129 , 922 , 295 , "Je?eli chcesz kupi? premium to poni?ej masz cennik.\n30 dni PREMIUM - 11.07z? ( brutto ) Tre??: AA.SP na numer: 7936\n14 dni PREMIUM - 6,15z? ( brutto ) Tre??: AA.SP na numer: 7555\n7 dni PREMIUM - 3,69z? ( brutto ) Tre??: AA.SP na numer: 7355\n1 dzie? PREMIUM - 1,23z? ( brutto ) Tre??: AA.SP na numer: 7136\n " , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 3 ] = guiCreateLabel ( 339 , 225 , 912 , 140 , "Kod kt?ry ci przyszed? wpisz poni?ej." , false , GUIEditor . window [ 1 ])
GUIEditor . memo [ 1 ] = guiCreateMemo ( 333 , 252 , 226 , 32 , "" , false , GUIEditor . window [ 1 ])
end
addEventHandler ( "onClientClick" , root , function( btn , state )
if btn == "left" and state == "down" then
if isMouseIn ( screenW * 0.4601 , screenH * 0.6848 , screenW * 0.5452 , screenH * 0.7048 ) and data . showed then
-- outputChatBox ( "Ten kod (" .. guiGetText ( data . button [ 1 ]).. ") wyslij na pm do Czeko (/pm Czeko " .. guiGetText ( data . button [ 1 ]).. ")" )
if guiCheckBoxGetSelected ( data . button [ 2 ]) then amount = "19" else amount = "9" end
triggerServerEvent ( "premiumActive" , localPlayer , guiGetText ( data . button [ 1 ]), amount )
destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
removeEventHandler ( "onClientRender" , root , renderZoneBox )
data . showed = false
showCursor ( false )
elseif isMouseIn ( screenW * 0.3655 , screenH * 0.2733 , screenW * 0.2696 , screenH * 0.0467 ) and data . showed then
destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
removeEventHandler ( "onClientRender" , root , renderZoneBox )
data . showed = false
showCursor ( false )
end
end
end )
function premiumshow ()
if data . showed then
destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
removeEventHandler ( "onClientRender" , root , renderZoneBox )
data . showed = false
showCursor ( false )
else
addEventHandler ( "onClientRender" , root , renderZoneBox )
data . button [ 1 ] = guiCreateEdit ( 0.40 , 0.57 , 0.21 , 0.05 , "" , true )
data . button [ 2 ] = guiCreateCheckBox ( 0.40 , 0.61 , 0.21 , 0.05 , "D?u?sze premium (30 dni)" , false , true )
guiEditSetMaxLength ( data . button [ 1 ], 8 )
data . showed = true
end
end
addCommandHandler ( 'premium' , premiumshow )
Prosz? o szybk? pomoc
Wysłany: 2016-08-16, 17:52
AteX
Wiek: 26 Na forum: 4015 dni Posty: 927
Nick w MP: #AteX
Piwa : 8360
onClientRender wykonuje si? kilkadziesi?t razy na sekund? i przez to tworzy tyle okien. Utw?rz gui przy starcie skryptu i p??niej go tylko wy?wietl przy wpisaniu komendy i schowaj po klikni?ciu w przycisk.
Wysłany: 2016-08-16, 17:59
AlaneqYT
Uczeń LUA
Wiek: 25 Na forum: 3884 dni Posty: 37
Piwa : 20
Okej, zrobi?em cos takiego:
function renderZoneBox ()
showCursor ( true )
GUIEditor . window [ 1 ] = guiCreateWindow ( 478 , 233 , 924 , 553 , "Us?uga PREMIUM" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
GUIEditor . button [ 1 ] = guiCreateButton ( 41 , 450 , 212 , 87 , "Sprawd?" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 1 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . button [ 2 ] = guiCreateButton ( 305 , 450 , 212 , 87 , "Zamknij" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 2 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . label [ 1 ] = guiCreateLabel ( 285 , 22 , 919 , 97 , "Za pomoc? tego formularza mo?esz zakupi? konto premium.\n REGULAMIN:\nZa b??dne wpisanie numeru lub tre?ci sms nie odpowiadamy.\n Za zakupiony premium nie oddajemy pieni?dzy." , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 2 ] = guiCreateLabel ( 10 , 129 , 922 , 295 , "Je?eli chcesz kupi? premium to poni?ej masz cennik.\n30 dni PREMIUM - 11.07z? ( brutto ) Tre??: AA.SP na numer: 7936\n14 dni PREMIUM - 6,15z? ( brutto ) Tre??: AA.SP na numer: 7555\n7 dni PREMIUM - 3,69z? ( brutto ) Tre??: AA.SP na numer: 7355\n1 dzie? PREMIUM - 1,23z? ( brutto ) Tre??: AA.SP na numer: 7136\n " , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 3 ] = guiCreateLabel ( 339 , 225 , 912 , 140 , "Kod kt?ry ci przyszed? wpisz poni?ej." , false , GUIEditor . window [ 1 ])
GUIEditor . memo [ 1 ] = guiCreateMemo ( 333 , 252 , 226 , 32 , "" , false , GUIEditor . window [ 1 ])
end
local data ={ showed = nil , button ={}}
local screenW , screenH = guiGetScreenSize ()
local sx , sy = guiGetScreenSize ()
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
GUIEditor = {
button = {},
window = {},
label = {},
memo = {}
}
function renderZoneBox ()
showCursor ( true )
GUIEditor . window [ 1 ] = guiCreateWindow ( 478 , 233 , 924 , 553 , "Us?uga PREMIUM" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
GUIEditor . button [ 1 ] = guiCreateButton ( 41 , 450 , 212 , 87 , "Sprawd?" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 1 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . button [ 2 ] = guiCreateButton ( 305 , 450 , 212 , 87 , "Zamknij" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 2 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . label [ 1 ] = guiCreateLabel ( 285 , 22 , 919 , 97 , "Za pomoc? tego formularza mo?esz zakupi? konto premium.\n REGULAMIN:\nZa b??dne wpisanie numeru lub tre?ci sms nie odpowiadamy.\n Za zakupiony premium nie oddajemy pieni?dzy." , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 2 ] = guiCreateLabel ( 10 , 129 , 922 , 295 , "Je?eli chcesz kupi? premium to poni?ej masz cennik.\n30 dni PREMIUM - 11.07z? ( brutto ) Tre??: AA.SP na numer: 7936\n14 dni PREMIUM - 6,15z? ( brutto ) Tre??: AA.SP na numer: 7555\n7 dni PREMIUM - 3,69z? ( brutto ) Tre??: AA.SP na numer: 7355\n1 dzie? PREMIUM - 1,23z? ( brutto ) Tre??: AA.SP na numer: 7136\n " , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 3 ] = guiCreateLabel ( 339 , 225 , 912 , 140 , "Kod kt?ry ci przyszed? wpisz poni?ej." , false , GUIEditor . window [ 1 ])
GUIEditor . memo [ 1 ] = guiCreateMemo ( 333 , 252 , 226 , 32 , "" , false , GUIEditor . window [ 1 ])
end
addEventHandler ( "onClientClick" , root , function( btn , state )
if btn == "left" and state == "down" then
if isMouseIn ( screenW * 0.4601 , screenH * 0.6848 , screenW * 0.5452 , screenH * 0.7048 ) and data . showed then
-- outputChatBox ( "Ten kod (" .. guiGetText ( data . button [ 1 ]).. ") wyslij na pm do Czeko (/pm Czeko " .. guiGetText ( data . button [ 1 ]).. ")" )
if guiCheckBoxGetSelected ( data . button [ 2 ]) then amount = "19" else amount = "9" end
triggerServerEvent ( "premiumActive" , localPlayer , guiGetText ( data . button [ 1 ]), amount )
destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
removeEventHandler ( "onClientRender" , root , renderZoneBox )
data . showed = false
showCursor ( false )
elseif isMouseIn ( screenW * 0.3655 , screenH * 0.2733 , screenW * 0.2696 , screenH * 0.0467 ) and data . showed then
destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
removeEventHandler ( "onClientRender" , root , renderZoneBox )
data . showed = false
showCursor ( false )
end
end
end )
function premiumshow ()
if data . showed then
destroyElement ( data . button [ 1 ])
destroyElement ( data . button [ 2 ])
guiSetVisible ( GUIEditor . window [ 1 ], state )
data . showed = false
showCursor ( false )
else
guiSetVisible ( GUIEditor . window [ 1 ], state )
data . button [ 1 ] = guiCreateEdit ( 0.40 , 0.57 , 0.21 , 0.05 , "" , true )
data . button [ 2 ] = guiCreateCheckBox ( 0.40 , 0.61 , 0.21 , 0.05 , "D?u?sze premium (30 dni)" , false , true )
guiEditSetMaxLength ( data . button [ 1 ], 8 )
data . showed = true
end
end
addCommandHandler ( 'premium' , premiumshow )
Czy to jest dobrze? I moglbys mi wyjasnic o co chodzi z tym 'state' ?
Wysłany: 2016-08-16, 18:03
AteX
Wiek: 26 Na forum: 4015 dni Posty: 927
Nick w MP: #AteX
Piwa : 8360
Co ty zrobi?e? Nie zmieni?e? nic, tylko skopiowa?e? funkcj? na sam pocz?tek. Mo?e CapsLock pomo?e. ONCLIENTRENDER WYKONUJE SI? KILKADZIESI?T RAZY NA SEKUND?. Masz stworzy? gui przy starcie skryptu i p??niej tylko korzysta? z guiSetVisible. Nie powinno tutaj w og?le by? u?yte onClientRender.
Wysłany: 2016-08-16, 18:04
AlaneqYT
Uczeń LUA
Wiek: 25 Na forum: 3884 dni Posty: 37
Piwa : 20
"AteX" napisał/a :Co ty zrobi?e? Nie zmieni?e? nic, tylko skopiowa?e? funkcj? na sam pocz?tek. Mo?e CapsLock pomo?e. ONCLIENTRENDER WYKONUJE SI? KILKADZIESI?T RAZY NA SEKUND?. Masz stworzy? gui przy starcie skryptu i p??niej tylko korzysta? z guiSetVisible.
M?g?bys pokazac przyk?ad na tym kodzie? zbytnio nie rozumiem tego.
Wysłany: 2016-08-16, 18:06
AteX
Wiek: 26 Na forum: 4015 dni Posty: 927
Nick w MP: #AteX
Piwa : 8360
GUIEditor = {
button = {},
window = {},
label = {},
memo = {}
}
GUIEditor . window [ 1 ] = guiCreateWindow ( 478 , 233 , 924 , 553 , "Us?uga PREMIUM" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
GUIEditor . button [ 1 ] = guiCreateButton ( 41 , 450 , 212 , 87 , "Sprawd?" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 1 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . button [ 2 ] = guiCreateButton ( 305 , 450 , 212 , 87 , "Zamknij" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 2 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . label [ 1 ] = guiCreateLabel ( 285 , 22 , 919 , 97 , "Za pomoc? tego formularza mo?esz zakupi? konto premium.\n REGULAMIN:\nZa b??dne wpisanie numeru lub tre?ci sms nie odpowiadamy.\n Za zakupiony premium nie oddajemy pieni?dzy." , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 2 ] = guiCreateLabel ( 10 , 129 , 922 , 295 , "Je?eli chcesz kupi? premium to poni?ej masz cennik.\n30 dni PREMIUM - 11.07z? ( brutto ) Tre??: AA.SP na numer: 7936\n14 dni PREMIUM - 6,15z? ( brutto ) Tre??: AA.SP na numer: 7555\n7 dni PREMIUM - 3,69z? ( brutto ) Tre??: AA.SP na numer: 7355\n1 dzie? PREMIUM - 1,23z? ( brutto ) Tre??: AA.SP na numer: 7136\n " , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 3 ] = guiCreateLabel ( 339 , 225 , 912 , 140 , "Kod kt?ry ci przyszed? wpisz poni?ej." , false , GUIEditor . window [ 1 ])
GUIEditor . memo [ 1 ] = guiCreateMemo ( 333 , 252 , 226 , 32 , "" , false , GUIEditor . window [ 1 ])
guiSetVisible ( GUIEditor . window [ 1 ], false )
function pokazGUI ()
guiSetVisible ( GUIEditor . window [ 1 ], true )
end
addCommandHandler ( "premium" , pokazGUI )
Wysłany: 2016-08-16, 18:22
AlaneqYT
Uczeń LUA
Wiek: 25 Na forum: 3884 dni Posty: 37
Piwa : 20
Okej, teraz jest gites, ale teraz nie dzia?a mi zamykanie i sprawdzanie, jak to mo?na naprawi?? Poprosi?bym ju? o dodanie do tego kodu.
Wysłany: 2016-08-16, 19:16
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4149 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
GUIEditor = {
button = {},
window = {},
label = {},
memo = {}
}
GUIEditor . window [ 1 ] = guiCreateWindow ( 478 , 233 , 924 , 553 , "Us?uga PREMIUM" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
GUIEditor . button [ 1 ] = guiCreateButton ( 41 , 450 , 212 , 87 , "Sprawd?" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 1 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . button [ 2 ] = guiCreateButton ( 305 , 450 , 212 , 87 , "Zamknij" , false , GUIEditor . window [ 1 ])
guiSetProperty ( GUIEditor . button [ 2 ], "NormalTextColour" , "FFAAAAAA" )
GUIEditor . label [ 1 ] = guiCreateLabel ( 285 , 22 , 919 , 97 , "Za pomoc? tego formularza mo?esz zakupi? konto premium.\n REGULAMIN:\nZa b??dne wpisanie numeru lub tre?ci sms nie odpowiadamy.\n Za zakupiony premium nie oddajemy pieni?dzy." , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 2 ] = guiCreateLabel ( 10 , 129 , 922 , 295 , "Je?eli chcesz kupi? premium to poni?ej masz cennik.\n30 dni PREMIUM - 11.07z? ( brutto ) Tre??: AA.SP na numer: 7936\n14 dni PREMIUM - 6,15z? ( brutto ) Tre??: AA.SP na numer: 7555\n7 dni PREMIUM - 3,69z? ( brutto ) Tre??: AA.SP na numer: 7355\n1 dzie? PREMIUM - 1,23z? ( brutto ) Tre??: AA.SP na numer: 7136\n " , false , GUIEditor . window [ 1 ])
GUIEditor . label [ 3 ] = guiCreateLabel ( 339 , 225 , 912 , 140 , "Kod kt?ry ci przyszed? wpisz poni?ej." , false , GUIEditor . window [ 1 ])
GUIEditor . memo [ 1 ] = guiCreateMemo ( 333 , 252 , 226 , 32 , "" , false , GUIEditor . window [ 1 ])
guiSetVisible ( GUIEditor . window [ 1 ], false )
function pokazGUI ()
if guiGetVisible ( GUIEditor . window [ 1 ]) == false then
guiSetVisible ( GUIEditor . window [ 1 ], true )
showCursor ( true )
else
guiSetVisible ( GUIEditor . window [ 1 ], false )
showCursor ( false )
end
end
addCommandHandler ( "premium" , pokazGUI )
Wysłany: 2016-08-16, 20:01
AlaneqYT
Uczeń LUA
Wiek: 25 Na forum: 3884 dni Posty: 37
Piwa : 20
Dobra ka?dy dostaje po piwku, dzi?kuje. do zamkni?cia.
Tagi: gui
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: