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

Wysłany: 2018-03-31, 14:41


fapster

Pseudol






Wiek: 22
Na forum: 4066 dni
Posty: 67
Nick w MP: MopSKY

Piwa: 272

Respekt: 50

posiadam skrypt dzieki ktoremu mozna montowac swiatla, lecz gdy montuje to zabiera 3x wiecej pieniedzy niz podane w skrypcie, prosi?bym serdecznie o pomoc :/

Kod:

local isVehicles=nil
local isColored={
-- Nazwa koloru, {r,g,b koloru}, cena
{"Light White", {255,255,255}, 1500},
{"Xenon Red", {255,0,0}, 10000},
{"Xenon Blue", {0,45,110}, 8000},
{"Xenon Yellow", {255,255,0}, 6000},
{"Xenon Green", {0,255,0}, 8500},
{"Xenon Blue x2", {48,213,200}, 8500},
{"Xenon Pink", {255,52,225}, 10000},
}

local wn={}
wn.window=guiCreateWindow(0.18, 0.19, 0.64, 0.62, "", true)
wn.grid=guiCreateGridList(0.03, 0.07, 0.62, 0.89, true, wn.window)
guiGridListAddColumn(wn.grid, "Kolor", 0.5)
guiGridListAddColumn(wn.grid, "Koszt", 0.5)
wn.btn_submit=guiCreateButton(0.67, 0.08, 0.31, 0.33, "Zamontuj", true, wn.window)
wn.btn_close=guiCreateButton(0.67, 0.63, 0.31, 0.33, "Zamknij", true, wn.window)
guiSetVisible(wn.window, false)

addEventHandler("onClientMarkerHit", resourceRoot, function(el,md)
if not md or el~=localPlayer then return end
local cs=getElementData(source, "marker:cuboid")
if not cs then return end
local job=getElementData(source,"marker:duty")
local ljob=getElementData(el,"player:duty")
if job ~= ljob then
outputChatBox("* Nie jeste? zatrudniony jako tuner.", 255, 0, 0)
return
end
local vehicles=getElementsWithinColShape(cs,"vehicle")
if #vehicles < 1 then
outputChatBox("* Na stanowisku monta?u nie ma ?adnego pojazdu.", 255, 0, 0)
return
end
if #vehicles > 1 then
outputChatBox("* Na stanowisku monta?u jest zbyt du?o pojazd?w.", 255, 0, 0)
return
end
if getElementHealth(vehicles[1]) < 900 then
outputChatBox("* Pojazd jest zbyt uszkodzony aby zamontowa? ?wiat?a.", 255, 0, 0)
return
end
isVehicles=vehicles[1]
showCursor(true,false)
guiGridListClear(wn.grid)
guiSetVisible(wn.window, true)
for i,v in ipairs(isColored) do
local row=guiGridListAddRow(wn.grid)
guiGridListSetItemText(wn.grid, row, 1, v[1], false, false)
guiGridListSetItemData(wn.grid, row, 1, v[2], false, false)
guiGridListSetItemColor(wn.grid, row, 1, v[2][1], v[2][2], v[2][3])
guiGridListSetItemData(wn.grid, row, 1, v[2], false, false)
guiGridListSetItemText(wn.grid, row, 2, v[3].." Eur", false, false)
guiGridListSetItemData(wn.grid, row, 2, v[3], false, false)
end
end)

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

addEventHandler("onClientGUIClick", wn.btn_submit, function()
if not isVehicles then return end
selectedRow=guiGridListGetSelectedItem(wn.grid) or -1
if selectedRow < 0 then return end
local color=guiGridListGetItemData(wn.grid, selectedRow, 1)
local cost=tonumber(guiGridListGetItemData(wn.grid, selectedRow, 2))
if not cost then return end
if cost > getPlayerMoney(localPlayer) then
outputChatBox("* Nie posiadasz tyle got?wki.", 255, 0, 0)
return
end
triggerServerEvent("takePlayerMoney", localPlayer, cost)
triggerServerEvent("montazElementu", root, isVehicles, "swiatla", {color[1], color[2], color[3]}, cost)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-31, 14:43


Ciastuuś

Truck soon...






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

Piwa: 4297

Respekt: 640
Respekt: 640Respekt: 640

Umie?? kod w znacznikach [lua] [ /lua]

Poka? kod ze strony clienta gdy? tam znajduje si? dalszy ci?g kodu od cen monta?u

Podpis
Truck soon...
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-31, 14:52


fapster

Pseudol






Wiek: 22
Na forum: 4066 dni
Posty: 67
Nick w MP: MopSKY

Piwa: 272

Respekt: 50

to jest od clienta

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-31, 14:53


Ciastuuś

Truck soon...






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

Piwa: 4297

Respekt: 640
Respekt: 640Respekt: 640

Pomyli?o mi si?. Mia?o by? od servera.

Podpis
Truck soon...
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-31, 14:54


fapster

Pseudol






Wiek: 22
Na forum: 4066 dni
Posty: 67
Nick w MP: MopSKY

Piwa: 272

Respekt: 50

local stanowiskaSwiatla = {
    stanowiskoDoherty={
        mpos={2143.47, -2194.6713.55-0.3}, -- marker
        cpos={2136.86, -2186.0613.553.20}, -- cuboid
        faction_id=tuner-ls, -- (idfrakcja kt?ra b?dzie mia?a dost?p
        text="Monta? ?wiate?"
    },
}

for i,v in pairs(stanowiskaSwiatla) do
    v.cuboid=createColCuboid(unpack(v.cpos))
    v.marker=createMarker(v.mpos[1], v.mpos[2], v.mpos[3]-0.60"cylinder"1.200255100)
    setElementData(v.marker,"sn_faction",v.faction_id)
    setElementData(v.marker,"sn_cs",v.cuboid)

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


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-31, 15:00


Ciastuuś

Truck soon...






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

Piwa: 4297

Respekt: 640
Respekt: 640Respekt: 640

W ogrpg-naprawapojazdow\c_naprawa.lua masz ustawienia dotycz?ce tych koszt?w.

if getElementData(localPlayer"player:duty") == "PSP" or getElementData(localPlayer"player:duty") == "SAPD" or getElementData(localPlayer"player:duty") == "SAMA" or getElementData(localPlayer"player:duty") == "SARH" then
    triggerServerEvent("takePlayerMoney"localPlayer0)
    outputChatBox('* Naprawiles wszystkie elementy w pojezdzie.')
    playSoundFrontEnd 46 )
    triggerServerEvent("montazElementu"rootisVehicles"naprawa""all"0)
    else
    triggerServerEvent("takePlayerMoney"localPlayer200)
    outputChatBox('* Naprawiles wszystkie elementy w pojezdzie.')
    playSoundFrontEnd 46 )
    triggerServerEvent("montazElementu"rootisVehicles"naprawa""all"0)
    setTimer(function()
        refreshGUI()
    end2002)
    end
