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

Wysłany: 2014-11-16, 23:42


wwa22442







Wiek: 38
Na forum: 4706 dni
Posty: 127

Piwa: 82

Respekt: 50

Ostrzeżeń: 20%
Witam.

Mam system bank?w, lecz chcia?bym aby guzik F2 lub komenda /bank dzia?a?a tylko w tej pozycji :

Kod:


2309, -13, 27


A oto kod skryptu:


------------------------------
key 'F2'
cmd 'bank'
------------------------------

g_Me localPlayer

function centerWindow center_window )
    local screenWscreenH guiGetScreenSize ( );
    local windowWwindowH guiGetSize center_windowfalse );
    local x= ( screenW windowW ) / 2, ( screenH windowH ) / 2
    guiSetPosition center_windowxyfalse );
end

function updateMoney ( Function, playerlabel )
    local theUpdateIsCorrect setTimer ( function ( )
        guiSetText label'Your Money : \n\n  $ '..Function ( player ) );
    end1000);
    if theUpdateIsCorrect then
        return true 
    else
        return false
    end
end

BS = {
    button = {},
    window = {},
    label = {},
    edit = {},
    checkbox = {}
}

addEventHandler'onClientResourceStart'resourceRoot,
    function ( )
        BS.window[1] = guiCreateWindow 277229501228'Bank System | Register'false );
        guiWindowSetSizable BS.window[1], false );
        guiSetAlpha BS.window[1], );
        guiSetVisible BS.window[1], false );
        BS.window[2] = guiCreateWindow 300193469306'.:[ The Bank System | v 1.5 ]:.'false );
        guiWindowSetSizable BS.window[2], false );
        guiSetAlpha BS.window[2], );
        guiSetVisible BS.window[2], false );
        BS.window[3] = guiCreateWindow 344207337293'.:[ The Bank System | Control Panel ]:.'false );
        guiWindowSetSizable BS.window[3], false );
        guiSetAlpha BS.window[3], );
        guiSetVisible BS.window[3], false );
        ---
        for _,w in nextgetElementsByType 'gui-window'guiRoot ) do
            centerWindow );
        end
        ---
        BS.button[1] = guiCreateButton 37916411227'Cancel'falseBS.window[1] );
        BS.button[2] = guiCreateButton 25416411227'Done'falseBS.window[1] );
        BS.button[3] = guiCreateButton 397275822'Exit'falseBS.window[2] );
        BS.button[4] = guiCreateButton 32619111929'Login'falseBS.window[2] );
        BS.button[5] = guiCreateButton 15413911928'Exit'falseBS.window[3] );
        BS.button[6] = guiCreateButton 15418211928'Execute'falseBS.window[3] );
        ---
        BS.checkbox[1] = guiCreateCheckBox 1917111729'  Withdraw'falsefalseBS.window[3] );
        BS.checkbox[2] = guiCreateCheckBox 1913211729'  Deposit'falsefalseBS.window[3] );
        ---
        BS.edit[1] = guiCreateEdit 217622336''falseBS.window[1] );
        guiEditSetMaxLength BS.edit[1], 20 );
        BS.edit[2] = guiCreateEdit 2116022336''falseBS.window[1] );
        guiEditSetMasked BS.edit[2], true );
        guiEditSetMaxLength BS.edit[2] , 20 );
        BS.edit[3] = guiCreateEdit 1614930032''falseBS.window[2] );
        guiEditSetMaxLength BS.edit[3] , 20 );
        BS.edit[4] = guiCreateEdit 1622230032''falseBS.window[2] );
        guiEditSetMasked BS.edit[4], true );
        guiEditSetMaxLength BS.edit[4] , 20 );
        BS.edit[5] = guiCreateEdit 5923823934''falseBS.window[3] ); 
        guiEditSetMaxLength BS.edit[5] , );
        ---
        BS.label[1] = guiCreateLabel 2212722223'Password :'falseBS.window[1] );
        BS.label[2] = guiCreateLabel 2606423163'Welcome To The Bank System ,,#\n\nPlease chose a username and a password\nto register to the bank system .'falseBS.window[1] );
        BS.label[3] = guiCreateLabel 214313623'Username :'falseBS.window[1] );    
        BS.label[4] = guiCreateLabel 3011215820'Username :'falseBS.window[2] );
        BS.label[5] = guiCreateLabel 3019215820'Password :'falseBS.window[2] );
        BS.label[6] = guiCreateLabel 203123864'Welcome To The Bank System ,,#\n\n\nLogin so you can access your balance .'falseBS.window[2] );
        BS.label[7] = guiCreateLabel 192136820'Amount :'falseBS.window[3] );
        BS.label[8] = guiCreateLabel 122726147'Your Money : \n\n  $ '..getPlayerMoney g_Me ), falseBS.window[3] );
        updateMoney getPlayerMoneyg_MeBS.label[8] );
        BS.label[9] = guiCreateLabel 128026147'Your Balance : \n\n  $ 0'falseBS.window[3] );
        BS.label[10] = guiCreateLabel 292481514'$'falseBS.window[3] );
    end
);

