Wysłany: 2014-12-31, 20:26
TAYHI
Wiek: 29 Na forum: 5469 dni Posty: 10
Nick w MP: TAYHI
Witam poczbuje pomocy chce to zrbic zeby bylo na id skina 50 czyli mechanika: Kto bedzie mial id mechanika czyli 50 bedzie mogl naprawiac przez guid [Plik xyzzyRPG]
Mechanik_s.lua
Kod: local strefyNapraw={
--idlewood
warsztatIdlewoodStanowsko11={
cuboid={1846.96, -1784.89, 14.1, 5, 9, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={1854.92,-1780.84,12.55}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
warsztatIdlewoodStanowsko12={
cuboid={1846.96, -1775.17, 14.1, 5, 9, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={1854.44,-1772.43,12.65}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
warsztatIdlewoodStanowsko2={
cuboid={1892.99, -1784.89, 14.1, 5, 21, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={1900.45,-1779.93,12.55}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
--montgomery
warsztatMontgomeryStanowsko1={
cuboid={1184.08,253.10,19.63, 8, 6, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={1182.39,253.35,18.53}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
warsztatMontgomeryStanowsko2={
cuboid={1187.19,260.38,19.63, 8, 6, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={1185.23,261.67,18.53}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
warsztatMontgomeryStanowsko3={
cuboid={1190.69,267.41,19.63, 8, 6, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={1188.04,268.48,18.53}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
--fernridge
warsztatFernridgeStanowsko1={
cuboid={625.54,-112.51,26, 6, 14, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={634.07,-120.03,24.49}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
--blueberry
warsztatBlueberryStanowsko1={
cuboid={98.99,-200.74,1.63, 5, 14, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={105.87,-182.61,0.63}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
warsztatBlueberryStanowsko2={
cuboid={83.09,-200.69,1.63, 5, 14, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={91.86,-186.84,0.63}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
--palomino creek
warsztatPalominoStanowsko1={
cuboid={2322.59,-192.69,26.49, 5, 14, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={2320.13,-177.73,25.49}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
warsztatPalominoStanowsko2={
cuboid={2305.99,-192.79,26.50, 5, 14, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={2303.40,-174.48,25.50}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
warsztatPalominoStanowsko3={
cuboid={2289.70,-192.82,26.50, 6, 14, 6 },-- cuboid w ktorym musi znalezc sie pojazd
mpos={2297.36,-175.18,25.50}, -- pozycja markera w ktorym gracz bedzie stal aby naprawiac
},
}
for i,v in pairs(strefyNapraw) do
v.cs=createColCuboid(unpack(v.cuboid))
v.marker=createMarker(v.mpos[1], v.mpos[2], v.mpos[3], "cylinder", 1, 0,0,0,100)
setElementData(v.marker,"cs",v.cs)
end
-- triggerServerEvent("naprawaElementu", resourceRoot, naprawiany_pojazd, czesc, koszt)
addEvent("naprawaElementu", true)
addEventHandler("naprawaElementu", resourceRoot, function(pojazd, czesc, koszt)
outputDebugString("Naprawa elementu " .. czesc .. " za " .. koszt)
if koszt>getPlayerMoney(client) then
return
end
if (czesc==-1) then
-- setElementHealth(pojazd, 1000)
local vps={}
local vds={}
local vls={}
for i=0,6 do vps[i]=getVehiclePanelState(pojazd,i) end
for i=0,3 do vds[i]=getVehicleDoorState(pojazd,i) end
for i=0,3 do vls[i]=getVehicleLightState(pojazd,i) end
fixVehicle(pojazd)
for i=0,6 do setVehiclePanelState(pojazd, i, vps[i]) end
for i=0,3 do setVehicleDoorState(pojazd, i, vds[i]) end
for i=0,3 do setVehicleLightState(pojazd, i, vls[i]) end
triggerClientEvent(client, "refreshVehicleData", resourceRoot, pojazd)
elseif czesc>=0 and czesc<=6 then
setVehiclePanelState(pojazd, czesc, 0)
triggerClientEvent(client, "refreshVehicleData", resourceRoot, pojazd)
elseif czesc>=10 and czesc<20 then
local drzwi=czesc-10
setVehicleDoorState(pojazd, drzwi, 0)
triggerClientEvent(client, "refreshVehicleData", resourceRoot, pojazd)
elseif czesc>=20 then
local swiatlo=czesc-20
setVehicleLightState(pojazd, swiatlo, 0)
triggerClientEvent(client, "refreshVehicleData", resourceRoot, pojazd)
end
end)
Mechanik_c.lua
Kod: local w_m={}
--utils
function math.round(number, decimals, method)
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 sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
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.6, 0.8395, 0.35, 0.1327, "", true, w_m.wnd)
w_m.lbl_costinfo = guiCreateLabel(0.6, 0.8395, 0.35, 0.1327, "", true, w_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,"przebieg") 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,"przebieg") 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,row, 1, "Silnik",false,false)
guiGridListSetItemData(w_m.grid,row, 1, -1)
guiGridListSetItemText(w_m.grid,row, 2, math.round(getElementHealth(v)/10).."%", false, true)
guiGridListSetItemText(w_m.grid,row, 3, math.round(math.abs(kosztNaprawySilnika(v))+2).."$", false, true)
end
end
for i,panel in pairs(panele) do
local stan = getVehiclePanelState(v, i)
if stan ~= 0 then
local koszt=kosztNaprawyElementu(v)*(getVehiclePanelState(v,i))/6
local row=guiGridListAddRow(w_m.grid)
guiGridListSetItemText(w_m.grid,row, 1, panel,false,false)
guiGridListSetItemData(w_m.grid,row, 1, i)
local stan=stanyPaneli[getVehiclePanelState(v,i)]
guiGridListSetItemText(w_m.grid,row, 2, stan, false, true)
guiGridListSetItemText(w_m.grid,row, 3, math.round(koszt+2).."$", false, true)
end
end
-- drzwi
for i=0,5 do
local stan=getVehicleDoorState(v, i)
if stan==2 or stan==3 or stan==4 then
local koszt=kosztNaprawyElementu(v)*2/6
local row=guiGridListAddRow(w_m.grid)
guiGridListSetItemText(w_m.grid,row, 1, nazwyDrzwi[i],false,false)
guiGridListSetItemData(w_m.grid,row, 1, i+10)
guiGridListSetItemText(w_m.grid,row, 2, "0%", false, true)
guiGridListSetItemText(w_m.grid,row, 3, math.round(koszt+2).."$", false, true)
end
end
for i=0,3 do
local stan=getVehicleLightState(v, i)
if stan==1 then
local koszt=kosztNaprawyElementu(v)*2/6
local row=guiGridListAddRow(w_m.grid)
guiGridListSetItemText(w_m.grid,row, 1, nazwySwiatel[i],false,false)
guiGridListSetItemData(w_m.grid,row, 1, i+20)
guiGridListSetItemText(w_m.grid,row, 2, "0%", false, true)
guiGridListSetItemText(w_m.grid,row, 3, math.round(koszt+2).."$", false, true)
end
end
end
addEventHandler("onClientMarkerHit", resourceRoot, function(el,md)
if not md or el~=localPlayer then return end
local cs=getElementData(source, "cs")
if not cs then return end
if getElementData(source, "braniekola") then return end
local fid=getElementData(source, "faction_id")
local lfid=getElementData(el, "faction:id") 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)
end, 1000, 0, el)
fillVehicleData(pojazdy[1])
guiSetEnabled(w_m.btn_napraw, false)
guiSetText(w_m.lbl_info,"")
guiSetVisible(w_m.wnd, true)
guiSetText(w_m.btn_napraw, string.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.wnd, false)
naprawiany_pojazd=nil
if allCost and isTimer(allCost) then killTimer(allCost) end
end)
addEventHandler("onClientGUIClick", w_m.btn_zamknij, function()
guiSetVisible(w_m.wnd, false)
naprawiany_pojazd=nil
if allCost and isTimer(allCost) then killTimer(allCost) end
end, false)
addEventHandler("onClientGUIClick", w_m.grid, function()
guiSetText(w_m.lbl_info,"")
selectedRow= guiGridListGetSelectedItem ( w_m.grid) or -1
if (selectedRow<0) then
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/3 == math.round(k/3)) then --kazde 3 wyniki sa takie same, pomijamy je
table.insert(multirepair,v)
end
end
totalkoszt = 0
for k,v in ipairs(multirepair) do
local koszt = guiGridListGetItemText(w_m.grid, v.row, 3)
local koszt = koszt:split("$")
local koszt = tonumber(koszt[1])
totalkoszt = totalkoszt+koszt
end
guiSetText(w_m.lbl_info, string.format("W sumie do zap?aty: %s$",totalkoszt))
guiSetEnabled(w_m.btn_napraw, true)
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_pojazd) then return end
selectedRow= guiGridListGetSelectedItem ( w_m.grid) or -1
if selectedRow<0 then return end
local rows = guiGridListGetSelectedItems(w_m.grid)
local multirepair = {}
--musimy sprawdzic, czy gracz zaznaczyl KILKA rowow, czy JEDEN //karer - takie male udogodnienie
for k,v in ipairs(rows) do
if (k/3 == math.round(k/3)) then --kazde 3 wyniki sa takie same, pomijamy je
table.insert(multirepair,v)
end
end
guiSetText(w_m.lbl_info,"")
if #multirepair == 1 then
local koszt = guiGridListGetItemText(w_m.grid, selectedRow, 3)
local koszt = koszt:split("$")
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(localPlayer) then
-- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
-- return
-- end
local czesc=guiGridListGetItemData(w_m.grid, selectedRow, 1) -- numer panelu lub -1==silnik
napraw_lu=getTickCount()
triggerServerEvent("naprawaElementu", resourceRoot, naprawiany_pojazd, czesc, koszt)
elseif #multirepair > 1 then
for i,v in ipairs(multirepair) do
local selectedRow = v.row
local koszt = guiGridListGetItemText(w_m.grid, selectedRow, 3)
local koszt = koszt:split("$")
local koszt = tonumber(koszt[1])
if not koszt then return end
if koszt<=0 then
break
end
-- if koszt>getPlayerMoney(localPlayer) then
-- guiSetText(w_m.lbl_info,"Nie masz tyle got?wki!")
-- return
-- end
local czesc=guiGridListGetItemData(w_m.grid, selectedRow, 1) -- numer panelu lub -1==silnik
napraw_lu=getTickCount()
triggerServerEvent("naprawaElementu", resourceRoot, naprawiany_pojazd, czesc, koszt)
end
else
outputDebugScript("lss-naprawapojazdow> inna wartosc countRows, should't happen.")
end
end, false)
-- triggerClientEvent(client, "refreshVehicleData", resourceRoot, pojazd)
addEvent("refreshVehicleData", true)
addEventHandler("refreshVehicleData", resourceRoot, function(pojazd)
naprawiany_pojazd=pojazd
fillVehicleData(pojazd)
end)
Wysłany: 2015-01-01, 00:24
LordKamis
Wiek: 26 Na forum: 4340 dni Posty: 107
Piwa : 190
Zastosuj if getElementModel ( thePlayer ) == 50 then
Wysłany: 2015-01-01, 10:23
TAYHI
Wiek: 29 Na forum: 5469 dni Posty: 10
Nick w MP: TAYHI
ale gdzie
[ Dodano : 2015-01-01, 10:35 ]
Gdzie nie daje to stanowiska znikaja albo ja cos mieszam ;D
Wysłany: 2015-01-01, 19:35
Terr9909
Skrypter LUA
Wiek: 26 Na forum: 4234 dni Posty: 346
Nick w MP: Split
Piwa : 1043
tam gdzie masz:
local fid = getElementData ( source , "faction_id" )
local lfid = getElementData ( el , "faction:id" ) or - 1
if fid ~= lfid then return end -- gracz nie jest pracownikiem ]]--
zamie? na sprawdzanie skina ;-)
if getElementModel ( el ) ~= 50 then return end
Wysłany: 2015-01-01, 20:46
TAYHI
Wiek: 29 Na forum: 5469 dni Posty: 10
Nick w MP: TAYHI
Split dzi?kuje ci i dostajesz piwko ale takie z lod?wki
Do Zamkni?cia
Wysłany: 2015-01-02, 07:22
Bingwin
LUA MTA
Wiek: 27 Na forum: 4191 dni Posty: 95
Nick w MP: Bingwin
Piwa : 2070
" xyzzyRPG " A nie powinno by? " xyzzyRP "
Wysłany: 2015-01-02, 07:53
Terr9909
Skrypter LUA
Wiek: 26 Na forum: 4234 dni Posty: 346
Nick w MP: Split
Piwa : 1043
Bingwin , I co Ty tak si? czepiasz do ka?dego tematu, napisa? tak to niech ju? tak jest, nie nabijaj post?w.
Tagi: mechanik :: skina
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: