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

Wysłany: 2018-03-01, 19:17


killercycDDS

Migacz






Wiek: 26
Na forum: 4653 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1667

Respekt: 22

Witam mam problem z napraw? pojazd?w. Wyskakuje mi b??d
triggered serverside event montazElementu, but event is not added serverside

Czyta?em na forum i jeden z u?ytkownik?w zmieni? na inn? napraw? i u niego to dzia?a?o. Natomiast u mnie wgra?em ju? 4 r??ne systemy napraw i nie dzia?a.

--[[
    Resource: OURGame
    Developers: Split <split.programista@gmail.com>
    Copyright <split.programista@gmail.com> 2015-2016
    You have no right to use this code without my permission.
]]

local m_dostep="mechanik-sf"

local doFixed={
    {"Silnik", 1, fn=function(veh) if getElementHealth(veh)>=2040 then return true end; return false end}, 
    {"Maska", 2, fn=function(veh) if getVehicleDoorState(veh, 0)==0 then return true end; return false end},
    {"Baga?nik", 3, fn=function(veh) if getVehicleDoorState(veh, 1)==0 then return true end; return false end},
    {"Drzwi lewy prz?d", 4, fn=function(veh) if getVehicleDoorState(veh, 2)==0 then return true end; return false end},
    {"Drzwi prawy prz?d", 5, fn=function(veh) if getVehicleDoorState(veh, 3)==0 then return true end; return false end},
    {"Drzwi lewy ty?", 6, fn=function(veh) if getVehicleDoorState(veh, 4)==0 then return true end; return false end},
    {"Drzwi prawy ty?", 7, fn=function(veh) if getVehicleDoorState(veh, 5)==0 then return true end; return false end},
    {"Szyba przednia", 8, fn=function(veh) if getVehiclePanelState(veh, 4)==0 then return true end; return false end},
    {"Zderzak przedni", 9, fn=function(veh) if getVehiclePanelState(veh, 5)==0 then return true end; return false end},
    {"Zderzak tylni", 10, fn=function(veh) if getVehiclePanelState(veh, 6)==0 then return true end; return false end},
    {"?wiat?o lewe przednie", 11, fn=function(veh) if getVehicleLightState(veh, 0)==0 then return true end; return false end},
    {"?wiat?a prawe przednie", 12, fn=function(veh) if getVehicleLightState(veh, 1)==0 then return true end; return false end},
    {"?wiat?a lewe tylnie", 13, fn=function(veh) if getVehicleLightState(veh, 2)==0 then return true end; return false end},
    {"?wiat?a prawe tylnie", 14, fn=function(veh) if getVehicleLightState(veh, 3)==0 then return true end; return false end},
}

local doCosts ={ 50, 20, 20, 15, 15, 15, 15, 40, 10, 10, 20, 20, 20, 20 }

local wm={}
local isVehicles=nil
wm.window = guiCreateWindow(0.18, 0.21, 0.64, 0.52, "", true)
guiWindowSetSizable(wm.window, false)
guiSetVisible(wm.window, false)
guiSetAlpha(wm.window, 1.00)
wm.gridlist = guiCreateGridList(0.01, 0.07, 0.97, 0.75, true, wm.window)
guiGridListAddColumn(wm.gridlist, "Nazwa", 0.5)
guiGridListAddColumn(wm.gridlist, "Koszt", 0.5)
guiGridListAddRow(wm.gridlist)
wm.fixall = guiCreateButton(0.75, 0.85, 0.24, 0.11, "Napraw wszystko (200 PLN)", true, wm.window)
wm.fixparts = guiCreateButton(0.02, 0.85, 0.24, 0.11, "Napraw wybran? cz???", true, wm.window)