addCommandHandler cmd, function ( )
    if getElementData g_Me'HaveAccount' then
        if getElementData g_Me'Loggedin' then
            guiSetVisible BS.window[3], not guiGetVisible BS.window[3] ) );
            showCursor guiGetVisible BS.window[3] ) );
            guiSetInputEnabled guiGetVisible BS.window[3] ) );
        else
            guiSetVisible BS.window[2], not guiGetVisible BS.window[2] ) );
            showCursor guiGetVisible BS.window[2] ) );
            guiSetInputEnabled guiGetVisible BS.window[2] ) );
        end
    else
        guiSetVisible BS.window[1], not guiGetVisible BS.window[1] ) );
        showCursor guiGetVisible BS.window[1] ) );
        guiSetInputEnabled guiGetVisible BS.window[1] ) );
    end
end );

bindKey key'down'cmd );

addEventHandler 'onClientGUIClick'root,
    function ( )
        if source == BS.button[1then
            guiSetVisible BS.window[1], false );
            showCursor guiGetVisible BS.window[1] ) );
            guiSetInputEnabled guiGetVisible BS.window[1] ) );
            guiSetText BS.edit[1], '' );
            guiSetText BS.edit[2], '' );
        elseif source == BS.button[2then
            local user guiGetText BS.edit[1] );
            local pass guiGetText BS.edit[2] );
            if user ~= '' and pass ~= '' then
                if #user > 5 and #user <20 and #pass > 5 and #pass <20 then
                    triggerServerEvent 'onAccountRegister'g_Meuserpass );
                    guiSetVisible BS.window[1], false );
                    showCursor guiGetVisible BS.window[1] ) );
                    guiSetInputEnabled guiGetVisible BS.window[1] ) );
                else
                    outputChatBox '#FF0000* #FFFFFFTo short username and \ or password .'000true );
                end
            else
                outputChatBox '#FF0000* #FFFFFFYou\'re #FF0000missing #FFFFFFthe username and \ or the password .', 0, 0, 0, true );
            end
        elseif source == BS.button[3then
            guiSetVisible BS.window[2], false );
            showCursor guiGetVisible BS.window[2] ) );
            guiSetInputEnabled guiGetVisible BS.window[2] ) );
            guiSetText BS.edit[3], '' );
            guiSetText BS.edit[4], '' );
        elseif source == BS.button[4then
            local user guiGetText BS.edit[3] );
            local pass guiGetText BS.edit[4] );
            if user ~= '' and pass ~= '' then
                if #user > 5 and #user <20 and #pass > 5 and #pass <20 then
                    local userCheck getElementData g_Me'User' )    
                    local passCheck getElementData g_Me'Pass' )
                    if userCheck == user and passCheck == pass then
                        guiSetVisible BS.window[2], false );
                        showCursor guiGetVisible BS.window[2] ) );
                        guiSetInputEnabled guiGetVisible BS.window[2] ) );
                        setElementData g_Me'Loggedin'true );
                        outputChatBox '#FF0000* #FFFFFFYou\'ve logged in #00FF00successfuly #FFFFFF.', 0, 0, 0, true );
                    else
                        outputChatBox '#FF0000* Wrong #FFFFFF username and \ or password .'000true );
                    end
                else
                    outputChatBox '#FF0000* #FFFFFFTo short username and \ or password .'000true );
                end
            else
                outputChatBox '#FF0000* #FFFFFFYou\'re #FF0000missing #FFFFFFthe username and \ or the password .', 0, 0, 0, true );
            end
        elseif source == BS.button[5then
            guiSetVisible BS.window[3], false );
            showCursor guiGetVisible BS.window[3] ) );
            guiSetInputEnabled guiGetVisible BS.window[3] ) );
        elseif source == BS.button[6then
            if guiCheckBoxGetSelected BS.checkbox[1] ) then
                local money getElementData g_Me'Balance' );
                local amount guiGetText BS.edit[5] );
                if amount == '' then
                    outputChatBox '#FF0000* #FFFFFFYou didn\'t right the #00FF00amount #FFFFFF.', 0, 0, 0, true );
                    return
                end
                if tonumberamount ) > money then
                    outputChatBox '#FF0000* #FFFFFFYou don\'t have enough balance .', 0, 0, 0, true );
                    return
                end
                triggerServerEvent ( 'onBalanceWithdraw', g_Me, tonumber( amount ) );
                outputChatBox ( '#FF0000* #FFFFFFYou\'ve successfuly drawed $ #00FF00'..amount..' #FFFFFFfrom your balance .', 0, 0, 0, true );
                guiSetText BS.edit[5], '' );
            guiCheckBoxSetSelected BS.checkbox[1], false );
            elseif guiCheckBoxGetSelected BS.checkbox[2] ) then
                local money getPlayerMoney g_Me );
                local amount guiGetText BS.edit[5] );
                if amount == '' then
                    outputChatBox '#FF0000* #FFFFFFYou didn\'t right the #00FF00amount #FFFFFF.', 0, 0, 0, true );
                    return
                end
                if tonumberamount ) > money then
                    outputChatBox '#FF0000* #FFFFFFYou don\'t have enough money .', 0, 0, 0, true );
                    return
                end
                triggerServerEvent ( 'onBalanceDeposit', g_Me, tonumber( amount ) );
                outputChatBox ( '#FF0000* #FFFFFFYou\'ve successfuly deposit $ #00FF00'..amount..' #FFFFFFto your balance .', 0, 0, 0, true );
                guiSetText BS.edit[5], '' );
            guiCheckBoxSetSelected BS.checkbox[2], false );
            else
                outputChatBox '#FF0000* #FFFFFFYou must chose an option to execute ( #00FF00withdraw #FFFFFFor #00FF00Deposit #FFFFFF) .'000true );
            end
        elseif source == BS.checkbox[1then
            guiCheckBoxSetSelected BS.checkbox[2], false );
        elseif source == BS.checkbox[2then
            guiCheckBoxSetSelected BS.checkbox[1], false );
        end
    end
);

