Witam robi? prac? czyszczenia ulic i mam problem bo nie dzia?a mi naliczanie KG a ?adne b??dy nie wyskakuj? pomocy
[lua]
local time=getTickCount()
function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
if
type( sEventName ) == 'string' and
isElement( pElementAttachedTo ) and
type( func ) == 'function'
then
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
end
return false
end
local function naliczaj2(veh)
if getTickCount()-time>5000 then
time = getTickCount()
local kg = getElementData(veh,"kilogramy") or 0
local vx,vy,vz = getElementVelocity(veh)
local spd=((vx^2 + vy^2 + vz^2)^(0.5)/2)
if spd>0 then
kg = kg+(spd * 1.25)
setElementData(veh, "kilogramy", kg)
end
end
end
function rendering2()
local pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end
if getElementData(pojazd,"kilogramy") and getElementData(pojazd,"kilogramy") then
naliczaj2(pojazd)
end
end
addEventHandler("onClientVehicleEnter",root,function(p)
if p ~= localPlayer then return end
if isTimer(timer) then killTimer(timer) end
time=getTickCount()
timer = setTimer(rendering2,5000,0)
end)
addEventHandler("onClientVe...
[lua]local rSweeper = createMarker(1610.88,-1893.91,12.55,"cylinder",1.5,255,0,0,150)
local bSweeper = createBlip(1610.88,-1893.91,12.55,52)
addEventHandler("onMarkerHit",rSweeper,
function (player)
if getElementData(player,"pracaSweeper") then outputChatBox("Posiadasz aktywn? prac?!",player) return end
local pSweeper = createVehicle(574,1615.72,-1893.36,13.22,360,360,360)
setElementData(player,"pracaSweeper",true)
warpPedIntoVehicle(player,pSweeper)
local v = getPedOccupiedVehicle(player)
outputChatBox("Rozpocze?e? prac? sweeper, twoim zadaniem jest jazda po mie?cie i czyszczenie ulic!",player)
outputChatBox("Je?eli wysi?dziesz z pojazdu, otrzymasz wynagrodzenie i praca si? zako?czy!",player)
local sx,sy,sz = getElementVelocity(v)
local kmhs = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
if kmhs >= 10 then
local smie = smie + 2
local smieci = setElementData(v,"smieci",smie)
setElementData(v,"pojazd_opis","?mieci: "..smieci.."%")
else return
end
end
)
addEventHandler("onVehicleStartExit",resourceRoot,
function (player)
local v = getPedOccupiedVehicle(player)
local smieci = getElementData(v,"smieci",smie)
setElementData(player,"pracaSweeper",false)
givePlayerMoney(player,smieci)
destroyElement(v)
end
)
addCommandHandler("dezaktywujs",
function (player)
...
local pojazdy = {
{-2633.43,-33.30,4.06,0,360,180},
{-2630.43,-33.30,4.06,0,360,180},
{-2627.43,-33.30,4.06,0,360,180},
{-2624.43,-33.30,4.06,0,360,180},
}
for i,v in ipairs (pojazdy) do
local veh = createVehicle(574,v[1],v[2],v[3],v[4],v[5],v[6])
setElementData(veh,"pojazd_paliwo",100)
setElementData(veh,"pojazd_opis","Praca DorywczanSweepery")
setElementFrozen(veh,true)
end
addEventHandler("onVehicleEnter",resourceRoot,
function ( player, seat )
if seat == 0 then
local veh = getPedOccupiedVehicle(player)
setElementData(veh,"pojazd_opis","Zape?nienie: 0%")
setElementData(veh,"smieci",0)
local veh = getPedOccupiedVehicle(player)
local speed = getElementVelocity(veh)
if speed > 5 then
setTimer(function()
local smieci = getElementData(veh,"smieci")
smieci = smieci + 1
setElementData(veh,"pojazd_opis","Zape?nienie: "..smieci.."%")
setElementData(veh,"smieci",smieci)
end,6000,0)
else return end
end
end
)
addEventHandler("onVehicleStartExit",resourceRoot,
function ( player, seat )
if seat == 0 then
local veh = getPedOccupiedVehicle(player)
setTimer(function()
respawnVehicle(veh)
setElementData(veh,"pojazd_opis","Praca DorywczanSweepery")
setElementData(veh,"smieci",0)
end,2500,...
function removePreviousVehicles(plr)
for i,v in ipairs(getElementsByType("vehicle", resourceRoot)) do
local sby = getElementData(v, "zrespilGracz")
if sby and sby == plr and getPedOccupiedVehicle(plr) ~= v then
destroyElement(v)
end
end
end
addEventHandler("onMarkerHit", m1, function(el, md)
if getElementData(el, "zrespilGracz") then
outputChatBox("Praca w trakcie przygotowania.", el)
return
end
if not md or getElementType(el) ~= "player" or getPedOccupiedVehicle(el) then return end
local x,y,z = getElementPosition(el)
local bus = createVehicle(574, x,y,z,0.0, 360.0, 269.9)