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

Wysłany: 2020-08-08, 01:21


StifMaster







Wiek: 30
Na forum: 3666 dni
Posty: 57
Nick w MP: Sztefi

Piwa: 5

Respekt: 50

Problem polega na tym, ?e: Je?li klikn? ENTER np na karnister paliwa to odbywa si? to podw?jnie. Z reszt? akcji jest to samo. Wraz z prze??czeniem na LPG kt?re odbywa si? pod przyciskiem "/"

s.lua

addEvent("eq:loaditems", true)
addEventHandler("eq:loaditems", root, function()
    local check = exports['mysql']:wykonaj("select * from pystories_users where id=?", getElementData(source, "player:sid"))
    if #check > 0 then
        if getElementData(source, "player:maska") then
            maska = "?ci?gnij"
        else
            maska = "za?o?"
        end
        setElementData(source, "eq:data", {
            ["zestawnaprawczy"] = check[1].zestawfix,
            ["kanister"] = check[1].zestawpaliwo,
            ["maska"] = maska,
            ["maryska"] = check[1].maryha_przerobiona,
        })
    end
end)

function zalozMaske()
    local check = exports['mysql']:wykonaj("select * from pystories_users where id=?", getElementData(source, "player:sid"))
    if #check > 0 then
        if check[1].maska == 1 then
            if getElementData(source, "player:job") then exports['yd-noti']:noti("Nie mo?esz zrobi? tego podczas pracy.", "error") return end
            if getElementData(source, "player:maska") then
                setElementData(source, "player:maska", nil)
                exports['yd-noti']:noti(source, "Pomy?lnie zdj?to mask?. Tw?j nick jest spowrotem widoczny.", "success")
                setPlayerName(source, getElementData(source, "last:nickmaska"))
                setElementData(source, "last:nickmaska", nil)
            else
                setElementData(source, "player:maska", true)
                exports['yd-noti']:noti(source, "Pomy?lnie za?o?y?e? mask?. Tw?j nick nie jest aktualnie widoczny.", "success")
                setElementData(source,"last:nickmaska",getPlayerName(source))
                setPlayerName(source, "#4d4d4dZamaskowany#"..check[1].id)
            end
        end
    end
end
addEvent("maska:zaloz", true)
addEventHandler("maska:zaloz", root, zalozMaske)

function zestawNaprawczy()
    if not isPedInVehicle(source) then return end
    local check = exports['mysql']:wykonaj("select * from pystories_users where id=?", getElementData(source, "player:sid"))
    if #check > 0 then
        if check[1].zestawfix == 0 then
            exports['yd-noti']:noti(source, "Nie posiadasz zestawu naprawczego!", "error")
        else
            exports['mysql']:wykonaj("update pystories_users set zestawfix=zestawfix-1 where id=?", getElementData(source, "player:sid"))
            local gowno = check[1].zestawfix -1
            exports['yd-noti']:noti(source, "Pomy?lnie u?yto jeden zestaw naprawczy. Pozosta?o Ci: "..gowno.." sztuk.", "success")
            setElementHealth(getPedOccupiedVehicle(source), 5000)
        end
    end
end
addEvent("naprawczy:uzyj", true)
addEventHandler("naprawczy:uzyj", root, zestawNaprawczy)

function paliwkoZestaw()
    if not isPedInVehicle(source) then return end
    local check = exports['mysql']:wykonaj("select * from pystories_users where id=?", getElementData(source, "player:sid"))
    if #check > 0 then
        if check[1].zestawpaliwo == 0 then
            exports['yd-noti']:noti(source, "Nie posiadasz kanistra!", "error")
        else
            exports['mysql']:wykonaj("update pystories_users set zestawpaliwo=zestawpaliwo-1 where id=?", getElementData(source, "player:sid"))
            local gowno = check[1].zestawpaliwo -1
            exports['yd-noti']:noti(source, "Pomy?lnie u?yto jeden kanister paliwa. Pozosta?o Ci: "..gowno.." sztuk.", "success")
            setElementData(getPedOccupiedVehicle(source), "vehicle:fuel", getElementData(getPedOccupiedVehicle(source),"vehicle:fuel")+10)
        end
    end
end
addEvent("paliwko:uzyj", true)
addEventHandler("paliwko:uzyj", root, paliwkoZestaw)

function zajebbucha()
    local check = exports['mysql']:wykonaj("select * from pystories_users where id=?", getElementData(source, "player:sid"))
    if #check > 0 then
        if check[1].maryha_przerobiona == 0 then return end
        exports['mysql']:wykonaj("update pystories_users set maryha_przerobiona=maryha_przerobiona-5 where id=?", getElementData(source, "player:sid"))
        setElementData(source, "maryha:przerobiona", getElementData(source, "maryha:przerobiona")-5)
        exports['yd-noti']:noti(source, "udanej fazy", "success")
        setPedAnimation(source, "LOWRIDER", "M_smklean_loop", 5000,true,false,true,false)
    end
