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: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

Witam mam problem z napraw? pojazd?w. Wyskakuje mi b??d
triggered serverside event montazElementubut 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.

--[[
    ResourceOURGame
    DevelopersSplit <split.programista@gmail.com>
    Copyright <split.programista@gmail.com2015-2016
    You have no right to use this code without my permission.
]]

local m_dostep="mechanik-sf"

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

local doCosts ={ 5020201515151540101020202020 }

local wm={}
local isVehicles=nil
wm.window guiCreateWindow(0.180.210.640.52""true)
guiWindowSetSizable(wm.windowfalse)
guiSetVisible(wm.windowfalse)
guiSetAlpha(wm.window1.00)
wm.gridlist guiCreateGridList(0.010.070.970.75truewm.window)
guiGridListAddColumn(wm.gridlist"Nazwa"0.5)
guiGridListAddColumn(wm.gridlist"Koszt"0.5)
guiGridListAddRow(wm.gridlist)
wm.fixall guiCreateButton(0.750.850.240.11"Napraw wszystko (200 PLN)"truewm.window)
wm.fixparts guiCreateButton(0.020.850.240.11"Napraw wybran? cz???"truewm.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.gridlistrow1v[1], falsefalse)
            guiGridListSetItemData(wm.gridlistrow1i)
            guiGridListSetItemText(wm.gridlistrow2doCosts[i].." PLN"falsefalse)
            guiGridListSetItemData(wm.gridlistrow2doCosts[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."25500)
        return
    end
    if #vehicles > 1 then
        outputChatBox("* Na stanowisku naprawczym znajduje si? zbyt du?a ilo?? pojazd?w."25500)
        return
    end
    --[[if getElementHealth(vehicles[1]) > 990 then
        outputChatBox("* Pojazd na stanowisku naprawczym jest sprawny.")
        return
    end]]
    showCursor(truefalse)
    guiSetVisible(wm.windowtrue)
    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.gridlistrow1v[1], falsefalse)
            guiGridListSetItemData(wm.gridlistrow1i)
            guiGridListSetItemText(wm.gridlistrow2doCosts[i].." PLN"falsefalse)
            guiGridListSetItemData(wm.gridlistrow2doCosts[i])
        end
    end
end)

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

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

    local part guiGridListGetItemData(wm.gridlistselectedRow1)
    outputChatBox('* Naprawiles ' .. tostring(getPartName(doFixedpart)))
    triggerServerEvent("takePlayerMoney"localPlayercost)
    triggerServerEvent("montazElementu"rootisVehicles"naprawa"partcost)
    setTimer(function()
        refreshGUI()
    end2002)
end)

addEventHandler("onClientGUIClick"wm.fixall, function()
    if not isVehicles or not isElement(isVehiclesthen return end
    if 200 getPlayerMoney(localPlayerthen
        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"localPlayer270)
    outputChatBox('* Naprawi?e?(a?) wszystkie elementy w poje?dzie.')
    triggerServerEvent("montazElementu"rootisVehicles"naprawa""all"270)
    setTimer(function()
        refreshGUI()
    end2002)
end)

-- utils
function getPartName(tkey)
    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ś

Truck soon...






Wiek: 26
Na forum: 3071 dni
Posty: 799
Nick w MP: Ciastuuś

Piwa: 4297

Respekt: 640
Respekt: 640Respekt: 640

Trzymaj, po stronie servera

niewspiera_tuningu = {
[503] = true,
}
addEvent("montazElementu"true)
addEventHandler("montazElementu"root, function(vehtypczesckosztnazwaCzesci)
    if tostring(typ) == "naprawa" then
        zgoda=true
        zgoda2=false
        if czesc == "all" then
            setElementHealth(veh10000)
            fixVehicle(veh)
            setElementHealth(veh10000)
            setVehicleDoorState(veh00)
            setVehicleDoorState(veh10)
            setVehicleDoorState(veh20)
            setVehicleDoorState(veh30)
            setVehicleDoorState(veh40)
            setVehicleDoorState(veh50)
            setVehiclePanelState(veh40)
            setVehiclePanelState(veh50)
            setVehiclePanelState(veh60)
            setVehicleLightState(veh00)
            setVehicleLightState(veh10)
            setVehicleLightState(veh20)
            setVehicleLightState(veh30)
        else
            if czesc == 1 then setElementHealth(veh10000end
            if czesc == 2 then setVehicleDoorState(veh00end
            if czesc == 3 then setVehicleDoorState(veh10end
            if czesc == 4 then setVehicleDoorState(veh20end
            if czesc == 5 then setVehicleDoorState(veh30end
            if czesc == 6 then setVehicleDoorState(veh40end
            if czesc == 7 then setVehicleDoorState(veh50end
            if czesc == 8 then setVehiclePanelState(veh40end
            if czesc == 9 then setVehiclePanelState(veh50end
            if czesc == 10 then setVehiclePanelState(veh60end
            if czesc == 11 then setVehicleLightState(veh00end
            if czesc == 12 then setVehicleLightState(veh10end
            if czesc == 13 then setVehicleLightState(veh20end
            if czesc == 14 then setVehicleLightState(veh30end
        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(vehczesc[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(vehtrue)
        setVehicleColor(vehczesc[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,c12id)
        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(vehtrue)
        setVehicleColor(vehc1,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,c12id)
        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(kosztthen
            local brakhajsu string.format("*Nie sta? ci? na %s brakuj? ci %d PLN"nazwaCzescitonumber(koszt)-getPlayerMoney(client))
            outputChatBox(brakhajsuclient)
        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(clientkoszt)
        zgoda=true
        zgoda2=false
        addVehicleUpgrade(vehczesc)
        upgrades=getVehicleUpgrades(veh)
        if not upgrades then upgrades={} end
        upgrades=table.concat(upgrades",")
        query=string.format("UPDATE ogrpg_vehicles SET tuning='%s' WHERE id=?"upgradesid)
        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=?"upgradesid)
            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"resourceRoottext,5"INNE")
        triggerEvent("admin:logs"roottext)
    end
    if zgoda2 == true then
        text="WARSZTAT Zdemontowano "..czesc..", dla pojazdu id "..id..", koszt "..koszt.." PLN'?w"
        triggerClientEvent("onDebugMessage"resourceRoottext,5"INNE")
        triggerEvent("admin:logs"roottext)
    end
end)


Podpis
Truck soon...
Postaw piwo autorowi tego posta
 

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


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

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