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

Wysłany: 2016-08-16, 17:37


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 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=nilbutton={}}


local screenWscreenH guiGetScreenSize()
local sxsy 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(478233924553"Us?uga PREMIUM"false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.button[1] = guiCreateButton(4145021287"Sprawd?"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour""FFAAAAAA")
        GUIEditor.button[2] = guiCreateButton(30545021287"Zamknij"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[2], "NormalTextColour""FFAAAAAA")
        GUIEditor.label[1] = guiCreateLabel(2852291997"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."falseGUIEditor.window[1])
        GUIEditor.label[2] = guiCreateLabel(10129922295"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 "falseGUIEditor.window[1])
        GUIEditor.label[3] = guiCreateLabel(339225912140"Kod kt?ry ci przyszed? wpisz poni?ej."falseGUIEditor.window[1])
        GUIEditor.memo[1] = guiCreateMemo(33325222632""falseGUIEditor.window[1]) 
end

addEventHandler("onClientClick"root, function(btn,state)
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.4601screenH 0.6848screenW 0.5452screenH 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"localPlayerguiGetText(data.button[1]),amount)
        destroyElement(data.button[1])
        destroyElement(data.button[2])
        removeEventHandler("onClientRender"rootrenderZoneBox)
        data.showed=false
        showCursor(false)
        elseif isMouseIn(screenW 0.3655screenH 0.2733screenW 0.2696screenH 0.0467) and data.showed then
        destroyElement(data.button[1])
        destroyElement(data.button[2])
        removeEventHandler("onClientRender"rootrenderZoneBox)
        data.showed=false
        showCursor(false)
        end
    end
end)

function premiumshow()
if data.showed then
    destroyElement(data.button[1])
    destroyElement(data.button[2])
    removeEventHandler("onClientRender"rootrenderZoneBox)
    data.showed=false
    showCursor(false)
else
    addEventHandler("onClientRender"rootrenderZoneBox) 
    data.button[1] = guiCreateEdit(0.400.570.210.05""true)
    data.button[2] = guiCreateCheckBox(0.400.610.210.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 :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 17:52


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

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.

Więcej informacji znajdziesz w Wikipedii MTA:

guiSetVisible


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 17:59


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 20%
Okej, zrobi?em cos takiego:

function renderZoneBox()
        showCursor(true)
                GUIEditor.window[1] = guiCreateWindow(478233924553"Us?uga PREMIUM"false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.button[1] = guiCreateButton(4145021287"Sprawd?"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour""FFAAAAAA")
        GUIEditor.button[2] = guiCreateButton(30545021287"Zamknij"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[2], "NormalTextColour""FFAAAAAA")
        GUIEditor.label[1] = guiCreateLabel(2852291997"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."falseGUIEditor.window[1])
        GUIEditor.label[2] = guiCreateLabel(10129922295"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 "falseGUIEditor.window[1])
        GUIEditor.label[3] = guiCreateLabel(339225912140"Kod kt?ry ci przyszed? wpisz poni?ej."falseGUIEditor.window[1])
        GUIEditor.memo[1] = guiCreateMemo(33325222632""falseGUIEditor.window[1]) 
end



local data={ showed=nilbutton={}}


local screenWscreenH guiGetScreenSize()
local sxsy 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(478233924553"Us?uga PREMIUM"false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.button[1] = guiCreateButton(4145021287"Sprawd?"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour""FFAAAAAA")
        GUIEditor.button[2] = guiCreateButton(30545021287"Zamknij"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[2], "NormalTextColour""FFAAAAAA")
        GUIEditor.label[1] = guiCreateLabel(2852291997"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."falseGUIEditor.window[1])
        GUIEditor.label[2] = guiCreateLabel(10129922295"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 "falseGUIEditor.window[1])
        GUIEditor.label[3] = guiCreateLabel(339225912140"Kod kt?ry ci przyszed? wpisz poni?ej."falseGUIEditor.window[1])
        GUIEditor.memo[1] = guiCreateMemo(33325222632""falseGUIEditor.window[1]) 
end

addEventHandler("onClientClick"root, function(btn,state)
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.4601screenH 0.6848screenW 0.5452screenH 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"localPlayerguiGetText(data.button[1]),amount)
        destroyElement(data.button[1])
        destroyElement(data.button[2])
        removeEventHandler("onClientRender"rootrenderZoneBox)
        data.showed=false
        showCursor(false)
        elseif isMouseIn(screenW 0.3655screenH 0.2733screenW 0.2696screenH 0.0467) and data.showed then
        destroyElement(data.button[1])
        destroyElement(data.button[2])
        removeEventHandler("onClientRender"rootrenderZoneBox)
        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.400.570.210.05""true)
    data.button[2] = guiCreateCheckBox(0.400.610.210.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' ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 18:03


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

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.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 18:04


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 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.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 18:06


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3


GUIEditor = {
    button = {},
    window = {},
    label = {},
    memo = {}
}
                GUIEditor.window[1] = guiCreateWindow(478233924553"Us?uga PREMIUM"false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.button[1] = guiCreateButton(4145021287"Sprawd?"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour""FFAAAAAA")
        GUIEditor.button[2] = guiCreateButton(30545021287"Zamknij"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[2], "NormalTextColour""FFAAAAAA")
        GUIEditor.label[1] = guiCreateLabel(2852291997"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."falseGUIEditor.window[1])
        GUIEditor.label[2] = guiCreateLabel(10129922295"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 "falseGUIEditor.window[1])
        GUIEditor.label[3] = guiCreateLabel(339225912140"Kod kt?ry ci przyszed? wpisz poni?ej."falseGUIEditor.window[1])
        GUIEditor.memo[1] = guiCreateMemo(33325222632""falseGUIEditor.window[1]) 
guiSetVisible(GUIEditor.window[1],false)

function pokazGUI()
 guiSetVisible(GUIEditor.window[1],true)
end
addCommandHandler("premium",pokazGUI)


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 18:22


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 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.

Postaw piwo autorowi tego posta
 

 
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

Respekt: 1436,8
Respekt: 1436,8

GUIEditor = {
    button = {},
    window = {},
    label = {},
    memo = {}
}
                GUIEditor.window[1] = guiCreateWindow(478233924553"Us?uga PREMIUM"false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.button[1] = guiCreateButton(4145021287"Sprawd?"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour""FFAAAAAA")
        GUIEditor.button[2] = guiCreateButton(30545021287"Zamknij"falseGUIEditor.window[1])
        guiSetProperty(GUIEditor.button[2], "NormalTextColour""FFAAAAAA")
        GUIEditor.label[1] = guiCreateLabel(2852291997"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."falseGUIEditor.window[1])
        GUIEditor.label[2] = guiCreateLabel(10129922295"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 "falseGUIEditor.window[1])
        GUIEditor.label[3] = guiCreateLabel(339225912140"Kod kt?ry ci przyszed? wpisz poni?ej."falseGUIEditor.window[1])
        GUIEditor.memo[1] = guiCreateMemo(33325222632""falseGUIEditor.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)


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 20:01


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 20%
Dobra ka?dy dostaje po piwku, dzi?kuje. do zamkni?cia.

Postaw piwo autorowi tego posta
 

 
Tagi: 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 » GUI 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