addEventHandler 'onClientElementDataChange'root, function ( theData )
    if theData == 'Balance' then
        guiSetText BS.label[9], 'Your Balance : \n\n  $ '..getElementData g_Me'Balance' ) );
    end
end );

addEventHandler 'onClientGUIAccepted'root, function ( )
    if source == BS.edit[1] or source == BS.edit[2then
        local user guiGetText BS.edit[1] );
        local pass guiGetText BS.edit[2] );
        if user ~= '' and pass ~= '' then
            triggerServerEvent 'onAccountRegister'g_Meuserpass );
            guiSetVisible BS.window[1], false );
            showCursor guiGetVisible BS.window[1] ) );
            guiSetInputEnabled guiGetVisible BS.window[1] ) );
        else
            outputChatBox '#FF0000* #FFFFFFYou\'re #FF0000missing #FFFFFFthe username and \ or the password .', 0, 0, 0, true );
        end
    elseif source == BS.edit[3] or source == BS.edit[4then
        local user guiGetText BS.edit[3] );
        local pass guiGetText BS.edit[4] );
        if user ~= '' and pass ~= '' then
            local userCheck getElementData g_Me'User' )    
            local passCheck getElementData g_Me'Pass' )
            if userCheck == user and passCheck == pass then
                guiSetVisible BS.window[2], false );
                showCursor guiGetVisible BS.window[2] ) );
                guiSetInputEnabled guiGetVisible BS.window[2] ) );
                setElementData g_Me'Loggedin'true );
                outputChatBox '#FF0000* #FFFFFFYou\'ve logged in #00FF00successfuly #FFFFFF.', 0, 0, 0, true );
            else
                outputChatBox '#FF0000* Wrong #FFFFFF username and \ or password .'000true );
            end
        else
            outputChatBox '#FF0000* #FFFFFFYou\'re #FF0000missing #FFFFFFthe username and \ or the password .', 0, 0, 0, true );
        end
    elseif source == BS.edit[5then
        if guiCheckBoxGetSelected BS.checkbox[1] ) then
            local money getElementData g_Me'Balance' );
            local amount guiGetText BS.edit[5] );
            if amount == '' then
                outputChatBox '#FF0000* #FFFFFFYou didn\'t right the #00FF00amount #FFFFFF.', 0, 0, 0, true );
                return
            end
            if tonumberamount ) > money then
                outputChatBox '#FF0000* #FFFFFFYou don\'t have enough balance .', 0, 0, 0, true );
                return
            end
            triggerServerEvent ( 'onBalanceWithdraw', g_Me, tonumber( amount ) );
            outputChatBox ( '#FF0000* #FFFFFFYou\'ve successfuly drawed $ #00FF00'..amount..' #FFFFFFfrom your balance .', 0, 0, 0, true );
            guiSetText BS.edit[5], '' );
            guiCheckBoxSetSelected BS.checkbox[1], false );
        elseif guiCheckBoxGetSelected BS.checkbox[2] ) then
            local money getPlayerMoney g_Me );
            local amount guiGetText BS.edit[5] );
            if amount == '' then
                outputChatBox '#FF0000* #FFFFFFYou didn\'t right the #00FF00amount #FFFFFF.', 0, 0, 0, true );
                return
            end
            if tonumberamount ) > money then
                outputChatBox '#FF0000* #FFFFFFYou don\'t have enough money .', 0, 0, 0, true );
                return
            end
            triggerServerEvent ( 'onBalanceDeposit', g_Me, tonumber( amount ) );
            outputChatBox ( '#FF0000* #FFFFFFYou\'ve successfuly deposit $ #00FF00'..amount..' #FFFFFFto your balance .', 0, 0, 0, true );
            guiSetText BS.edit[5], '' );
            guiCheckBoxSetSelected BS.checkbox[2], false );
        else
            outputChatBox '#FF0000* #FFFFFFYou must chose an option to execute ( #00FF00withdraw #FFFFFFor #00FF00Deposit #FFFFFF) .'000true );
        end
    end