end)


Podpis
Truck soon...
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-31, 15:15


fapster

Pseudol






Wiek: 22
Na forum: 4066 dni
Posty: 67
Nick w MP: MopSKY

Piwa: 272

Respekt: 50

mam jeszcze jeden problem dotyczacy naprawy pojazd?w, gdy wchodze w marker nie pojawia sie gui , mam skin, prace itp

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

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 (1000 PLN)"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

    local vehicles=getElementsWithinColShape(cs,"vehicle")
    if #vehicles < 1 then
        outputChatBox("* Na stanowisku monta?u nie ma ?adnego pojazdu."25500)
        return
    end
    if #vehicles > 1 then
        outputChatBox("* Na stanowisku monta?u jest zbyt du?o 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 masz 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()
    end2001)
end)

addEventHandler("onClientGUIClick"wm.fixall, function()
    if not isVehicles or not isElement(isVehiclesthen return end
    if 200 getPlayerMoney(localPlayerthen
        outputChatBox("* Nie masz 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 juz naprawiony.')
        return
    end

 triggerServerEvent("takePlayerMoney"localPlayer200)
    outputChatBox('* Naprawiles wszystkie elementy w pojezdzie.')
    playSoundFrontEnd 46 )
    triggerServerEvent("montazElementu"rootisVehicles"naprawa""all"0)
    setTimer(function()
        refreshGUI()
    end2002)
    end
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')


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

stanowiskaNaprawcze = {
    stanowiskoDoherty={
        mpos={2154.89, -2188.1413.55}, -- marker
        neyo={2143.92, -2177.1013.55,4}, -- cuboid 
        text="Naprawa pojazdu"
    },
    stanowiskoDoherty2={
        mpos={2151.53, -2191.9313.55}, -- marker
        neyo={2142.10, -2182.5813.55,4}, -- cuboid 
        text="Naprawa pojazdu"
    },
    stanowiskoDoherty3={
        mpos={-2050.36 ,175.5928.85}, -- marker
        neyo={-2047.93178.7328.85,4}, -- cuboid 
        text="Naprawa pojazdu"
    },
    stanowiskoDoherty4={
        mpos={-2050.13167.1228.84}, -- marker
        neyo={-2276.65, -133.4635.32,4}, -- cuboid 
        text="Naprawa pojazdu"
    },
        stanowiskoDoherty5={
        mpos={-2280.23, -129.3935.32}, -- marker
        neyo={-2277.86, -131.7635.32,4}, -- cuboid 
        text="Naprawa pojazdu"
    },

}



for i,v in pairs(stanowiskaNaprawcze) do

    v.cuboid=createColSphere(v.neyo[1], v.neyo[2], v.neyo[3], v.neyo[4])
    v.marker=createMarker(v.mpos[1], v.mpos[2], v.mpos[3]-1"cylinder"1.5509020075)
    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


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-31, 15:22


Ciastuuś

Truck soon...






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

Piwa: 4297

Respekt: 640
Respekt: 640Respekt: 640

B??dy w /debugscript 3 podczas wchodzenia?

Podpis
Truck soon...
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-03-31, 15:27


fapster

Pseudol






Wiek: 22
Na forum: 4066 dni
Posty: 67
Nick w MP: MopSKY

Piwa: 272

Respekt: 50

nie ma zadnych

Postaw piwo autorowi tego posta
 

 
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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