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

Wysłany: 2021-01-31, 20:31


Huan_Strasilov







Wiek: 29
Na forum: 2230 dni
Posty: 6
Nick w MP: Huan_Strasilov

Piwa: 47

Respekt: 50

Witam, chcia?bym do pracy magazyniera z pys 3.0 doda? gui gdzie mia?oby by? przycisk rozpocz?cia tylko i zeby kursor sie pokaza? klikn?? F3 i zeby normalnie wyj?? sobie z markera. Gui stworze sobie w guieditor bedzie tam tylko napis i button rozpocznij. Chcia?bym abyscie nakierowali mnie po kolei jakich funkcji u?y?.
A fajnie by by?o jak by sie te? da?o zako?czy? komend?, albo tak jak rozpocz??o

tutaj kod po stronie clienta

local startMagazyn createMarker(5.69, -106.82998.06-0.9"cylinder"1.52552550)
setElementInterior(startMagazyn1)
setElementDimension(startMagazyn1)

xguiGetScreenSize()
pxpy = (x/1024), (y/768)

pkt = {
    {1.86, -136.43993.39},
    {2.75, -143.92993.39},
    {-3.87, -146.44993.39},
    {-9.60, -146.95993.39},
    {10.07, -144.76993.39},
    {10.15, -140.12993.39},
    {9.02, -128.05993.39},
    {7.75, -119.44993.39},
    {10.20, -116.68993.39},
    {9.95, -120.39993.39},
    {16.24, -119.62993.39},
    {16.80, -115.82993.39},
    {16.42, -110.51993.39},
    {10.78, -109.25993.39},
    {23.66, -110.44993.39},
    {22.95, -115.79993.39},
    {26.34, -117.90993.39},
    {30.17, -111.63993.39},
    {30.42, -117.48993.39},
    {30.50, -121.04993.39},
    {30.53, -125.72993.39},
    {26.93, -134.48993.39},
    {26.47, -138.39993.39},
    {29.88, -139.57993.39},
    {30.04, -143.99993.39},
    {6.26, -108.71993.39},
}

setElementData(localPlayer"skrzynia:magazyn"nil)