end );

addEventHandler 'onClientGUIChanged'root,
    function ( element )      
        if ( element == BS.edit[5] ) then
            local ID guiGetText BS.edit[5] );
            if not tonumberID then
            return guiSetText BS.edit[5], '' );
            end
        end
    end 
);


moglbym prosic o zrobienie rowniez na tej pozycji tzw. checkpointa [k??eczka] w do kt?rego jak si? wjedzie bedzie mozna uzyc tego guzika albo komendy, oraz po wejsciu w niego aby wyswietlal tekst : "witaj w banku. aby skorzystac z bankomatu wpisz /bank".

Pozdrawiam. Za pomoc daje zimne piwka ;)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-17, 14:28


Vini

Piszący...






Wiek: 27
Na forum: 4556 dni
Posty: 23
Nick w MP: Vini

Piwa: 2

Respekt: 50

Dodaj sobie w kodzie
local x,y,z = getElementPosition(source)
if (x == 2309) and (y==-13) and (y==27) then
--Kod
end

Powinno zadzia?a?

Podpis
Lubię pomagać
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-18, 10:48


Blur







Wiek: 28
Na forum: 4298 dni
Posty: 47
Nick w MP: Blu

Piwa: 2

Respekt: 50

Vini, przyjacielu, to strona clienta, nie servera.

local x,y,getElementPosition()
if == 2309 and y  == -13 and == 27 then


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-18, 22:40


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Blur, duchowi pobierasz te x,y,z?

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-19, 00:25


Wielebny







Wiek: 41
Na forum: 5498 dni
Posty: 257
Nick w MP: Wielebny

Piwa: 1690

Respekt: 180
Respekt: 180Respekt: 180

"Vini" napisał/a:

local x,y,z = getElementPosition(source)
if (x == 2309) and (y==-13) and (y==27) then
Powinno zadzia?a?


Bardzo precyzyjnie mu odpowiedzia?e?, gorzej, ?e gracz nigdy nie stanie w dok?adnie tej pozycji. Zamiast tego proponuj? wyliczy? odleg?o???od podanego punktu:


local x,y,z=getElementPosition(gracz)
if getDistanceBetweenPoints3D(x,y,z,2309,-13,27)<5 then
 -- gracz jest w zasiegu
end


Opr?cz tego warto te? sprawdzi? interior i dimension.

Cytat:


Vini, przyjacielu, to strona clienta, nie servera.


Funkcja getElementPosition dzia?a tak samo[1] po obu stronach i w obu przypadkach wymaga podania argumentu.

[1] prawie tak samo - po stronie klienta zwraca mniej dok?adne warto?ci dla element?w bed?cych w ruchu i poza zasi?giem strumieniowania, np. dla graczy na drugim ko?cu mapy.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-19, 00:53


Piorun







Wiek: 32
Na forum: 6712 dni
Posty: 1837
Nick w MP: Piorun

Piwa: 516

Respekt: 480,7
Respekt: 480,7

