Hello guys, i have a new problem...
I have clientside function:
function rendering()
if (draw) then
dxDrawImage(screenWidth/2-16,screenHeight/2-70,32,32,"data/cur.png")
elem = getElementsByType("vehicle")
for key,value in pairs(elem) do
local veh = getPedOccupiedVehicle(player)
if isElementOnScreen(value) and veh ~= value then
local ex,ey,ez = getElementPosition(value)
local px,py,pz = getElementPosition(player)
local dis = getDistanceBetweenPoints3D(ex,ey,ez,px,py,pz)
if dis < 50 and isLineOfSightClear(ex,ey,ez,px,py,pz,true,false,false,false) then
local x,y = getScreenFromWorldPosition(ex,ey,ez)
local hp = getElementHealth(value)
if x and hp ~= 0 then
hp = hp/10000
dxDrawRectangle(x-62.5, y, 125, 25, tocolor(0,0,0,100))
dxDrawRectangle(x-59.5, y+3, 119*hp, 19, tocolor(255,0,0,200))
end
end
end
end
end
end
addEventHandler("onClientRender", getRootElement(), rendering)
and i have:
function setHealthC(theVehicle)
local vx, vy, vz = getElementPosition(theVehicle)
local vrx, vry, vrz = getElementRotation(theVehicle)
setElementHealth(theVehicle, 10000.0)
military = createObject(3884, vx,vy,vz+1,vrx,vry,vrz)
setObjectStatic(military, true)
setElementCollisionsEnabled(military, false)
attachElements(military, theVehicle)
end
addEventHandler("onClientPlayerVehicleEnter", getRootElement(), setHealthC)
So there is a problem: When i enter car, and looking how many my car have health, it's write's that i have 10000 health, when i exit, now i can see that car HP bar, and it shows that this car has about 1000hp, so hp bar is not full, also when i'm in car, and other players looking at my car HP bar, they see that thing too, that hp bar is not full, only 1 time, it showed me full bar, but when i rejoined from car, i again see, that hp bar is not full, i think the problem in desync with client and server, but maybe no? I hope u will help me!