polaczkos
Wiek: 25 Na forum: 4085 dni Posty: 168
Nick w MP: polaczkos
Piwa : 3
Witam robi? prac? czyszczenia ulic i mam problem bo nie dzia?a mi naliczanie KG a ?adne b??dy nie wyskakuj? pomocy
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 ( "onClientVehicleExit" , root ,function( p )
if p ~= localPlayer then return end
if isTimer ( timer ) then killTimer ( timer ) end
end )
a tu wy?wietlanie ale one powinno dzia?a? bo jak podpinam pod przebieg to normalnie wy?wietla
function zapelenienie ()
local pojazdy = getElementsByType ( "vehicle" , getRootElement ())
local rx , ry , rz = getCameraMatrix ()
for i , pojazd in ipairs ( pojazdy ) do
if getElementData ( pojazd , "zbieranie" ) then
local zapelenienie2 = getElementData ( pojazd , "kilogramy" ) or 0
local vx , vy , vz = getElementPosition ( pojazd )
local x , y , z = getElementPosition ( localPlayer )
local distance = getDistanceBetweenPoints3D ( rx , ry , rz , vx , vy , vz )
if distance <= 20 then
local sx , sy = getScreenFromWorldPosition ( vx , vy , vz , 0.06 )
if sx and sy then
if sx and sy then
dxDrawText ( "Zape?enienie: " .. zapelenienie2 .. " KG" , sx - 7 , sy + 30 , sx - 1 , sy + 25 , tocolor ( 255 , 255 , 255 , 255 ), 1 , "default-bold" , "center" , "center" , false , false , false , false , false )
end
end
end
end
end
end
addEventHandler ( "onClientRender" , root , zapelenienie )