Wielebny, nie lepiej b?dzie jakiego? colshape'a wsadzi? w danym miejscu, a potem odpowiedni? funkcj? sprawdzi? czy gracz jest w ?rodku :E ?

Mniej liczenia, mniej problem?w :P .

Podpis
Możesz mnie znaleźć na: Facebook
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-19, 07:40


Wielebny







Wiek: 41
Na forum: 5498 dni
Posty: 257
Nick w MP: Wielebny

Piwa: 1690

Respekt: 180
Respekt: 180Respekt: 180

Colshape to inna metoda na zrobienie tego, ta operacje jest na tyle banalna, ?e zaryzykuj? stwierdzenie, ?e to zupe?nie bez r??nicy.

edit: w sumie rozwa?amy tu tylko teoretycznie, bo najlepszym rozwi?zaniem by?oby co?, co zobaczy gracz - np. marker.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-19, 20:19


piotr172







Wiek: 26
Na forum: 4417 dni
Posty: 130

Piwa: 2329

Respekt: 105,3
Respekt: 105,3

"Wielebny" napisał/a:



edit: w sumie rozwa?amy tu tylko teoretycznie, bo najlepszym rozwi?zaniem by?oby co?, co zobaczy gracz - np. marker.


Wielebny mo?na to zrobi? tak: Wstawi? tam Colshape odpowiedzialny za te funkcje itp i doda? marker w tym miejscu kt?ry nic nie robi, nie odpowiada ?adnej funkcji.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-19, 23:24


Wielebny







Wiek: 41
Na forum: 5498 dni
Posty: 257
Nick w MP: Wielebny

Piwa: 1690

Respekt: 180
Respekt: 180Respekt: 180

"piotr172" napisał/a:


Wielebny mo?na to zrobi? tak: Wstawi? tam Colshape odpowiedzialny za te funkcje itp i doda? marker w tym miejscu kt?ry nic nie robi, nie odpowiada ?adnej funkcji.


Nie trzeba stawia? dodatkowego colshape, ka?dy marker jeden ma wbudowany - mo?esz go nawet pobra? funkcj? getElementColShape.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-20, 11:07


wwa22442







Wiek: 38
Na forum: 4706 dni
Posty: 127

Piwa: 82

Respekt: 50

Ostrzeżeń: 20%
A w kt?rym miejscu to wklei? ? :) Oboj?tnie gdzie w kodzie ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-20, 11:43


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3


Więcej informacji znajdziesz w Wikipedii MTA:

isElementWithinMarker


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-20, 16:10


Wielebny







Wiek: 41
Na forum: 5498 dni
Posty: 257
Nick w MP: Wielebny

Piwa: 1690

Respekt: 180
Respekt: 180Respekt: 180

"wwa22442" napisał/a:

A w kt?rym miejscu to wklei? ? :) Oboj?tnie gdzie w kodzie ?


Zaraz po:


addCommandHandler cmd, function ( )


wstaw:

local x,y,z=getElementPosition(localPlayer)
if not getDistanceBetweenPoints3D(x,y,z,2309,-13,27)<15 then
 outputChatBox("Musisz by? wewn?trz banku")
 return
end


Zasi?g (15) wyreguluj w zale?no?ci od rozmiaru budynku.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-11-24, 15:51


wwa22442







Wiek: 38
Na forum: 4706 dni
Posty: 127

Piwa: 82

Respekt: 50

Ostrzeżeń: 20%

addCommandHandler cmd, function ( )
    local x,y,z=getElementPosition(localPlayer)
        if not getDistanceBetweenPoints3D(x,y,z,2309,-13,27)<15 then
        outputChatBox("Musisz by? wewn?trz banku")
        return
    end
    if getElementData g_Me'HaveAccount' then
        if getElementData g_Me'Loggedin' then
            guiSetVisible BS.window[3], not guiGetVisible BS.window[3] ) );
            showCursor guiGetVisible BS.window[3] ) );
            guiSetInputEnabled guiGetVisible BS.window[3] ) );
        else
            guiSetVisible BS.window[2], not guiGetVisible BS.window[2] ) );
            showCursor guiGetVisible BS.window[2] ) );
            guiSetInputEnabled guiGetVisible BS.window[2] ) );
        end
    else
        guiSetVisible BS.window[1], not guiGetVisible BS.window[1] ) );
        showCursor guiGetVisible BS.window[1] ) );
        guiSetInputEnabled guiGetVisible BS.window[1] ) );
    end
end 
);


Tak ? :D

Postaw piwo autorowi tego posta
 

 
Tagi: komenda :: lub :: guzik :: danej :: pozycji
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA 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