end
addEvent("eq:zajebbucha", true)
addEventHandler("eq:zajebbucha", root, zajebbucha)

function przelaczLPG()
    if not isPedInVehicle(source) then return end

    local check = exports['mysql']:wykonaj("select * from pystories_vehicles where id=?", getElementData(getPedOccupiedVehicle(source), "vehicle:id"))

    if #check > 0 then
        if check[1].system_lpg == 1 then

            local lpg_status = getElementData(getPedOccupiedVehicle(source), "vehicle:lpg:on")

            if lpg_status then
                removeElementData(getPedOccupiedVehicle(source), "vehicle:lpg:on")
            else
                setElementData(getPedOccupiedVehicle(source), "vehicle:lpg:on", true)
            end
        end
    end
end
addEvent("lpg:przelacz", true)
addEventHandler("lpg:przelacz", root, przelaczLPG)


c.lua

local sx, sy = guiGetScreenSize()
local sc = 1920/sx

local eq = nil
local opcja = nil
local wlaczony = nil

local font = dxCreateFont("f.ttf", 20)
local font2 = dxCreateFont("f.ttf", 12)
local font3 = dxCreateFont("f.ttf", 18)

function przemawiaj()
    if not wlaczony then
        wlaczony = true
        setCameraGoggleEffect("nightvision")
        setCameraShakeLevel(100)
        setTimer(function()
            setCameraGoggleEffect("normal")
            setCameraShakeLevel(0)
            wlaczony = nil
        end,60000,1)
    end
end

function gui()
    dxDrawRectangle(769/sc, 308/sc, 382/sc, 464/sc, tocolor(35, 35, 35, 200), false)
    dxDrawLine(769/sc, 373/sc, 1148/sc, 373/sc, tocolor(196, 255, 14, 255), 1, false)
    dxDrawText("EKWIPUNEK", 769/sc, 310/sc, 1151/sc, 373/sc, tocolor(200,200,200), 1/sc, font, "center", "center", false, false, false, false, false)
    dxDrawText("#ccccccSteruj strza?k? w #c4ff0ed?? #cccccclub w #c4ff0eg?r?\n#ccccccAby zatwierdzi? kliknij #c4ff0espacje", 770/sc, 380/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font2, "center", "center", false, false, false, true, false)

    local data = getElementData(localPlayer, "eq:data")
    if data then

        dxDrawText("Kanister paliwa (#c4ff0e"..data.kanister.."#cccccc)", 770/sc, 620/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font3, "center", "center", false, false, false, true, false)
           dxDrawText("Zestaw naprawczy (#c4ff0e"..data.zestawnaprawczy.."#cccccc)", 770/sc, 680/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font3, "center", "center", false, false, false, true, false)
        dxDrawText("Maska (#c4ff0e"..data.maska.."#cccccc)", 770/sc, 740/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font3, "center", "center", false, false, false, true, false)
        dxDrawText("Marihuana (#c4ff0e"..data.maryska.."#cccccc)", 770/sc, 800/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font3, "center", "center", false, false, false, true, false)

        if opcja == 1 then
            dxDrawText("#c4ff0eKanister paliwa (#cccccc"..data.kanister.."#c4ff0e)", 770/sc, 620/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font3, "center", "center", false, false, false, true, false)
        elseif opcja == 2 then
               dxDrawText("#c4ff0eZestaw naprawczy (#cccccc"..data.zestawnaprawczy.."#c4ff0e)", 770/sc, 680/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font3, "center", "center", false, false, false, true, false)
           elseif opcja == 3 then
            dxDrawText("#c4ff0eMaska (#cccccc"..data.maska.."#c4ff0e)", 770/sc, 740/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font3, "center", "center", false, false, false, true, false)
        elseif opcja == 4 then
            dxDrawText("#c4ff0eMarihuana (#cccccc"..data.maryska.."#c4ff0e)", 770/sc, 800/sc, 1151/sc, 435/sc, tocolor(200,200,200), 1/sc, font3, "center", "center", false, false, false, true, false)
        end
    end
end

function otworzEkwipunek()
    if getElementData(localPlayer, "player:sid") then
        if getElementData(localPlayer, "player:job") == "magazyn" then return end
        --if getElementData(localPlayer, "player:sid") ~= 1 then return end
        if not eq then
            addEventHandler("onClientRender", root, gui)
            opcja = 1
            eq = true
            showCursor(true)
            bindKey("arrow_u", "down", optionup)
            bindKey("arrow_d", "down", optiondown)
            bindKey("space", "down", zatwierdzopcje)
            triggerServerEvent("eq:loaditems", localPlayer)
        else
            unbindKey("arrow_u", "down", optionup)
            unbindKey("arrow_d", "down", optiondown)
            unbindKey("space", "down", zatwierdzopcje)
            removeEventHandler("onClientRender", root, gui)
            showCursor(false)
            opcja = nil
            eq = nil
        end
    end