local function refreshGUI()
    if not isVehicles then return end

    guiGridListClear(wm.gridlist)
    for i,v in pairs(doFixed) do
        if v.fn(isVehicles)==false then
            local row = guiGridListAddRow(wm.gridlist)
            guiGridListSetItemText(wm.gridlist, row, 1, v[1], false, false)
            guiGridListSetItemData(wm.gridlist, row, 1, i)
            guiGridListSetItemText(wm.gridlist, row, 2, doCosts[i].." PLN", false, false)
            guiGridListSetItemData(wm.gridlist, row, 2, doCosts[i])
        end
    end
end

addEventHandler("onClientMarkerHit", resourceRoot, function(el,md)
    if not md or el~=localPlayer then return end
    local cs=getElementData(source, "snn_cs")
    if not cs then return end
    local vehicles=getElementsWithinColShape(cs,"vehicle")
    if #vehicles < 1 then
        outputChatBox("* Na stanowisku naprawczym nie znajduje si? pojazd.", 255, 0, 0)
        return
    end
    if #vehicles > 1 then
        outputChatBox("* Na stanowisku naprawczym znajduje si? zbyt du?a ilo?? pojazd?w.", 255, 0, 0)
        return
    end
    --[[if getElementHealth(vehicles[1]) > 990 then
        outputChatBox("* Pojazd na stanowisku naprawczym jest sprawny.")
        return
    end]]
    showCursor(true, false)
    guiSetVisible(wm.window, true)
    isVehicles = vehicles[1]
    guiGridListClear(wm.gridlist)
    for i,v in pairs(doFixed) do
        if v.fn(isVehicles)==false then
            local row = guiGridListAddRow(wm.gridlist)
            guiGridListSetItemText(wm.gridlist, row, 1, v[1], false, false)
            guiGridListSetItemData(wm.gridlist, row, 1, i)
            guiGridListSetItemText(wm.gridlist, row, 2, doCosts[i].." PLN", false, false)
            guiGridListSetItemData(wm.gridlist, row, 2, doCosts[i])
        end
    end
end)

addEventHandler("onClientMarkerLeave", resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(wm.window, false)
    isVehicles=nil
    showCursor(false)
end)

addEventHandler("onClientGUIClick", wm.fixparts, function()
    if not isVehicles or not isElement(isVehicles) then return end
    selectedRow = guiGridListGetSelectedItem(wm.gridlist) or -1
    if selectedRow < 0 then return end
    local cost = guiGridListGetItemData(wm.gridlist, selectedRow, 2)
    if cost > getPlayerMoney(localPlayer) then
        outputChatBox("* Nie posiadasz tyle got?wki!")
        return
    end

    local part = guiGridListGetItemData(wm.gridlist, selectedRow, 1)
    outputChatBox('* Naprawiles ' .. tostring(getPartName(doFixed, part)))
    triggerServerEvent("takePlayerMoney", localPlayer, cost)
    triggerServerEvent("montazElementu", root, isVehicles, "naprawa", part, cost)
    setTimer(function()
        refreshGUI()
    end, 200, 2)
end)

addEventHandler("onClientGUIClick", wm.fixall, function()
    if not isVehicles or not isElement(isVehicles) then return end
    if 200 > getPlayerMoney(localPlayer) then
        outputChatBox("* Nie posiadasz tyle got?wki!")
        return
    end

    local elementyDoNaprawy=0
    for i,v in pairs(doFixed) do
        if v.fn(isVehicles)==false then
            elementyDoNaprawy=elementyDoNaprawy+1
        end
    end
    if elementyDoNaprawy==0 then
        outputChatBox('* Pojazd jest ju? naprawiony.')
        return
    end

    triggerServerEvent("takePlayerMoney", localPlayer, 270)
    outputChatBox('* Naprawi?e?(a?) wszystkie elementy w poje?dzie.')
    triggerServerEvent("montazElementu", root, isVehicles, "naprawa", "all", 270)
    setTimer(function()
        refreshGUI()
    end, 200, 2)
end)