function isMouseIn xywidthheight )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sxsy guiGetScreenSize ( )
    local cxcy getCursorPosition ( )
    local cxcy = ( cx sx ), ( cy sy )
    if ( cx >= and cx <= width ) and ( cy >= and cy <= height then
        return true
    else
        return false
    end
end

posxposy 465621

addEventHandler("onClientRender"root, function()
    if not getElementData(localPlayer"skrzynia:magazyn") == true then return end
    if loading == 390 then setElementData(localPlayer"skrzynia:magazyn"falsetoggleAllControls(true)
    triggerServerEvent("anim"localPlayerfalse)
    if getElementData(localPlayer"player:premium"then
        triggerServerEvent("monetyMagazynier"localPlayermath.random(120000*1.2135000*1.2), math.random(1,6))
    else
        triggerServerEvent("monetyMagazynier"localPlayermath.random(120000135000), math.random(0,4))
    end
    return end
    newTick getTickCount()
    loading interpolateBetween(00039000, (newTick-tick)/7500"Linear")
    dxDrawImage(316*px331*py400*px50*py"bar.png"000tocolor(255255255255), false)
    dxDrawRectangle(319*px335*pyloading*px42*pytocolor(255255255255), false)
end)

function markery()
    markerOdbior createMarker(-4.52, -127.93993.39-0.9"cylinder"225500)
    blipOdbior createBlipAttachedTo(markerOdbior41)
    setElementInterior(markerOdbior1)
    setElementDimension(markerOdbior1)
    setElementInterior(blipOdbior1)
    setElementDimension(blipOdbior1)
    addEventHandler("onClientMarkerHit"markerOdbior, function(el)
        if el ~= localPlayer then return end
        destroyElement(source)
        destroyElement(blipOdbior)
        triggerServerEvent("anim"localPlayertrue)
        rand math.random(1#pkt)
        markerOddawanie createMarker(pkt[rand][1], pkt[rand][2], pkt[rand][3]-0.9"cylinder"1.510025555)
        blipOddawanie createBlipAttachedTo(markerOddawanie41)
        setElementInterior(markerOddawanie1)
        setElementDimension(markerOddawanie1)
        setElementInterior(blipOddawanie1)
        setElementDimension(blipOddawanie1)
        addEventHandler("onClientMarkerHit"markerOddawanie, function(el)
            if el ~= localPlayer then return end
            destroyElement(source)
            destroyElement(blipOddawanie)
            markery()
            setElementData(localPlayer"skrzynia:magazyn"true)
            tick getTickCount()
            loading 0
            toggleAllControls(false)
        end)
    end)
end

addEventHandler("onClientMarkerHit"startMagazyn, function(el)
    if el ~= localPlayer then return end
    setElementData(localPlayer"gui:magazyniera"true)
    showCursor(true)
     if getElementData(localPlayer"praca"then triggerEvent("onClientAddNotification"localPlayer"Posiadasz aktywn? prac?""error") return end
        outputChatBox("Rozpoczynasz prac? magazyniera. Aby zako?czy? wpisz /zakoncz.magazyn"100100250)
        for i,v in ipairs(getElementsByType("player")) do
            setElementCollidableWith(localPlayervfalse)
            setElementCollidableWith(vlocalPlayerfalse)
        end
        setElementData(localPlayer"praca""magazyn")
        triggerEvent("onClientAddNotification"localPlayer"Rozpoczynasz prac? magazyniera, aby zako?czy? wpisz /zakoncz.magazyn""success")
        showCursor(false)
        setElementData(localPlayer"gui:magazyniera"false)
        markery()
end)

addCommandHandler("zakoncz.magazyn", function()
    if getElementData(localPlayer"praca") ~= "magazyn" then
        triggerEvent("onClientAddNotification"localPlayer"Nie posiadasz aktywnej pracy magazyniera""error")
        return
    end
    setElementData(localPlayer"praca"nil)
    destroyElement(markerOdbior)
    destroyElement(blipOdbior)
    destroyElement(markerOddawanie)
    destroyElement(blipOddawanie)
    setElementData(localPlayer"skrzynia:magazyn"nil)
        for i,v in ipairs(getElementsByType("player")) do
            setElementCollidableWith(localPlayervfalse)
            setElementCollidableWith(vlocalPlayerfalse)
        end
    showCursor(false)
    triggerServerEvent("magazyn"localPlayer)
    triggerEvent("onClientAddNotification"localPlayer"Ko?czysz prac? jako magazynier""success")
end)


tutaj kod po stronie serwera

box = {}

addEvent("anim"true)
addEventHandler("anim"root, function(bul)
    if bul then
        setPedAnimation(client"CARRY""crry_prtial"4.1truetruetrue)
        box[client] = createObject(1271000)
        setObjectScale(box[client], 0.8)
        setElementInterior(box[client], 1)
        setElementDimension(box[client], 1)
        attachElements (box[client], client, -0.0870.740.55)
        toggleControl(client"walk"false)
        toggleControl(client"jump"false)
        toggleControl(client"sprint"false)
        toggleControl(client"crouch"false)
        setControlState(client"walk"true)
    else
        setPedAnimation(client"CARRY""liftup"0.0falsefalsefalsefalse)
    end
end)

addEvent("monetyMagazynier"true)
addEventHandler("monetyMagazynier"root, function(iloscrepa)
    local kasa ilosc
    givePlayerMoney(clientkasa)
    triggerClientEvent(client"onClientAddNotification"client"Za odniesienie skrzyni otrzymujesz "..kasa.." $""success")
    local reputacja getElementData(client"player:reputation")
    setElementData(client"player:reputation"reputacja+repa)
    destroyElement(box[client])
end)

addEvent("magazyn"true)
addEventHandler("magazyn"root, function()
    destroyElement(box[client])
        toggleControl(client"walk"true)
        toggleControl(client"jump"true)
        toggleControl(client"sprint"true)
        toggleControl(client"crouch"true)
        setControlState(client"walk"false)
        setPedAnimation(client"CARRY""liftup"0.0falsefalsefalsefalse)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-01-31, 22:31


rudziku







Wiek: 18
Na forum: 1952 dni
Posty: 16

Piwa: 3

Respekt: 30,5


Więcej informacji znajdziesz w Wikipedii MTA:

onClientGuiClick



Więcej informacji znajdziesz w Wikipedii MTA:

showCursor


Postaw piwo autorowi tego posta
 

 
Tagi: gui :: praca
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 praca Odpowiedz do tematu

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