Kamilo_Kamilo12
Wiek: 25 Na forum: 1930 dni Posty: 8
Nick w MP: Kamilo
Piwa : 2
Cze??, Przychodz? do was z Pytanie co jest ?le w Skrypcie, Gdy wje?d?am w Blipa pokazuj? ?e Naprawia Pojazd jednak nie zabiera Ani Got?wki, Ani go nie naprawia.
Kod:
mojeW,mojeH = 1280, 1024
sW,sH = guiGetScreenSize()
w, h = (sW/mojeW), (sH/mojeH)
local sx, sy = guiGetScreenSize ()
naprawa = true
function mysz(psx,psy,pssx,pssy,abx,aby)
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*sx,cy*sy
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end
local m_dostep="mechanik-sf1"
local doFixed={
{"Silnik", 1, fn=function(veh) if getElementHealth(veh)>=2040 then return true end; return false end},
{"Maska", 2, fn=function(veh) if getVehicleDoorState(veh, 0)==0 then return true end; return false end},
{"Baga?nik", 3, fn=function(veh) if getVehicleDoorState(veh, 1)==0 then return true end; return false end},
{"Drzwi lewy prz?d", 4, fn=function(veh) if getVehicleDoorState(veh, 2)==0 then return true end; return false end},
{"Drzwi prawy prz?d", 5, fn=function(veh) if getVehicleDoorState(veh, 3)==0 then return true end; return false end},
{"Drzwi lewy ty?", 6, fn=function(veh) if getVehicleDoorState(veh, 4)==0 then return true end; return false end},
{"Drzwi prawy ty?", 7, fn=function(veh) if getVehicleDoorState(veh, 5)==0 then return true end; return false end},
{"Szyba przednia", 8, fn=function(veh) if getVehiclePanelState(veh, 4)==0 then return true end; return false end},
{"Zderzak przedni", 9, fn=function(veh) if getVehiclePanelState(veh, 5)==0 then return true end; return false end},
{"Zderzak tylni", 10, fn=function(veh) if getVehiclePanelState(veh, 6)==0 then return true end; return false end},
{"?wiat?o lewe przednie", 11, fn=function(veh) if getVehicleLightState(veh, 0)==0 then return true end; return false end},
{"?wiat?a prawe przednie", 12, fn=function(veh) if getVehicleLightState(veh, 1)==0 then return true end; return false end},
{"?wiat?a lewe tylnie", 13, fn=function(veh) if getVehicleLightState(veh, 2)==0 then return true end; return false end},
{"?wiat?a prawe tylnie", 14, fn=function(veh) if getVehicleLightState(veh, 3)==0 then return true end; return false end},
}
local doCosts ={ 1000, 500, 500, 500, 500, 500, 500, 1000, 500, 500, 500, 500, 500, 500 }
local wm={}
local isVehicles=nil
wm.gridlist = guiCreateGridList(357*w, 393*h, 567*w, 218*h, false)
guiGridListAddColumn(wm.gridlist, "Cz???", 0.45)
guiGridListAddColumn(wm.gridlist, "Koszt", 0.45)
guiGridListAddRow(wm.gridlist)
guiSetVisible(wm.gridlist, false)
guiSetAlpha(wm.gridlist, 0.8)
guiSetFont(wm.gridlist, "default-bold-small")
local function refreshGUI()
if not isVehicles then return end
guiGridListClear(wm.gridlist)
for i,v in pairs(doFixed) do
if v.fn(isVehicles)==false then
local row = guiGridListAddRow(wm.gridlist)
guiGridListSetItemText(wm.gridlist, row, 1, v[1], false, false)
guiGridListSetItemData(wm.gridlist, row, 1, i)
guiGridListSetItemText(wm.gridlist, row, 2, doCosts[i].." PLN", false, false)
guiGridListSetItemData(wm.gridlist, row, 2, doCosts[i])
end
end
end
addEventHandler("onClientMarkerHit", resourceRoot, function(el,md)
if not md or el~=localPlayer then return end
local cs=getElementData(source, "snn_cs")
if not cs then return end
local vehicles=getElementsWithinColShape(cs,"vehicle")
if #vehicles < 1 then
triggerEvent('onClientAddNotification', localPlayer, 'Na stanowisku naprawczym nie znajduje si?\npojazd', 'error')
return
end
if #vehicles > 1 then
triggerEvent('onClientAddNotification', localPlayer, 'Na stanowisku naprawczym znajduje si?\nzbyt du?a ilo?? pojazd?w', 'error')
return
end
showCursor(true, false)
guiSetVisible(wm.gridlist, true)
if naprawa == false then
addEventHandler("onClientRender",root,gui)
naprawa = true
isVehicles = vehicles[1]
guiGridListClear(wm.gridlist)
for i,v in pairs(doFixed) do
if v.fn(isVehicles)==false then
local row = guiGridListAddRow(wm.gridlist)
guiGridListSetItemText(wm.gridlist, row, 1, v[1], false, false)
guiGridListSetItemData(wm.gridlist, row, 1, i)
guiGridListSetItemText(wm.gridlist, row, 2, doCosts[i].." PLN", false, false)
guiGridListSetItemData(wm.gridlist, row, 2, doCosts[i])
end
end
end
end)
addEventHandler("onClientMarkerLeave", resourceRoot, function(el,md)
if el~=localPlayer then return end
guiSetVisible(wm.gridlist, false)
removeEventHandler("onClientRender",root,gui)
naprawa = false
isVehicles=nil
showCursor(false)
end)
addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "down" then
if naprawa == true then
if mysz(352*w, 624*h, 210*w, 78*h) then
if not isVehicles or not isElement(isVehicles) then return end
selectedRow = guiGridListGetSelectedItem(wm.gridlist) or -1
if selectedRow < 0 then return end
local cost = guiGridListGetItemData(wm.gridlist, selectedRow, 2)
if cost > getPlayerMoney(localPlayer) and not getElementData(localPlayer, "player:duty") == "SAFD" and not getElementData(localPlayer, "player:duty") == "SAPD" and not getElementData(localPlayer, "player:duty") == "SAMD" and not getElementData(localPlayer, "player:duty") == "SATS" then
outputChatBox("#bf0101(✖) #FFFFFFNie masz tyle got?wki!", 255,255,255, true)
cancelEvent()
return
end
if getElementData(localPlayer, "player:duty") == "SAFD" then cost = 0 end
if getElementData(localPlayer, "player:duty") == "SAPD" then cost = 0 end
if getElementData(localPlayer, "player:duty") == "SAMD" then cost = 0 end
local part = guiGridListGetItemData(wm.gridlist, selectedRow, 1)
outputChatBox('(✔) Naprawi?e? cz???: ' .. tostring(getPartName(doFixed, part, 255,255,255, true)))
triggerServerEvent("takePlayerMoney", localPlayer, cost)
triggerServerEvent("montazElementu", root, isVehicles, "naprawa", part, cost)
setTimer(function()
refreshGUI()
end, 10000, 2)
end
end
end
end)
addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "down" then
if naprawa == true then
if mysz(718*w, 624*h, 210*w, 78*h) then
if not isVehicles or not isElement(isVehicles) then return end
if 10000 > getPlayerMoney(localPlayer) and not getElementData(localPlayer, "player:duty") == "SAFD" and not getElementData(localPlayer, "player:duty") == "SAPD" and not getElementData(localPlayer, "player:duty") == "SAMD" and not getElementData(localPlayer, "player:duty") == "SATS" then
triggerEvent('onClientAddNotification', localPlayer, 'Nie posiadasz wystarczaj?co got?wki\ndo naprawy pojazdu', 'error')
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
triggerEvent('onClientAddNotification', localPlayer, 'Pojazd jest ju? naprawiony.', 'error')
return
end
if getElementData(localPlayer, "player:duty") == "SAFD" or getElementData(localPlayer, "player:duty") == "SAPD" or getElementData(localPlayer, "player:duty") == "SAMD" or getElementData(localPlayer, "player:duty") == "SATS" then
triggerServerEvent("takePlayerMoney", localPlayer, 0)
outputChatBox('* Naprawiles wszystkie elementy w pojezdzie.')
triggerServerEvent("montazElementu", root, isVehicles, "naprawa", "all", 0)
else
triggerServerEvent("takePlayerMoney", localPlayer, 10000)
triggerEvent('onClientAddNotification', localPlayer, 'Naprawi?e? wszystkie cz??ci w poje?dzie.', 'success')
triggerServerEvent("montazElementu", root, isVehicles, "naprawa", "all", 10000)
setTimer(function()
refreshGUI()
end, 10000, 2)
end
end
end
end
end)
function gui()
dxDrawImage(315*w, 313*h, 650*w, 400*h, "naprawa-psrpg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end
-- utils
function getPartName(t, key)
for i,v in pairs(t) do
if v[2]==key then
return v[1]
end
end
end
Problem Jaki si? wy?wietla w debugscript 3:
ERROR: Client triggered serverside event takePlayerMoney, but event is not added serverside
[11:31] ERROR: Client triggered serverside event montazElementu, but event is not added serverside