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

Wysłany: 2017-02-04, 20:17


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

Witam mam problem z tym skryptem chodzi o to ze pobiera mi kas? x2 to jeszcze daje na minus jak mam 0 stara?em si? to ogarn?? i nic mi nie wychodzi.

S:
local stanowiskaNaprawcze = {
    stanowiskoDoherty={
        mpos={1106.54602,1760.97449,10.82031}, -- marker
        cpos={1094.73731757.045510.820313-111.756.755}, -- cuboid
        --faction_id=1, -- (idfrakcja kt?ra b?dzie mia?a dost?p
        text="Naprawa pojazdu"
    
    },
    stanowiskoLV={
        mpos={1107.12097,1750.85950,10.82031}, -- marker
        cpos={1095.2721747.289610.820313-19.56.255}, -- cuboid
        --faction_id=1, -- (idfrakcja kt?ra b?dzie mia?a dost?p
        text="Naprawa pojazdu"
    
    },
}


for i,v in pairs(stanowiskaNaprawcze) do
    v.cuboid=createColCuboid(unpack(v.cpos))
    v.marker=createMarker(v.mpos[1], v.mpos[2], v.mpos[3]-0.90"cylinder"1.200255100)
    --setElementData(v.marker,"snn_faction",v.faction_id)
    setElementData(v.marker,"snn_cs",v.cuboid)

    t=createElement("text")
    setElementData(t,"name",v.text)
    setElementPosition(t,v.mpos[1], v.mpos[2], v.mpos[3])
end


--   triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
addEvent("naprawaElementu"true)
addEventHandler("naprawaElementu"resourceRoot, function(pojazdczesckoszt)
  outputDebugString("Naprawa elementu " .. czesc .. " za " .. koszt)
  if koszt>getPlayerMoney(clientthen
    return
  end

  if (czesc==-1then
--    setElementHealth(pojazd1000)

    local vps={}
    local vds={}
    local vls={}

    for i=0,do          vps[i]=getVehiclePanelState(pojazd,i)     end
    for i=0,do          vds[i]=getVehicleDoorState(pojazd,iend
    for i=0,do          vls[i]=getVehicleLightState(pojazd,iend

    fixVehicle(pojazd)

    for i=0,do      setVehiclePanelState(pojazdivps[i])    end
    for i=0,do      setVehicleDoorState(pojazdivds[i])    end
    for i=0,do      setVehicleLightState(pojazdivls[i])    end

    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  elseif czesc>=and czesc<=6 then
    setVehiclePanelState(pojazdczesc0)
    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  elseif czesc>=10 and czesc<20 then
    local drzwi=czesc-10
    setVehicleDoorState(pojazddrzwi0)
    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  elseif czesc>=20 then
    local swiatlo=czesc-20
    setVehicleLightState(pojazdswiatlo0)
    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  end
end)

C:
--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@author Karer <karer.programmer@gmail.com>
@author RacheT <rachet@pylife.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@package MTA-XyzzyRP
@link https://github.com/lpiob/MTA-XyzzyRP GitHub
]]--

local screenWscreenH guiGetScreenSize()

local w_m={}



--utils
function math.round(numberdecimalsmethod)
        decimals decimals or 0
        local factor 10 decimals
        if (method == "ceil" or method == "floor"then return math[method](number factor) / factor
        else return tonumber(("%."..decimals.."f"):format(number)) end
end

function string:split(sep)
    local sepfields sep or ":", {}
    local pattern string.format("([^%s]+)"sep)
    self:gsub(pattern, function(cfields[#fields+1] = c end)
    return fields
end





w_m.wnd guiCreateStaticImage(0.190.190.720.55"panel.png"true)
--w_m.wnd guiCreateWindow(0.1469,0.1667,0.7344,0.675,"Panel mechanika",true)
w_m.btn_napraw guiCreateButton(0.0277,0.8395,0.3064,0.1327,"Napraw",true,w_m.wnd)

w_m.btn_zamknij guiCreateButton(0.3427,0.8395,0.3064,0.1327,"Zamknij",true,w_m.wnd)
w_m.lbl_info guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
w_m.lbl_costinfo guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
guiLabelSetHorizontalAlign(w_m.lbl_info"center"true)
guiLabelSetVerticalAlign(w_m.lbl_info"center")


w_m.grid guiCreateGridList(0.0298,0.0895,0.9383,0.7191,true,w_m.wnd)
guiGridListSetSelectionMode(w_m.grid,1)
guiGridListSetSortingEnabled(w_m.grid,false)
w_m.grid_nazwa guiGridListAddColumn w_m.grid"Nazwa cz??ci"0.3 )
w_m.grid_stan guiGridListAddColumn w_m.grid"Stan cz??ci"0.3 )
w_m.grid_koszt guiGridListAddColumn w_m.grid"Koszt naprawy"0.3 )
guiSetVisible(w_m.wnd,false)

local naprawiany_pojazd=nil

local function kosztNaprawySilnika(v)
    local vhp=1000-getElementHealth(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return vhp/1000*cenapojazdu*przebieg*0.002 -- it's that simple
end

local function kosztNaprawyElementu(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return cenapojazdu*przebieg*0.002 -- it's that simple
end

local panele={
    [0]="Karoseria lewy prz?d",
    [1]="Karoseria prawy prz?d",
    [2]="Karoseria lewy ty?",
    [3]="Karoseria prawy ty?",
    [4]="Szyba przednia",
    [5]="Zderzak z przodu",
    [6]="Zderzak z ty?u"
}
local stanyPaneli={
    [0]="100%",
    [1]="66%",
    [2]="33%",
    [3]="0%",
}
local nazwyDrzwi={
    [0]="Maska",
    [1]="Baga?nik",
    [2]="Drzwi lewy prz?d",
    [3]="Drzwi prawy prz?d",
    [4]="Drzwi lewy ty?",
    [5]="Drzwi prawy ty?"
}

local nazwySwiatel={
    [0]="?wiat?o lewy prz?d",
    [1]="?wiat?o prawy prz?d",
    [2]="?wiat?o lewy ty?",
    [3]="?wiat?o prawy ty?"
}

local function fillVehicleData(v)
    guiGridListClear(w_m.grid)
    do
    if getElementHealth(v) ~= 1000 then
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1"Silnik",false,false)
        guiGridListSetItemData(w_m.grid,row1, -1)
        guiGridListSetItemText(w_m.grid,row2math.round(getElementHealth(v)/10).."%"falsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(math.abs(kosztNaprawySilnika(v))+2).."PLN"falsetrue)
    end
    
    end
    for i,panel in pairs(panele) do
    local stan getVehiclePanelState(vi)
    if stan ~= 0 then
        local koszt=kosztNaprawyElementu(v)*(getVehiclePanelState(v,i))/6
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1panel,false,false)
        guiGridListSetItemData(w_m.grid,row1i)
        local stan=stanyPaneli[getVehiclePanelState(v,i)]
        guiGridListSetItemText(w_m.grid,row2stanfalsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
    end
    end
    -- drzwi
    for i=0,do
        local stan=getVehicleDoorState(vi)
        if stan==or stan==or stan==4 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwyDrzwi[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+10)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        end
    end
    for i=0,do
        local stan=getVehicleLightState(vi)
        if stan==1 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwySwiatel[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+20)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        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
    if getElementData(source"braniekola"then return end
    
    --local fid=getElementData(source"snn_faction")
    --local lfid=getElementData(el"player:faction") or -1
    
    --if fid~=lfid then return end -- gracz nie jest pracownikiem]]--
    local pojazdy=getElementsWithinColShape(cs,"vehicle")

    if #pojazdy<1 then
        outputChatBox("Na stanowisku naprawczym nie ma ?adnego pojazdu.")
        return
    end
    if #pojazdy>1 then
        outputChatBox("Na stanowisku naprawczym jest zbyt du?o pojazd?w.")
        return
    end
    allCost setTimer(function(plr) 
        
    end10000el)
    fillVehicleData(pojazdy[1])
    guiSetEnabled(w_m.btn_naprawfalse)
    guiSetText(w_m.lbl_info,"")
    showCursor(truefalse)
    guiSetVisible(w_m.wndtrue)
    guiSetText(w_m.btn_naprawstring.format("Napraw (%s)"getVehicleName(pojazdy[1])) )
    naprawiany_pojazd=pojazdy[1]
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    showCursor(false)
    if allCost and isTimer(allCostthen killTimer(allCostend
end)

addEventHandler("onClientGUIClick"w_m.btn_zamknij, function()
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    if allCost and isTimer(allCostthen killTimer(allCostend
endfalse)

addEventHandler("onClientGUIClick"w_m.grid, function()
        guiSetText(w_m.lbl_info,"")
        selectedRowguiGridListGetSelectedItem w_m.grid) or -1
        if (selectedRow<0then
            guiSetEnabled(w_m.btn_napraw,false)
            return
        end
        
        local multirepair = {}
        local rows guiGridListGetSelectedItems(w_m.grid)
        for k,v in ipairs(rows) do
            if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
                table.insert(multirepair,v)
            end
        end
        
        totalkoszt 0
        
        for k,v in ipairs(multirepair) do
            local koszt guiGridListGetItemText(w_m.gridv.row3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            totalkoszt totalkoszt+koszt
        end
        
        guiSetText(w_m.lbl_infostring.format("W sumie do zap?aty: %sPLN",totalkoszt))
        guiSetEnabled(w_m.btn_naprawtrue)
end)


local napraw_lu=getTickCount()
    
addEventHandler("onClientGUIClick"w_m.btn_napraw, function()
    if getTickCount()-napraw_lu<1000 then return end

    if not naprawiany_pojazd or not isElement(naprawiany_pojazdthen return end

    selectedRowguiGridListGetSelectedItem w_m.grid) or -1
    if selectedRow<0 then return end
    local rows guiGridListGetSelectedItems(w_m.grid)
    
    local multirepair = {}
    --musimy sprawdzicczy gracz zaznaczyl KILKA rowowczy JEDEN    //karer - takie male udogodnienie
    for k,v in ipairs(rows) do
        if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
            table.insert(multirepair,v)
        end
    end
    
    guiSetText(w_m.lbl_info,"")
    if #multirepair == 1 then
        local koszt guiGridListGetItemText(w_m.gridselectedRow3)
        local koszt koszt:split("PLN")
        local koszt tonumber(koszt[1])
        if not koszt then return end
        if koszt<=0 then
        guiSetText(w_m.lbl_info,"Ta cz??? jest sprawna.")
        return
        end
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end
        local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
        napraw_lu=getTickCount()
        triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        triggerServerEvent("takePlayerMoney"localPlayerkoszt)
    elseif #multirepair > 1 then
        for i,v in ipairs(multirepair) do
            local selectedRow v.row
            local koszt guiGridListGetItemText(w_m.gridselectedRow3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            triggerServerEvent("takePlayerMoney"localPlayerkoszt)
            if not koszt then return end
            if koszt<=0 then
                break
            end
            -- if koszt>getPlayerMoney(localPlayerthen
            -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            -- return
            end
            local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
            napraw_lu=getTickCount()
            triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        end
    else
        outputDebugScript("lss-naprawapojazdow> inna wartosc countRows, should't happen.")
    end
endfalse)

Z g?ry Dzi?kuje za pomoc.

Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 20:22


_Haze

Peace Yo!






Wiek: 24
Na forum: 4184 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

STOPseba, usu? --
            -- if koszt>getPlayerMoney(localPlayerthen
            -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            -- return
i usu?
 triggerServerEvent("takePlayerMoney"localPlayerkoszt)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
STOPseba
Wysłany: 2017-02-04, 20:56


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

"Hazmudex" napisał/a:

STOPseba, usu? --
            -- if koszt>getPlayerMoney(localPlayerthen
            -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            -- return
i usu?
 triggerServerEvent("takePlayerMoney"localPlayerkoszt)

Dalej to samo.
--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@author Karer <karer.programmer@gmail.com>
@author RacheT <rachet@pylife.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@package MTA-XyzzyRP
@link https://github.com/lpiob/MTA-XyzzyRP GitHub
]]--

local screenWscreenH guiGetScreenSize()

local w_m={}



--utils
function math.round(numberdecimalsmethod)
        decimals decimals or 0
        local factor 10 decimals
        if (method == "ceil" or method == "floor"then return math[method](number factor) / factor
        else return tonumber(("%."..decimals.."f"):format(number)) end
end

function string:split(sep)
    local sepfields sep or ":", {}
    local pattern string.format("([^%s]+)"sep)
    self:gsub(pattern, function(cfields[#fields+1] = c end)
    return fields
end





w_m.wnd guiCreateStaticImage(0.190.190.720.55"panel.png"true)
--w_m.wnd guiCreateWindow(0.1469,0.1667,0.7344,0.675,"Panel mechanika",true)
w_m.btn_napraw guiCreateButton(0.0277,0.8395,0.3064,0.1327,"Napraw",true,w_m.wnd)

w_m.btn_zamknij guiCreateButton(0.3427,0.8395,0.3064,0.1327,"Zamknij",true,w_m.wnd)
w_m.lbl_info guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
w_m.lbl_costinfo guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
guiLabelSetHorizontalAlign(w_m.lbl_info"center"true)
guiLabelSetVerticalAlign(w_m.lbl_info"center")


w_m.grid guiCreateGridList(0.0298,0.0895,0.9383,0.7191,true,w_m.wnd)
guiGridListSetSelectionMode(w_m.grid,1)
guiGridListSetSortingEnabled(w_m.grid,false)
w_m.grid_nazwa guiGridListAddColumn w_m.grid"Nazwa cz??ci"0.3 )
w_m.grid_stan guiGridListAddColumn w_m.grid"Stan cz??ci"0.3 )
w_m.grid_koszt guiGridListAddColumn w_m.grid"Koszt naprawy"0.3 )
guiSetVisible(w_m.wnd,false)

local naprawiany_pojazd=nil

local function kosztNaprawySilnika(v)
    local vhp=1000-getElementHealth(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return vhp/1000*cenapojazdu*przebieg*0.002 -- it's that simple
end

local function kosztNaprawyElementu(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return cenapojazdu*przebieg*0.002 -- it's that simple
end

local panele={
    [0]="Karoseria lewy prz?d",
    [1]="Karoseria prawy prz?d",
    [2]="Karoseria lewy ty?",
    [3]="Karoseria prawy ty?",
    [4]="Szyba przednia",
    [5]="Zderzak z przodu",
    [6]="Zderzak z ty?u"
}
local stanyPaneli={
    [0]="100%",
    [1]="66%",
    [2]="33%",
    [3]="0%",
}
local nazwyDrzwi={
    [0]="Maska",
    [1]="Baga?nik",
    [2]="Drzwi lewy prz?d",
    [3]="Drzwi prawy prz?d",
    [4]="Drzwi lewy ty?",
    [5]="Drzwi prawy ty?"
}

local nazwySwiatel={
    [0]="?wiat?o lewy prz?d",
    [1]="?wiat?o prawy prz?d",
    [2]="?wiat?o lewy ty?",
    [3]="?wiat?o prawy ty?"
}

local function fillVehicleData(v)
    guiGridListClear(w_m.grid)
    do
    if getElementHealth(v) ~= 1000 then
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1"Silnik",false,false)
        guiGridListSetItemData(w_m.grid,row1, -1)
        guiGridListSetItemText(w_m.grid,row2math.round(getElementHealth(v)/10).."%"falsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(math.abs(kosztNaprawySilnika(v))+2).."PLN"falsetrue)
    end
    
    end
    for i,panel in pairs(panele) do
    local stan getVehiclePanelState(vi)
    if stan ~= 0 then
        local koszt=kosztNaprawyElementu(v)*(getVehiclePanelState(v,i))/6
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1panel,false,false)
        guiGridListSetItemData(w_m.grid,row1i)
        local stan=stanyPaneli[getVehiclePanelState(v,i)]
        guiGridListSetItemText(w_m.grid,row2stanfalsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
    end
    end
    -- drzwi
    for i=0,do
        local stan=getVehicleDoorState(vi)
        if stan==or stan==or stan==4 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwyDrzwi[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+10)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        end
    end
    for i=0,do
        local stan=getVehicleLightState(vi)
        if stan==1 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwySwiatel[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+20)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        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
    if getElementData(source"braniekola"then return end
    
    --local fid=getElementData(source"snn_faction")
    --local lfid=getElementData(el"player:faction") or -1
    
    --if fid~=lfid then return end -- gracz nie jest pracownikiem]]--
    local pojazdy=getElementsWithinColShape(cs,"vehicle")

    if #pojazdy<1 then
        outputChatBox("Na stanowisku naprawczym nie ma ?adnego pojazdu.")
        return
    end
    if #pojazdy>1 then
        outputChatBox("Na stanowisku naprawczym jest zbyt du?o pojazd?w.")
        return
    end
    allCost setTimer(function(plr) 
        
    end10000el)
    fillVehicleData(pojazdy[1])
    guiSetEnabled(w_m.btn_naprawfalse)
    guiSetText(w_m.lbl_info,"")
    showCursor(truefalse)
    guiSetVisible(w_m.wndtrue)
    guiSetText(w_m.btn_naprawstring.format("Napraw (%s)"getVehicleName(pojazdy[1])) )
    naprawiany_pojazd=pojazdy[1]
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    showCursor(false)
    if allCost and isTimer(allCostthen killTimer(allCostend
end)

addEventHandler("onClientGUIClick"w_m.btn_zamknij, function()
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    if allCost and isTimer(allCostthen killTimer(allCostend
endfalse)

addEventHandler("onClientGUIClick"w_m.grid, function()
        guiSetText(w_m.lbl_info,"")
        selectedRowguiGridListGetSelectedItem w_m.grid) or -1
        if (selectedRow<0then
            guiSetEnabled(w_m.btn_napraw,false)
            return
        end
        
        local multirepair = {}
        local rows guiGridListGetSelectedItems(w_m.grid)
        for k,v in ipairs(rows) do
            if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
                table.insert(multirepair,v)
            end
        end
        
        totalkoszt 0
        
        for k,v in ipairs(multirepair) do
            local koszt guiGridListGetItemText(w_m.gridv.row3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            totalkoszt totalkoszt+koszt
        end
        
        guiSetText(w_m.lbl_infostring.format("W sumie do zap?aty: %sPLN",totalkoszt))
        guiSetEnabled(w_m.btn_naprawtrue)
end)


local napraw_lu=getTickCount()
    
addEventHandler("onClientGUIClick"w_m.btn_napraw, function()
    if getTickCount()-napraw_lu<1000 then return end

    if not naprawiany_pojazd or not isElement(naprawiany_pojazdthen return end

    selectedRowguiGridListGetSelectedItem w_m.grid) or -1
    if selectedRow<0 then return end
    local rows guiGridListGetSelectedItems(w_m.grid)
    
    local multirepair = {}
    --musimy sprawdzicczy gracz zaznaczyl KILKA rowowczy JEDEN    //karer - takie male udogodnienie
    for k,v in ipairs(rows) do
        if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
            table.insert(multirepair,v)
        end
    end
    
    guiSetText(w_m.lbl_info,"")
    if #multirepair == 1 then
        local koszt guiGridListGetItemText(w_m.gridselectedRow3)
        local koszt koszt:split("PLN")
        local koszt tonumber(koszt[1])
        if not koszt then return end
        if koszt<=0 then
        guiSetText(w_m.lbl_info,"Ta cz??? jest sprawna.")
        return
        end
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end
        local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
        napraw_lu=getTickCount()
        triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        triggerServerEvent("takePlayerMoney"localPlayerkoszt)
    elseif #multirepair > 1 then
        for i,v in ipairs(multirepair) do
            local selectedRow v.row
            local koszt guiGridListGetItemText(w_m.gridselectedRow3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            if not koszt then return end
            if koszt<=0 then
                break
            end
            if koszt>getPlayerMoney(localPlayerthen
            guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            return
            end
            local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
            napraw_lu=getTickCount()
            triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        end
    else
        outputDebugScript("lss-naprawapojazdow> inna wartosc countRows, should't happen.")
    end
endfalse)


Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:09


_Haze

Peace Yo!






Wiek: 24
Na forum: 4184 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

STOPseba, nie zrobi?e? tego, usu? komentarze do tego.
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
STOPseba
Wysłany: 2017-02-04, 21:15


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

"Hazmudex" napisał/a:

STOPseba, nie zrobi?e? tego, usu? komentarze do tego.
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end

Dzi?ki ju? nie zabiera na - ale dalej x2

Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:42


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@author Karer <karer.programmer@gmail.com>
@author RacheT <rachet@pylife.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@package MTA-XyzzyRP
@link https://github.com/lpiob/MTA-XyzzyRP GitHub
]]--

local screenWscreenH guiGetScreenSize()

local w_m={}



--utils
function math.round(numberdecimalsmethod)
        decimals decimals or 0
        local factor 10 decimals
        if (method == "ceil" or method == "floor"then return math[method](number factor) / factor
        else return tonumber(("%."..decimals.."f"):format(number)) end
end

function string:split(sep)
    local sepfields sep or ":", {}
    local pattern string.format("([^%s]+)"sep)
    self:gsub(pattern, function(cfields[#fields+1] = c end)
    return fields
end





w_m.wnd guiCreateStaticImage(0.190.190.720.55"panel.png"true)
--w_m.wnd guiCreateWindow(0.1469,0.1667,0.7344,0.675,"Panel mechanika",true)
w_m.btn_napraw guiCreateButton(0.0277,0.8395,0.3064,0.1327,"Napraw",true,w_m.wnd)

w_m.btn_zamknij guiCreateButton(0.3427,0.8395,0.3064,0.1327,"Zamknij",true,w_m.wnd)
w_m.lbl_info guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
w_m.lbl_costinfo guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
guiLabelSetHorizontalAlign(w_m.lbl_info"center"true)
guiLabelSetVerticalAlign(w_m.lbl_info"center")


w_m.grid guiCreateGridList(0.0298,0.0895,0.9383,0.7191,true,w_m.wnd)
guiGridListSetSelectionMode(w_m.grid,1)
guiGridListSetSortingEnabled(w_m.grid,false)
w_m.grid_nazwa guiGridListAddColumn w_m.grid"Nazwa cz??ci"0.3 )
w_m.grid_stan guiGridListAddColumn w_m.grid"Stan cz??ci"0.3 )
w_m.grid_koszt guiGridListAddColumn w_m.grid"Koszt naprawy"0.3 )
guiSetVisible(w_m.wnd,false)

local naprawiany_pojazd=nil

local function kosztNaprawySilnika(v)
    local vhp=1000-getElementHealth(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return vhp/1000*cenapojazdu*przebieg*0.002 -- it's that simple
end

local function kosztNaprawyElementu(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return cenapojazdu*przebieg*0.002 -- it's that simple
end

local panele={
    [0]="Karoseria lewy prz?d",
    [1]="Karoseria prawy prz?d",
    [2]="Karoseria lewy ty?",
    [3]="Karoseria prawy ty?",
    [4]="Szyba przednia",
    [5]="Zderzak z przodu",
    [6]="Zderzak z ty?u"
}
local stanyPaneli={
    [0]="100%",
    [1]="66%",
    [2]="33%",
    [3]="0%",
}
local nazwyDrzwi={
    [0]="Maska",
    [1]="Baga?nik",
    [2]="Drzwi lewy prz?d",
    [3]="Drzwi prawy prz?d",
    [4]="Drzwi lewy ty?",
    [5]="Drzwi prawy ty?"
}

local nazwySwiatel={
    [0]="?wiat?o lewy prz?d",
    [1]="?wiat?o prawy prz?d",
    [2]="?wiat?o lewy ty?",
    [3]="?wiat?o prawy ty?"
}

local function fillVehicleData(v)
    guiGridListClear(w_m.grid)
    do
    if getElementHealth(v) ~= 1000 then
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1"Silnik",false,false)
        guiGridListSetItemData(w_m.grid,row1, -1)
        guiGridListSetItemText(w_m.grid,row2math.round(getElementHealth(v)/10).."%"falsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(math.abs(kosztNaprawySilnika(v))+2).."PLN"falsetrue)
    end
    
    end
    for i,panel in pairs(panele) do
    local stan getVehiclePanelState(vi)
    if stan ~= 0 then
        local koszt=kosztNaprawyElementu(v)*(getVehiclePanelState(v,i))/6
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1panel,false,false)
        guiGridListSetItemData(w_m.grid,row1i)
        local stan=stanyPaneli[getVehiclePanelState(v,i)]
        guiGridListSetItemText(w_m.grid,row2stanfalsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
    end
    end
    -- drzwi
    for i=0,do
        local stan=getVehicleDoorState(vi)
        if stan==or stan==or stan==4 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwyDrzwi[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+10)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        end
    end
    for i=0,do
        local stan=getVehicleLightState(vi)
        if stan==1 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwySwiatel[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+20)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        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
    if getElementData(source"braniekola"then return end
    
    --local fid=getElementData(source"snn_faction")
    --local lfid=getElementData(el"player:faction") or -1
    
    --if fid~=lfid then return end -- gracz nie jest pracownikiem]]--
    local pojazdy=getElementsWithinColShape(cs,"vehicle")

    if #pojazdy<1 then
        outputChatBox("Na stanowisku naprawczym nie ma ?adnego pojazdu.")
        return
    end
    if #pojazdy>1 then
        outputChatBox("Na stanowisku naprawczym jest zbyt du?o pojazd?w.")
        return
    end
    allCost setTimer(function(plr) 
        
    end10000el)
    fillVehicleData(pojazdy[1])
    guiSetEnabled(w_m.btn_naprawfalse)
    guiSetText(w_m.lbl_info,"")
    showCursor(truefalse)
    guiSetVisible(w_m.wndtrue)
    guiSetText(w_m.btn_naprawstring.format("Napraw (%s)"getVehicleName(pojazdy[1])) )
    naprawiany_pojazd=pojazdy[1]
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    showCursor(false)
    if allCost and isTimer(allCostthen killTimer(allCostend
end)

addEventHandler("onClientGUIClick"w_m.btn_zamknij, function()
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    if allCost and isTimer(allCostthen killTimer(allCostend
endfalse)

addEventHandler("onClientGUIClick"w_m.grid, function()
        guiSetText(w_m.lbl_info,"")
        selectedRowguiGridListGetSelectedItem w_m.grid) or -1
        if (selectedRow<0then
            guiSetEnabled(w_m.btn_napraw,false)
            return
        end
        
        local multirepair = {}
        local rows guiGridListGetSelectedItems(w_m.grid)
        for k,v in ipairs(rows) do
            if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
                table.insert(multirepair,v)
            end
        end
        
        totalkoszt 0
        
        for k,v in ipairs(multirepair) do
            local koszt guiGridListGetItemText(w_m.gridv.row3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            totalkoszt totalkoszt+koszt
        end
        
        guiSetText(w_m.lbl_infostring.format("W sumie do zap?aty: %sPLN",totalkoszt))
        guiSetEnabled(w_m.btn_naprawtrue)
end)


local napraw_lu=getTickCount()
    
addEventHandler("onClientGUIClick"w_m.btn_napraw, function()
    if getTickCount()-napraw_lu<1000 then return end

    if not naprawiany_pojazd or not isElement(naprawiany_pojazdthen return end

    selectedRowguiGridListGetSelectedItem w_m.grid) or -1
    if selectedRow<0 then return end
    local rows guiGridListGetSelectedItems(w_m.grid)
    
    local multirepair = {}
    --musimy sprawdzicczy gracz zaznaczyl KILKA rowowczy JEDEN    //karer - takie male udogodnienie
    for k,v in ipairs(rows) do
        if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
            table.insert(multirepair,v)
        end
    end
    
    guiSetText(w_m.lbl_info,"")
    if #multirepair == 1 then
        local koszt guiGridListGetItemText(w_m.gridselectedRow3)
        local koszt koszt:split("PLN")
        local koszt tonumber(koszt[1])
        if not koszt then return end
        if koszt<=0 then
        guiSetText(w_m.lbl_info,"Ta cz??? jest sprawna.")
        return
        end
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end
        local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
        napraw_lu=getTickCount()
        triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
       -- triggerServerEvent("takePlayerMoney"localPlayerkoszt)
    elseif #multirepair > 1 then
        for i,v in ipairs(multirepair) do
            local selectedRow v.row
            local koszt guiGridListGetItemText(w_m.gridselectedRow3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            if not koszt then return end
            if koszt<=0 then
                break
            end
            if koszt>getPlayerMoney(localPlayerthen
            guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            return
            end
            local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
            napraw_lu=getTickCount()
            triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        end
    else
        outputDebugScript("lss-naprawapojazdow> inna wartosc countRows, should't happen.")
    end
endfalse)


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
STOPseba
Wysłany: 2017-02-04, 21:49


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

"marcin778" napisał/a:

--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@author Karer <karer.programmer@gmail.com>
@author RacheT <rachet@pylife.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@package MTA-XyzzyRP
@link https://github.com/lpiob/MTA-XyzzyRP GitHub
]]--

local screenWscreenH guiGetScreenSize()

local w_m={}



--utils
function math.round(numberdecimalsmethod)
        decimals decimals or 0
        local factor 10 decimals
        if (method == "ceil" or method == "floor"then return math[method](number factor) / factor
        else return tonumber(("%."..decimals.."f"):format(number)) end
end

function string:split(sep)
    local sepfields sep or ":", {}
    local pattern string.format("([^%s]+)"sep)
    self:gsub(pattern, function(cfields[#fields+1] = c end)
    return fields
end





w_m.wnd guiCreateStaticImage(0.190.190.720.55"panel.png"true)
--w_m.wnd guiCreateWindow(0.1469,0.1667,0.7344,0.675,"Panel mechanika",true)
w_m.btn_napraw guiCreateButton(0.0277,0.8395,0.3064,0.1327,"Napraw",true,w_m.wnd)

w_m.btn_zamknij guiCreateButton(0.3427,0.8395,0.3064,0.1327,"Zamknij",true,w_m.wnd)
w_m.lbl_info guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
w_m.lbl_costinfo guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
guiLabelSetHorizontalAlign(w_m.lbl_info"center"true)
guiLabelSetVerticalAlign(w_m.lbl_info"center")


w_m.grid guiCreateGridList(0.0298,0.0895,0.9383,0.7191,true,w_m.wnd)
guiGridListSetSelectionMode(w_m.grid,1)
guiGridListSetSortingEnabled(w_m.grid,false)
w_m.grid_nazwa guiGridListAddColumn w_m.grid"Nazwa cz??ci"0.3 )
w_m.grid_stan guiGridListAddColumn w_m.grid"Stan cz??ci"0.3 )
w_m.grid_koszt guiGridListAddColumn w_m.grid"Koszt naprawy"0.3 )
guiSetVisible(w_m.wnd,false)

local naprawiany_pojazd=nil

local function kosztNaprawySilnika(v)
    local vhp=1000-getElementHealth(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return vhp/1000*cenapojazdu*przebieg*0.002 -- it's that simple
end

local function kosztNaprawyElementu(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return cenapojazdu*przebieg*0.002 -- it's that simple
end

local panele={
    [0]="Karoseria lewy prz?d",
    [1]="Karoseria prawy prz?d",
    [2]="Karoseria lewy ty?",
    [3]="Karoseria prawy ty?",
    [4]="Szyba przednia",
    [5]="Zderzak z przodu",
    [6]="Zderzak z ty?u"
}
local stanyPaneli={
    [0]="100%",
    [1]="66%",
    [2]="33%",
    [3]="0%",
}
local nazwyDrzwi={
    [0]="Maska",
    [1]="Baga?nik",
    [2]="Drzwi lewy prz?d",
    [3]="Drzwi prawy prz?d",
    [4]="Drzwi lewy ty?",
    [5]="Drzwi prawy ty?"
}

local nazwySwiatel={
    [0]="?wiat?o lewy prz?d",
    [1]="?wiat?o prawy prz?d",
    [2]="?wiat?o lewy ty?",
    [3]="?wiat?o prawy ty?"
}

local function fillVehicleData(v)
    guiGridListClear(w_m.grid)
    do
    if getElementHealth(v) ~= 1000 then
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1"Silnik",false,false)
        guiGridListSetItemData(w_m.grid,row1, -1)
        guiGridListSetItemText(w_m.grid,row2math.round(getElementHealth(v)/10).."%"falsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(math.abs(kosztNaprawySilnika(v))+2).."PLN"falsetrue)
    end
    
    end
    for i,panel in pairs(panele) do
    local stan getVehiclePanelState(vi)
    if stan ~= 0 then
        local koszt=kosztNaprawyElementu(v)*(getVehiclePanelState(v,i))/6
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1panel,false,false)
        guiGridListSetItemData(w_m.grid,row1i)
        local stan=stanyPaneli[getVehiclePanelState(v,i)]
        guiGridListSetItemText(w_m.grid,row2stanfalsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
    end
    end
    -- drzwi
    for i=0,do
        local stan=getVehicleDoorState(vi)
        if stan==or stan==or stan==4 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwyDrzwi[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+10)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        end
    end
    for i=0,do
        local stan=getVehicleLightState(vi)
        if stan==1 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwySwiatel[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+20)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        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
    if getElementData(source"braniekola"then return end
    
    --local fid=getElementData(source"snn_faction")
    --local lfid=getElementData(el"player:faction") or -1
    
    --if fid~=lfid then return end -- gracz nie jest pracownikiem]]--
    local pojazdy=getElementsWithinColShape(cs,"vehicle")

    if #pojazdy<1 then
        outputChatBox("Na stanowisku naprawczym nie ma ?adnego pojazdu.")
        return
    end
    if #pojazdy>1 then
        outputChatBox("Na stanowisku naprawczym jest zbyt du?o pojazd?w.")
        return
    end
    allCost setTimer(function(plr) 
        
    end10000el)
    fillVehicleData(pojazdy[1])
    guiSetEnabled(w_m.btn_naprawfalse)
    guiSetText(w_m.lbl_info,"")
    showCursor(truefalse)
    guiSetVisible(w_m.wndtrue)
    guiSetText(w_m.btn_naprawstring.format("Napraw (%s)"getVehicleName(pojazdy[1])) )
    naprawiany_pojazd=pojazdy[1]
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    showCursor(false)
    if allCost and isTimer(allCostthen killTimer(allCostend
end)

addEventHandler("onClientGUIClick"w_m.btn_zamknij, function()
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    if allCost and isTimer(allCostthen killTimer(allCostend
endfalse)

addEventHandler("onClientGUIClick"w_m.grid, function()
        guiSetText(w_m.lbl_info,"")
        selectedRowguiGridListGetSelectedItem w_m.grid) or -1
        if (selectedRow<0then
            guiSetEnabled(w_m.btn_napraw,false)
            return
        end
        
        local multirepair = {}
        local rows guiGridListGetSelectedItems(w_m.grid)
        for k,v in ipairs(rows) do
            if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
                table.insert(multirepair,v)
            end
        end
        
        totalkoszt 0
        
        for k,v in ipairs(multirepair) do
            local koszt guiGridListGetItemText(w_m.gridv.row3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            totalkoszt totalkoszt+koszt
        end
        
        guiSetText(w_m.lbl_infostring.format("W sumie do zap?aty: %sPLN",totalkoszt))
        guiSetEnabled(w_m.btn_naprawtrue)
end)


local napraw_lu=getTickCount()
    
addEventHandler("onClientGUIClick"w_m.btn_napraw, function()
    if getTickCount()-napraw_lu<1000 then return end

    if not naprawiany_pojazd or not isElement(naprawiany_pojazdthen return end

    selectedRowguiGridListGetSelectedItem w_m.grid) or -1
    if selectedRow<0 then return end
    local rows guiGridListGetSelectedItems(w_m.grid)
    
    local multirepair = {}
    --musimy sprawdzicczy gracz zaznaczyl KILKA rowowczy JEDEN    //karer - takie male udogodnienie
    for k,v in ipairs(rows) do
        if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
            table.insert(multirepair,v)
        end
    end
    
    guiSetText(w_m.lbl_info,"")
    if #multirepair == 1 then
        local koszt guiGridListGetItemText(w_m.gridselectedRow3)
        local koszt koszt:split("PLN")
        local koszt tonumber(koszt[1])
        if not koszt then return end
        if koszt<=0 then
        guiSetText(w_m.lbl_info,"Ta cz??? jest sprawna.")
        return
        end
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end
        local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
        napraw_lu=getTickCount()
        triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
       -- triggerServerEvent("takePlayerMoney"localPlayerkoszt)
    elseif #multirepair > 1 then
        for i,v in ipairs(multirepair) do
            local selectedRow v.row
            local koszt guiGridListGetItemText(w_m.gridselectedRow3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            if not koszt then return end
            if koszt<=0 then
                break
            end
            if koszt>getPlayerMoney(localPlayerthen
            guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            return
            end
            local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
            napraw_lu=getTickCount()
            triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        end
    else
        outputDebugScript("lss-naprawapojazdow> inna wartosc countRows, should't happen.")
    end
endfalse)

Teraz naprawia ale nie zabiera kasy :(

Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:53


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@author Karer <karer.programmer@gmail.com>
@author RacheT <rachet@pylife.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@package MTA-XyzzyRP
@link https://github.com/lpiob/MTA-XyzzyRP GitHub
]]--

local screenWscreenH guiGetScreenSize()

local w_m={}



--utils
function math.round(numberdecimalsmethod)
        decimals decimals or 0
        local factor 10 decimals
        if (method == "ceil" or method == "floor"then return math[method](number factor) / factor
        else return tonumber(("%."..decimals.."f"):format(number)) end
end

function string:split(sep)
    local sepfields sep or ":", {}
    local pattern string.format("([^%s]+)"sep)
    self:gsub(pattern, function(cfields[#fields+1] = c end)
    return fields
end





w_m.wnd guiCreateStaticImage(0.190.190.720.55"panel.png"true)
--w_m.wnd guiCreateWindow(0.1469,0.1667,0.7344,0.675,"Panel mechanika",true)
w_m.btn_napraw guiCreateButton(0.0277,0.8395,0.3064,0.1327,"Napraw",true,w_m.wnd)

w_m.btn_zamknij guiCreateButton(0.3427,0.8395,0.3064,0.1327,"Zamknij",true,w_m.wnd)
w_m.lbl_info guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
w_m.lbl_costinfo guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
guiLabelSetHorizontalAlign(w_m.lbl_info"center"true)
guiLabelSetVerticalAlign(w_m.lbl_info"center")


w_m.grid guiCreateGridList(0.0298,0.0895,0.9383,0.7191,true,w_m.wnd)
guiGridListSetSelectionMode(w_m.grid,1)
guiGridListSetSortingEnabled(w_m.grid,false)
w_m.grid_nazwa guiGridListAddColumn w_m.grid"Nazwa cz??ci"0.3 )
w_m.grid_stan guiGridListAddColumn w_m.grid"Stan cz??ci"0.3 )
w_m.grid_koszt guiGridListAddColumn w_m.grid"Koszt naprawy"0.3 )
guiSetVisible(w_m.wnd,false)

local naprawiany_pojazd=nil

local function kosztNaprawySilnika(v)
    local vhp=1000-getElementHealth(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return vhp/1000*cenapojazdu*przebieg*0.002 -- it's that simple
end

local function kosztNaprawyElementu(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return cenapojazdu*przebieg*0.002 -- it's that simple
end

local panele={
    [0]="Karoseria lewy prz?d",
    [1]="Karoseria prawy prz?d",
    [2]="Karoseria lewy ty?",
    [3]="Karoseria prawy ty?",
    [4]="Szyba przednia",
    [5]="Zderzak z przodu",
    [6]="Zderzak z ty?u"
}
local stanyPaneli={
    [0]="100%",
    [1]="66%",
    [2]="33%",
    [3]="0%",
}
local nazwyDrzwi={
    [0]="Maska",
    [1]="Baga?nik",
    [2]="Drzwi lewy prz?d",
    [3]="Drzwi prawy prz?d",
    [4]="Drzwi lewy ty?",
    [5]="Drzwi prawy ty?"
}

local nazwySwiatel={
    [0]="?wiat?o lewy prz?d",
    [1]="?wiat?o prawy prz?d",
    [2]="?wiat?o lewy ty?",
    [3]="?wiat?o prawy ty?"
}

local function fillVehicleData(v)
    guiGridListClear(w_m.grid)
    do
    if getElementHealth(v) ~= 1000 then
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1"Silnik",false,false)
        guiGridListSetItemData(w_m.grid,row1, -1)
        guiGridListSetItemText(w_m.grid,row2math.round(getElementHealth(v)/10).."%"falsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(math.abs(kosztNaprawySilnika(v))+2).."PLN"falsetrue)
    end
    
    end
    for i,panel in pairs(panele) do
    local stan getVehiclePanelState(vi)
    if stan ~= 0 then
        local koszt=kosztNaprawyElementu(v)*(getVehiclePanelState(v,i))/6
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1panel,false,false)
        guiGridListSetItemData(w_m.grid,row1i)
        local stan=stanyPaneli[getVehiclePanelState(v,i)]
        guiGridListSetItemText(w_m.grid,row2stanfalsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
    end
    end
    -- drzwi
    for i=0,do
        local stan=getVehicleDoorState(vi)
        if stan==or stan==or stan==4 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwyDrzwi[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+10)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        end
    end
    for i=0,do
        local stan=getVehicleLightState(vi)
        if stan==1 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwySwiatel[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+20)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        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
    if getElementData(source"braniekola"then return end
    
    --local fid=getElementData(source"snn_faction")
    --local lfid=getElementData(el"player:faction") or -1
    
    --if fid~=lfid then return end -- gracz nie jest pracownikiem]]--
    local pojazdy=getElementsWithinColShape(cs,"vehicle")

    if #pojazdy<1 then
        outputChatBox("Na stanowisku naprawczym nie ma ?adnego pojazdu.")
        return
    end
    if #pojazdy>1 then
        outputChatBox("Na stanowisku naprawczym jest zbyt du?o pojazd?w.")
        return
    end
    allCost setTimer(function(plr) 
        
    end10000el)
    fillVehicleData(pojazdy[1])
    guiSetEnabled(w_m.btn_naprawfalse)
    guiSetText(w_m.lbl_info,"")
    showCursor(truefalse)
    guiSetVisible(w_m.wndtrue)
    guiSetText(w_m.btn_naprawstring.format("Napraw (%s)"getVehicleName(pojazdy[1])) )
    naprawiany_pojazd=pojazdy[1]
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    showCursor(false)
    if allCost and isTimer(allCostthen killTimer(allCostend
end)

addEventHandler("onClientGUIClick"w_m.btn_zamknij, function()
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    if allCost and isTimer(allCostthen killTimer(allCostend
endfalse)

addEventHandler("onClientGUIClick"w_m.grid, function()
        guiSetText(w_m.lbl_info,"")
        selectedRowguiGridListGetSelectedItem w_m.grid) or -1
        if (selectedRow<0then
            guiSetEnabled(w_m.btn_napraw,false)
            return
        end
        
        local multirepair = {}
        local rows guiGridListGetSelectedItems(w_m.grid)
        for k,v in ipairs(rows) do
            if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
                table.insert(multirepair,v)
            end
        end
        
        totalkoszt 0
        
        for k,v in ipairs(multirepair) do
            local koszt guiGridListGetItemText(w_m.gridv.row3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            totalkoszt totalkoszt+koszt
        end
        
        guiSetText(w_m.lbl_infostring.format("W sumie do zap?aty: %sPLN",totalkoszt))
        guiSetEnabled(w_m.btn_naprawtrue)
end)


local napraw_lu=getTickCount()
    
addEventHandler("onClientGUIClick"w_m.btn_napraw, function()
    if getTickCount()-napraw_lu<1000 then return end

    if not naprawiany_pojazd or not isElement(naprawiany_pojazdthen return end

    selectedRowguiGridListGetSelectedItem w_m.grid) or -1
    if selectedRow<0 then return end
    local rows guiGridListGetSelectedItems(w_m.grid)
    
    local multirepair = {}
    --musimy sprawdzicczy gracz zaznaczyl KILKA rowowczy JEDEN    //karer - takie male udogodnienie
    for k,v in ipairs(rows) do
        if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
            table.insert(multirepair,v)
        end
    end
    
    guiSetText(w_m.lbl_info,"")
    if #multirepair == 1 then
        local koszt guiGridListGetItemText(w_m.gridselectedRow3)
        local koszt koszt:split("PLN")
        local koszt tonumber(koszt[1])
        if not koszt then return end
        if koszt<=0 then
        guiSetText(w_m.lbl_info,"Ta cz??? jest sprawna.")
        return
        end
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end
        local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
        napraw_lu=getTickCount()
        triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
       -- triggerServerEvent("takePlayerMoney"localPlayerkoszt)
       takePlayerMoney(localPlayertonumber(koszt))
    elseif #multirepair > 1 then
        for i,v in ipairs(multirepair) do
            local selectedRow v.row
            local koszt guiGridListGetItemText(w_m.gridselectedRow3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            if not koszt then return end
            if koszt<=0 then
                break
            end
            if koszt>getPlayerMoney(localPlayerthen
            guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            return
            end
            local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
            napraw_lu=getTickCount()
            triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        end
    else
        outputDebugScript("lss-naprawapojazdow> inna wartosc countRows, should't happen.")
    end
endfalse)


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
STOPseba
Wysłany: 2017-02-04, 22:02


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

"marcin778" napisał/a:

--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@author Karer <karer.programmer@gmail.com>
@author RacheT <rachet@pylife.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@package MTA-XyzzyRP
@link https://github.com/lpiob/MTA-XyzzyRP GitHub
]]--

local screenWscreenH guiGetScreenSize()

local w_m={}



--utils
function math.round(numberdecimalsmethod)
        decimals decimals or 0
        local factor 10 decimals
        if (method == "ceil" or method == "floor"then return math[method](number factor) / factor
        else return tonumber(("%."..decimals.."f"):format(number)) end
end

function string:split(sep)
    local sepfields sep or ":", {}
    local pattern string.format("([^%s]+)"sep)
    self:gsub(pattern, function(cfields[#fields+1] = c end)
    return fields
end





w_m.wnd guiCreateStaticImage(0.190.190.720.55"panel.png"true)
--w_m.wnd guiCreateWindow(0.1469,0.1667,0.7344,0.675,"Panel mechanika",true)
w_m.btn_napraw guiCreateButton(0.0277,0.8395,0.3064,0.1327,"Napraw",true,w_m.wnd)

w_m.btn_zamknij guiCreateButton(0.3427,0.8395,0.3064,0.1327,"Zamknij",true,w_m.wnd)
w_m.lbl_info guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
w_m.lbl_costinfo guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
guiLabelSetHorizontalAlign(w_m.lbl_info"center"true)
guiLabelSetVerticalAlign(w_m.lbl_info"center")


w_m.grid guiCreateGridList(0.0298,0.0895,0.9383,0.7191,true,w_m.wnd)
guiGridListSetSelectionMode(w_m.grid,1)
guiGridListSetSortingEnabled(w_m.grid,false)
w_m.grid_nazwa guiGridListAddColumn w_m.grid"Nazwa cz??ci"0.3 )
w_m.grid_stan guiGridListAddColumn w_m.grid"Stan cz??ci"0.3 )
w_m.grid_koszt guiGridListAddColumn w_m.grid"Koszt naprawy"0.3 )
guiSetVisible(w_m.wnd,false)

local naprawiany_pojazd=nil

local function kosztNaprawySilnika(v)
    local vhp=1000-getElementHealth(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return vhp/1000*cenapojazdu*przebieg*0.002 -- it's that simple
end

local function kosztNaprawyElementu(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return cenapojazdu*przebieg*0.002 -- it's that simple
end

local panele={
    [0]="Karoseria lewy prz?d",
    [1]="Karoseria prawy prz?d",
    [2]="Karoseria lewy ty?",
    [3]="Karoseria prawy ty?",
    [4]="Szyba przednia",
    [5]="Zderzak z przodu",
    [6]="Zderzak z ty?u"
}
local stanyPaneli={
    [0]="100%",
    [1]="66%",
    [2]="33%",
    [3]="0%",
}
local nazwyDrzwi={
    [0]="Maska",
    [1]="Baga?nik",
    [2]="Drzwi lewy prz?d",
    [3]="Drzwi prawy prz?d",
    [4]="Drzwi lewy ty?",
    [5]="Drzwi prawy ty?"
}

local nazwySwiatel={
    [0]="?wiat?o lewy prz?d",
    [1]="?wiat?o prawy prz?d",
    [2]="?wiat?o lewy ty?",
    [3]="?wiat?o prawy ty?"
}

local function fillVehicleData(v)
    guiGridListClear(w_m.grid)
    do
    if getElementHealth(v) ~= 1000 then
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1"Silnik",false,false)
        guiGridListSetItemData(w_m.grid,row1, -1)
        guiGridListSetItemText(w_m.grid,row2math.round(getElementHealth(v)/10).."%"falsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(math.abs(kosztNaprawySilnika(v))+2).."PLN"falsetrue)
    end
    
    end
    for i,panel in pairs(panele) do
    local stan getVehiclePanelState(vi)
    if stan ~= 0 then
        local koszt=kosztNaprawyElementu(v)*(getVehiclePanelState(v,i))/6
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1panel,false,false)
        guiGridListSetItemData(w_m.grid,row1i)
        local stan=stanyPaneli[getVehiclePanelState(v,i)]
        guiGridListSetItemText(w_m.grid,row2stanfalsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
    end
    end
    -- drzwi
    for i=0,do
        local stan=getVehicleDoorState(vi)
        if stan==or stan==or stan==4 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwyDrzwi[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+10)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        end
    end
    for i=0,do
        local stan=getVehicleLightState(vi)
        if stan==1 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwySwiatel[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+20)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        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
    if getElementData(source"braniekola"then return end
    
    --local fid=getElementData(source"snn_faction")
    --local lfid=getElementData(el"player:faction") or -1
    
    --if fid~=lfid then return end -- gracz nie jest pracownikiem]]--
    local pojazdy=getElementsWithinColShape(cs,"vehicle")

    if #pojazdy<1 then
        outputChatBox("Na stanowisku naprawczym nie ma ?adnego pojazdu.")
        return
    end
    if #pojazdy>1 then
        outputChatBox("Na stanowisku naprawczym jest zbyt du?o pojazd?w.")
        return
    end
    allCost setTimer(function(plr) 
        
    end10000el)
    fillVehicleData(pojazdy[1])
    guiSetEnabled(w_m.btn_naprawfalse)
    guiSetText(w_m.lbl_info,"")
    showCursor(truefalse)
    guiSetVisible(w_m.wndtrue)
    guiSetText(w_m.btn_naprawstring.format("Napraw (%s)"getVehicleName(pojazdy[1])) )
    naprawiany_pojazd=pojazdy[1]
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    showCursor(false)
    if allCost and isTimer(allCostthen killTimer(allCostend
end)

addEventHandler("onClientGUIClick"w_m.btn_zamknij, function()
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    if allCost and isTimer(allCostthen killTimer(allCostend
endfalse)

addEventHandler("onClientGUIClick"w_m.grid, function()
        guiSetText(w_m.lbl_info,"")
        selectedRowguiGridListGetSelectedItem w_m.grid) or -1
        if (selectedRow<0then
            guiSetEnabled(w_m.btn_napraw,false)
            return
        end
        
        local multirepair = {}
        local rows guiGridListGetSelectedItems(w_m.grid)
        for k,v in ipairs(rows) do
            if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
                table.insert(multirepair,v)
            end
        end
        
        totalkoszt 0
        
        for k,v in ipairs(multirepair) do
            local koszt guiGridListGetItemText(w_m.gridv.row3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            totalkoszt totalkoszt+koszt
        end
        
        guiSetText(w_m.lbl_infostring.format("W sumie do zap?aty: %sPLN",totalkoszt))
        guiSetEnabled(w_m.btn_naprawtrue)
end)


local napraw_lu=getTickCount()
    
addEventHandler("onClientGUIClick"w_m.btn_napraw, function()
    if getTickCount()-napraw_lu<1000 then return end

    if not naprawiany_pojazd or not isElement(naprawiany_pojazdthen return end

    selectedRowguiGridListGetSelectedItem w_m.grid) or -1
    if selectedRow<0 then return end
    local rows guiGridListGetSelectedItems(w_m.grid)
    
    local multirepair = {}
    --musimy sprawdzicczy gracz zaznaczyl KILKA rowowczy JEDEN    //karer - takie male udogodnienie
    for k,v in ipairs(rows) do
        if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
            table.insert(multirepair,v)
        end
    end
    
    guiSetText(w_m.lbl_info,"")
    if #multirepair == 1 then
        local koszt guiGridListGetItemText(w_m.gridselectedRow3)
        local koszt koszt:split("PLN")
        local koszt tonumber(koszt[1])
        if not koszt then return end
        if koszt<=0 then
        guiSetText(w_m.lbl_info,"Ta cz??? jest sprawna.")
        return
        end
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end
        local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
        napraw_lu=getTickCount()
        triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
       -- triggerServerEvent("takePlayerMoney"localPlayerkoszt)
       takePlayerMoney(localPlayertonumber(koszt))
    elseif #multirepair > 1 then
        for i,v in ipairs(multirepair) do
            local selectedRow v.row
            local koszt guiGridListGetItemText(w_m.gridselectedRow3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            if not koszt then return end
            if koszt<=0 then
                break
            end
            if koszt>getPlayerMoney(localPlayerthen
            guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            return
            end
            local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
            napraw_lu=getTickCount()
            triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        end
    else
        outputDebugScript("lss-naprawapojazdow> inna wartosc countRows, should't happen.")
    end
endfalse)

Dalej to samo.

Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 22:09


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

STOPseba, Zabiera 2x?

Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
STOPseba
Wysłany: 2017-02-04, 22:11


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

"marcin778" napisał/a:

STOPseba, Zabiera 2x?

Nie zabiera wcale :(

Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 22:18


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

To s? ca?e kody?


client

--[[
@author Lukasz Biegaj <wielebny@bestplay.pl>
@author Karer <karer.programmer@gmail.com>
@author RacheT <rachet@pylife.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@package MTA-XyzzyRP
@link https://github.com/lpiob/MTA-XyzzyRP GitHub
]]--

local screenWscreenH guiGetScreenSize()

local w_m={}



--utils
function math.round(numberdecimalsmethod)
        decimals decimals or 0
        local factor 10 decimals
        if (method == "ceil" or method == "floor"then return math[method](number factor) / factor
        else return tonumber(("%."..decimals.."f"):format(number)) end
end

function string:split(sep)
    local sepfields sep or ":", {}
    local pattern string.format("([^%s]+)"sep)
    self:gsub(pattern, function(cfields[#fields+1] = c end)
    return fields
end





w_m.wnd guiCreateStaticImage(0.190.190.720.55"panel.png"true)
--w_m.wnd guiCreateWindow(0.1469,0.1667,0.7344,0.675,"Panel mechanika",true)
w_m.btn_napraw guiCreateButton(0.0277,0.8395,0.3064,0.1327,"Napraw",true,w_m.wnd)

w_m.btn_zamknij guiCreateButton(0.3427,0.8395,0.3064,0.1327,"Zamknij",true,w_m.wnd)
w_m.lbl_info guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
w_m.lbl_costinfo guiCreateLabel(0.60.83950.350.1327""truew_m.wnd)
guiLabelSetHorizontalAlign(w_m.lbl_info"center"true)
guiLabelSetVerticalAlign(w_m.lbl_info"center")


w_m.grid guiCreateGridList(0.0298,0.0895,0.9383,0.7191,true,w_m.wnd)
guiGridListSetSelectionMode(w_m.grid,1)
guiGridListSetSortingEnabled(w_m.grid,false)
w_m.grid_nazwa guiGridListAddColumn w_m.grid"Nazwa cz??ci"0.3 )
w_m.grid_stan guiGridListAddColumn w_m.grid"Stan cz??ci"0.3 )
w_m.grid_koszt guiGridListAddColumn w_m.grid"Koszt naprawy"0.3 )
guiSetVisible(w_m.wnd,false)

local naprawiany_pojazd=nil

local function kosztNaprawySilnika(v)
    local vhp=1000-getElementHealth(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return vhp/1000*cenapojazdu*przebieg*0.002 -- it's that simple
end

local function kosztNaprawyElementu(v)
    local cenapojazdu=getVehicleHandling(v).monetary or 10000
    local przebieg=(10000-math.min(getElementData(v,"vehicle:mileage") or 5000,9999))/10000
    return cenapojazdu*przebieg*0.002 -- it's that simple
end

local panele={
    [0]="Karoseria lewy prz?d",
    [1]="Karoseria prawy prz?d",
    [2]="Karoseria lewy ty?",
    [3]="Karoseria prawy ty?",
    [4]="Szyba przednia",
    [5]="Zderzak z przodu",
    [6]="Zderzak z ty?u"
}
local stanyPaneli={
    [0]="100%",
    [1]="66%",
    [2]="33%",
    [3]="0%",
}
local nazwyDrzwi={
    [0]="Maska",
    [1]="Baga?nik",
    [2]="Drzwi lewy prz?d",
    [3]="Drzwi prawy prz?d",
    [4]="Drzwi lewy ty?",
    [5]="Drzwi prawy ty?"
}

local nazwySwiatel={
    [0]="?wiat?o lewy prz?d",
    [1]="?wiat?o prawy prz?d",
    [2]="?wiat?o lewy ty?",
    [3]="?wiat?o prawy ty?"
}

local function fillVehicleData(v)
    guiGridListClear(w_m.grid)
    do
    if getElementHealth(v) ~= 1000 then
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1"Silnik",false,false)
        guiGridListSetItemData(w_m.grid,row1, -1)
        guiGridListSetItemText(w_m.grid,row2math.round(getElementHealth(v)/10).."%"falsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(math.abs(kosztNaprawySilnika(v))+2).."PLN"falsetrue)
    end
    
    end
    for i,panel in pairs(panele) do
    local stan getVehiclePanelState(vi)
    if stan ~= 0 then
        local koszt=kosztNaprawyElementu(v)*(getVehiclePanelState(v,i))/6
        local row=guiGridListAddRow(w_m.grid)
        guiGridListSetItemText(w_m.grid,row1panel,false,false)
        guiGridListSetItemData(w_m.grid,row1i)
        local stan=stanyPaneli[getVehiclePanelState(v,i)]
        guiGridListSetItemText(w_m.grid,row2stanfalsetrue)
        guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
    end
    end
    -- drzwi
    for i=0,do
        local stan=getVehicleDoorState(vi)
        if stan==or stan==or stan==4 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwyDrzwi[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+10)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        end
    end
    for i=0,do
        local stan=getVehicleLightState(vi)
        if stan==1 then
            local koszt=kosztNaprawyElementu(v)*2/6
            local row=guiGridListAddRow(w_m.grid)
            guiGridListSetItemText(w_m.grid,row1nazwySwiatel[i],false,false)
            guiGridListSetItemData(w_m.grid,row1i+20)
            guiGridListSetItemText(w_m.grid,row2"0%"falsetrue)
            guiGridListSetItemText(w_m.grid,row3math.round(koszt+2).."PLN"falsetrue)
        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
    if getElementData(source"braniekola"then return end
    
    --local fid=getElementData(source"snn_faction")
    --local lfid=getElementData(el"player:faction") or -1
    
    --if fid~=lfid then return end -- gracz nie jest pracownikiem]]--
    local pojazdy=getElementsWithinColShape(cs,"vehicle")

    if #pojazdy<1 then
        outputChatBox("Na stanowisku naprawczym nie ma ?adnego pojazdu.")
        return
    end
    if #pojazdy>1 then
        outputChatBox("Na stanowisku naprawczym jest zbyt du?o pojazd?w.")
        return
    end
    allCost setTimer(function(plr) 
        
    end10000el)
    fillVehicleData(pojazdy[1])
    guiSetEnabled(w_m.btn_naprawfalse)
    guiSetText(w_m.lbl_info,"")
    showCursor(truefalse)
    guiSetVisible(w_m.wndtrue)
    guiSetText(w_m.btn_naprawstring.format("Napraw (%s)"getVehicleName(pojazdy[1])) )
    naprawiany_pojazd=pojazdy[1]
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    showCursor(false)
    if allCost and isTimer(allCostthen killTimer(allCostend
end)

addEventHandler("onClientGUIClick"w_m.btn_zamknij, function()
    guiSetVisible(w_m.wndfalse)
    naprawiany_pojazd=nil
    if allCost and isTimer(allCostthen killTimer(allCostend
endfalse)

addEventHandler("onClientGUIClick"w_m.grid, function()
        guiSetText(w_m.lbl_info,"")
        selectedRowguiGridListGetSelectedItem w_m.grid) or -1
        if (selectedRow<0then
            guiSetEnabled(w_m.btn_napraw,false)
            return
        end
        
        local multirepair = {}
        local rows guiGridListGetSelectedItems(w_m.grid)
        for k,v in ipairs(rows) do
            if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
                table.insert(multirepair,v)
            end
        end
        
        totalkoszt 0
        
        for k,v in ipairs(multirepair) do
            local koszt guiGridListGetItemText(w_m.gridv.row3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            totalkoszt totalkoszt+koszt
        end
        
        guiSetText(w_m.lbl_infostring.format("W sumie do zap?aty: %sPLN",totalkoszt))
        guiSetEnabled(w_m.btn_naprawtrue)
end)


local napraw_lu=getTickCount()
    
addEventHandler("onClientGUIClick"w_m.btn_napraw, function()
    if getTickCount()-napraw_lu<1000 then return end

    if not naprawiany_pojazd or not isElement(naprawiany_pojazdthen return end

    selectedRowguiGridListGetSelectedItem w_m.grid) or -1
    if selectedRow<0 then return end
    local rows guiGridListGetSelectedItems(w_m.grid)
    
    local multirepair = {}
    --musimy sprawdzicczy gracz zaznaczyl KILKA rowowczy JEDEN    //karer - takie male udogodnienie
    for k,v in ipairs(rows) do
        if (k/== math.round(k/3)) then --kazde 3 wyniki sa takie samepomijamy je
            table.insert(multirepair,v)
        end
    end
    
    guiSetText(w_m.lbl_info,"")
    if #multirepair == 1 then
        local koszt guiGridListGetItemText(w_m.gridselectedRow3)
        local koszt koszt:split("PLN")
        local koszt tonumber(koszt[1])
        if not koszt then return end
        if koszt<=0 then
        guiSetText(w_m.lbl_info,"Ta cz??? jest sprawna.")
        return
        end
        -- if koszt>getPlayerMoney(localPlayerthen
        -- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
        -- return
        -- end
        local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
        napraw_lu=getTickCount()
        triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        triggerServerEvent("pobierzKase"localPlayerkoszt)
     --  takePlayerMoney(localPlayertonumber(koszt))
    elseif #multirepair > 1 then
        for i,v in ipairs(multirepair) do
            local selectedRow v.row
            local koszt guiGridListGetItemText(w_m.gridselectedRow3)
            local koszt koszt:split("PLN")
            local koszt tonumber(koszt[1])
            if not koszt then return end
            if koszt<=0 then
                break
            end
            if koszt>getPlayerMoney(localPlayerthen
            guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
            return
            end
            local czesc=guiGridListGetItemData(w_m.gridselectedRow1) -- numer panelu lub -1==silnik
            napraw_lu=getTickCount()
            triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
        end
    else
        outputDebugScript("lss-naprawapojazdow> inna wartosc countRows, should't happen.")
    end
endfalse)



server


addEvent("pobierzKase",true)
addEventHandler("pobierzKase",root,function(price)
if getPlayerMoney(client) >= price then
takePlayerMoney(clienttonumber(price))
end
end)

local stanowiskaNaprawcze = {
    stanowiskoDoherty={
        mpos={1106.54602,1760.97449,10.82031}, -- marker
        cpos={1094.73731757.045510.820313-111.756.755}, -- cuboid
        --faction_id=1, -- (idfrakcja kt?ra b?dzie mia?a dost?p
        text="Naprawa pojazdu"
    
    },
    stanowiskoLV={
        mpos={1107.12097,1750.85950,10.82031}, -- marker
        cpos={1095.2721747.289610.820313-19.56.255}, -- cuboid
        --faction_id=1, -- (idfrakcja kt?ra b?dzie mia?a dost?p
        text="Naprawa pojazdu"
    
    },
}


for i,v in pairs(stanowiskaNaprawcze) do
    v.cuboid=createColCuboid(unpack(v.cpos))
    v.marker=createMarker(v.mpos[1], v.mpos[2], v.mpos[3]-0.90"cylinder"1.200255100)
    --setElementData(v.marker,"snn_faction",v.faction_id)
    setElementData(v.marker,"snn_cs",v.cuboid)

    t=createElement("text")
    setElementData(t,"name",v.text)
    setElementPosition(t,v.mpos[1], v.mpos[2], v.mpos[3])
end


--   triggerServerEvent("naprawaElementu"resourceRootnaprawiany_pojazdczesckoszt)
addEvent("naprawaElementu"true)
addEventHandler("naprawaElementu"resourceRoot, function(pojazdczesckoszt)
  outputDebugString("Naprawa elementu " .. czesc .. " za " .. koszt)
  if koszt>getPlayerMoney(clientthen
    return
  end

  if (czesc==-1then
--    setElementHealth(pojazd1000)

    local vps={}
    local vds={}
    local vls={}

    for i=0,do          vps[i]=getVehiclePanelState(pojazd,i)     end
    for i=0,do          vds[i]=getVehicleDoorState(pojazd,iend
    for i=0,do          vls[i]=getVehicleLightState(pojazd,iend

    fixVehicle(pojazd)

    for i=0,do      setVehiclePanelState(pojazdivps[i])    end
    for i=0,do      setVehicleDoorState(pojazdivds[i])    end
    for i=0,do      setVehicleLightState(pojazdivls[i])    end

    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  elseif czesc>=and czesc<=6 then
    setVehiclePanelState(pojazdczesc0)
    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  elseif czesc>=10 and czesc<20 then
    local drzwi=czesc-10
    setVehicleDoorState(pojazddrzwi0)
    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  elseif czesc>=20 then
    local swiatlo=czesc-20
    setVehicleLightState(pojazdswiatlo0)
    triggerClientEvent(client"refreshVehicleData"resourceRootpojazd)
  end
end)


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
STOPseba
Wysłany: 2017-02-04, 22:34


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

Tak i jeszcze to od (ogrpg-prace-settings)
S:
-- Kod s?u??cy od dawania wynagrodzenia
addEvent("givePlayerMoney"true)
addEventHandler("givePlayerMoney"root, function(value2)
    -- nie zalogowana osoba a fuj
    if not getElementData(client,"player:logged"then return end
    local rnd={math.random(1,30),math.random(1,2)}
    if rnd[1] == or rnd[1] == 15 or rnd[1] == 26 then
        local rep=getElementData(client,"player:reputation") or 0
        local xd=rep+rnd[2]
        setElementData(client,"player:reputation",xd)
        triggerClientEvent(client"reputation:show"resourceRootrnd)
    end
end)

addEvent("takePlayerMoney"true)
addEventHandler("takePlayerMoney"root, function(how)
    if not getElementData(source,"player:logged"then return end
    if not tonumber(howthen return end
    takePlayerMoney(source,how);
end)

-- Kod s?u??cy od usuwania danego pojazdu
addEvent("destroyVehicle"true)
addEventHandler("destroyVehicle"root, function(veh)
    if not veh then return end
    destroyElement(veh)
    if obiekt[vehthen 
        destroyElement(obiekt[veh])
    end
end)

-- Kod s?u??cy od usuwania obiekt?w z pojazdu
addEvent("removeObject"true)
addEventHandler("removeObject"root, function(veh,code)
    if obiekt[vehthen
        destroyElement(obiekt[veh])
    end
end)

-- Kod s?u?acy do dodawania obiekt?do prac
addEvent("addObject"true)
addEventHandler("addObject"root, function(veh,code)
    if code == "kamieniolom" then
        obiekt[veh]=createObject(3929000)
        setObjectScale(obiekt[veh], 3.5)
        attachElements(obiekt[veh], veh0, -2190)
    end
end)


addEventHandler "onPlayerVehicleEnter"root, function(v,s,j)
if getElementData(v,"vehicle:fuel") == false then
setElementData(v,"vehicle:fuel",100)
end
end)


Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 22:37


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

STOPseba, Przetestowa?e? te powy?sze kody? Co poda?em

Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
STOPseba
Wysłany: 2017-02-04, 22:43


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

"marcin778" napisał/a:

STOPseba, Przetestowa?e? te powy?sze kody? Co poda?em

Tak przetestowa?em Dzia?a Dzi?ki Zostawiam dla ciebie Respekt oraz browarka
@Lock

Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Tagi: naprawa :: pojazdu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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