-- utils
function getPartName(t, key)
    for i,v in pairs(t) do
        if v[2]==key then
            return v[1]
        end
    end
end
fileDelete('c_naprawa.lua')


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-01, 19:45


Ciastuuś

As-salamu alaykum






Wiek: 27
Na forum: 3212 dni
Posty: 800
Nick w MP: Ciastuuś

Piwa: 4304

Respekt: 640
Respekt: 640Respekt: 640

Trzymaj, po stronie servera

niewspiera_tuningu = {
[503] = true,
}
addEvent("montazElementu", true)
addEventHandler("montazElementu", root, function(veh, typ, czesc, koszt, nazwaCzesci)
    if tostring(typ) == "naprawa" then
        zgoda=true
        zgoda2=false
        if czesc == "all" then
            setElementHealth(veh, 10000)
            fixVehicle(veh)
            setElementHealth(veh, 10000)
            setVehicleDoorState(veh, 0, 0)
            setVehicleDoorState(veh, 1, 0)
            setVehicleDoorState(veh, 2, 0)
            setVehicleDoorState(veh, 3, 0)
            setVehicleDoorState(veh, 4, 0)
            setVehicleDoorState(veh, 5, 0)
            setVehiclePanelState(veh, 4, 0)
            setVehiclePanelState(veh, 5, 0)
            setVehiclePanelState(veh, 6, 0)
            setVehicleLightState(veh, 0, 0)
            setVehicleLightState(veh, 1, 0)
            setVehicleLightState(veh, 2, 0)
            setVehicleLightState(veh, 3, 0)
        else
            if czesc == 1 then setElementHealth(veh, 10000) end
            if czesc == 2 then setVehicleDoorState(veh, 0, 0) end
            if czesc == 3 then setVehicleDoorState(veh, 1, 0) end
            if czesc == 4 then setVehicleDoorState(veh, 2, 0) end
            if czesc == 5 then setVehicleDoorState(veh, 3, 0) end
            if czesc == 6 then setVehicleDoorState(veh, 4, 0) end
            if czesc == 7 then setVehicleDoorState(veh, 5, 0) end
            if czesc == 8 then setVehiclePanelState(veh, 4, 0) end
            if czesc == 9 then setVehiclePanelState(veh, 5, 0) end
            if czesc == 10 then setVehiclePanelState(veh, 6, 0) end
            if czesc == 11 then setVehicleLightState(veh, 0, 0) end
            if czesc == 12 then setVehicleLightState(veh, 1, 0) end
            if czesc == 13 then setVehicleLightState(veh, 2, 0) end
            if czesc == 14 then setVehicleLightState(veh, 3, 0) end
        end
    end
    local id=getElementData(veh,"vehicle:id")
    if not id then return end
    if tostring(typ) == "swiatla" then
        zgoda=true
        zgoda2=false
        takePlayerMoney(client,koszt)
        setVehicleHeadLightColor(veh, czesc[1], czesc[2], czesc[3])
        query=string.format("UPDATE ogrpg_vehicles SET headlights='%d,%d,%d' WHERE id=?", czesc[1], czesc[2], czesc[3], id)
        exports["ogrpg-db"]:dbSet(query) -- set rekords
    end
    if tostring(typ) == "kolor" then
        zgoda=false
        zgoda2=false
        local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12=getVehicleColor(veh, true)
        setVehicleColor(veh, czesc[1], czesc[2], czesc[3],c4,c5,c6,c7,c8,c9,c10,c11,c12)
        query=string.format("UPDATE ogrpg_vehicles SET color='%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d' WHERE id=?", czesc[1], czesc[2], czesc[3],c4,c5,c6,c7,c8,c9,c10,c11,c12, id)
        exports["ogrpg-db"]:dbSet(query) -- set rekords
    end
    if tostring(typ) == "kolor2" then
        zgoda=false
        zgoda2=false
        local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12=getVehicleColor(veh, true)
        setVehicleColor(veh, c1,c2,c3,czesc[1], czesc[2], czesc[3],c7,c8,c9,c10,c11,c12)
        query=string.format("UPDATE ogrpg_vehicles SET color='%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d' WHERE id=?", c1,c2,c3,czesc[1], czesc[2], czesc[3],c7,c8,c9,c10,c11,c12, id)
        exports["ogrpg-db"]:dbSet(query) -- set rekords
    end
    if tostring(typ) == "tuning" then
        if niewspiera_tuningu[getElementModel(veh)] then outputChatBox("* Tego pojazdu nie mozesz tuningowa?!",client) return end
        if getPlayerMoney(client)<tonumber(koszt) then
            local brakhajsu = string.format("*Nie sta? ci? na %s brakuj? ci %d PLN", nazwaCzesci, tonumber(koszt)-getPlayerMoney(client))
            outputChatBox(brakhajsu, client)
        return end
        local driver=getVehicleController(veh)
        if driver then
            removeVehicleUpgrade(veh,czesc)
            outputChatBox("* Zamontowano cz??c:"..nazwaCzesci.."("..czesc.."), koszt: "..koszt.." PLN'?w", driver)
        else
            outputChatBox("* Brak kierowcy w pojedzie", client) return
        end
        takePlayerMoney(client, koszt)
        zgoda=true
        zgoda2=false
        addVehicleUpgrade(veh, czesc)
        upgrades=getVehicleUpgrades(veh)
        if not upgrades then upgrades={} end
        upgrades=table.concat(upgrades, ",")
        query=string.format("UPDATE ogrpg_vehicles SET tuning='%s' WHERE id=?", upgrades, id)
        exports["ogrpg-db"]:dbSet(query) -- set rekords
    end
    if tostring(typ) == "demtuning" then
        driver=getVehicleController(veh)
        if not driver then outputChatBox("* Brak kierowcy w pojedzie", client) return end
        if getElementData(veh,"vehicle:ownedPlayer") ~= getElementData(driver,"player:uid") then outputChatBox("* Kierowca nie jest w?ascicielem!",client) return end
        if removeVehicleUpgrade(veh,czesc) == true then
            if driver then
                removeVehicleUpgrade(veh,czesc)
                givePlayerMoney(driver,koszt)
                outputChatBox("* Zdemontowano cz??c: "..nazwaCzesci.."("..czesc.."), zwrot: "..koszt.." PLN'?w", driver)
            end
            zgoda=false
            zgoda2=true
            upgrades=getVehicleUpgrades(veh)
            if not upgrades then upgrades={} end
            upgrades=table.concat(upgrades, ",")
            query=string.format("UPDATE ogrpg_vehicles SET tuning='%s' WHERE id=?", upgrades, id)
            exports["ogrpg-db"]:dbSet(query) -- set rekords
        end
    end
    if zgoda == true then
        text="WARSZTAT Zamontowano "..typ..", dla pojazdu id "..id..", koszt "..koszt.." PLN'?w"
        triggerClientEvent("onDebugMessage", resourceRoot, text,5, "INNE")
        triggerEvent("admin:logs", root, text)
    end
    if zgoda2 == true then
        text="WARSZTAT Zdemontowano "..czesc..", dla pojazdu id "..id..", koszt "..koszt.." PLN'?w"
        triggerClientEvent("onDebugMessage", resourceRoot, text,5, "INNE")
        triggerEvent("admin:logs", root, text)
    end
end)


Podpis
As-salamu alaykum
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
killercycDDS
Wysłany: 2018-03-01, 19:51


killercycDDS

Migacz






Wiek: 26
Na forum: 4653 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1667

Respekt: 22

poradzi?em sobie nie mia?em ogrpg_montaz :facepalm:

Postaw piwo autorowi tego posta
 

 
Tagi: naprawa :: pojazdów :: ogrpg
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