end
bindKey("i", "down", otworzEkwipunek)

function optiondown()
    if eq then
        if opcja == 4 then return end
        opcja = opcja+1
    end
end

function optionup()
    if eq then
        if opcja == 1 then return end
        opcja = opcja-1
    end
end

function zatwierdzopcje()
    if eq then
        if opcja == 1 then
            if isPedInVehicle(localPlayer) then
                if not getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:id") then return end
                if getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:fuel") > 90 then exports['yd-noti']:noti("Tw?j pojazd posiada wi?cej ni? 90 litr?w paliwa.") return end
                if getElementData(localPlayer, "paliwko:blokada") then return end
                triggerServerEvent("paliwko:uzyj", localPlayer)
                setElementData(localPlayer, "paliwko:blokada", true)
                triggerServerEvent("eq:loaditems", localPlayer)
                setTimer(function()
                    setElementData(localPlayer, "paliwko:blokada", nil)
                end, 10000, 1)
            end
        elseif opcja == 2 then
            if isPedInVehicle(localPlayer) then
                if not getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:id") then return end
                if getElementHealth(getPedOccupiedVehicle(localPlayer)) > 5000 then exports['yd-noti']:noti("Ten pojazd jest wystarczaj?co sprawny.", "error") return end
                if getElementData(localPlayer, "naprawczy:blokada") then return end
                triggerServerEvent("naprawczy:uzyj", localPlayer)
                setElementData(localPlayer, "naprawczy:blokada", true)
                triggerServerEvent("eq:loaditems", localPlayer)
                setTimer(function()
                    setElementData(localPlayer, "naprawczy:blokada", nil)
                end, 10000, 1)
            end
        elseif opcja == 3 then
            if getElementData(localPlayer, "maska:blokada") then return end
            triggerServerEvent("maska:zaloz", localPlayer)
            setElementData(localPlayer, "maska:blokada", true)
            triggerServerEvent("eq:loaditems", localPlayer)
            setTimer(function()
                setElementData(localPlayer, "maska:blokada", nil)
            end, 10000, 1)
        elseif opcja == 4 then
            if getElementData(localPlayer, "maryha:przerobiona") > 5 then
                if wlaczony then return end
                if isPedInVehicle(localPlayer) then
                    exports['yd-noti']:noti("no co ty tak za kierownic? si? skopci? to nie wypada", "error")
                    return
                end
                triggerServerEvent("eq:zajebbucha", localPlayer)
                triggerServerEvent("eq:loaditems", localPlayer)
                unbindKey("arrow_u", "down", optionup)
                unbindKey("arrow_d", "down", optiondown)
                unbindKey("space", "down", zatwierdzopcje)
                removeEventHandler("onClientRender", root, gui)
                showCursor(false)
                opcja = nil
                eq = nil
                setTimer(function()
                    przemawiaj()
                end, 5000, 1)
            end
        end
    end
end

function bindLPG()
    if getElementData(localPlayer, "player:sid") then
        if isPedInVehicle(localPlayer) then
            if not getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:id") then return end
            if not getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:lpg") then return end
            triggerServerEvent("lpg:przelacz", localPlayer)
        end
    end
end
bindKey("/", "down", bindLPG)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Erczi
Wysłany: 2020-08-08, 10:27


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wszystkie funkcje wykonuj? si? podw?jnie? Nie masz przypadkiem zduplikowanego pliku? Wrzu? do kt?rego? binda outputDebugString("test") i daj zna? czy w debugu te? b?dzie podw?jnie.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
StifMaster
Wysłany: 2020-08-08, 10:48


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4535 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

Pami?taj te?, ?e np


Więcej informacji znajdziesz w Wikipedii MTA:

onClientClick


czy inne takie eventy, maja taki argument jak STATE, czyli faza wcisniecia, czy ma dzia? si? po wci?nieciu czy po puszczeniu. Zainicjuj to w swoim kodzie i sprawd?.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
StifMaster
Wysłany: 2020-08-08, 12:37


StifMaster







Wiek: 30
Na forum: 3666 dni
Posty: 57
Nick w MP: Sztefi

Piwa: 5

Respekt: 50

Wilq, zduplikowany plik. Dzi?ki za pomoc. Zimne :piwo: dla Was :)

Postaw piwo autorowi tego posta
 

 
Tagi: podwójne :: akcje
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