MisterQuestions Posted January 26, 2015 Posted January 26, 2015 Hey i have a error on this script, this suposes to move with vehicle, but it lags if is more than a user. Code: Client-Side: function follow(trped1) local x, y, z = getElementPosition(car) setCameraMatrix(x+5, y+12, z+4, x, y, z) end addEventHandler("onClientRender", getRootElement(),follow)
.:HyPeX:. Posted January 26, 2015 Posted January 26, 2015 If the car is server-side, it will follow a server element, wich is unstable (I.e. has a possible sync lag)
MisterQuestions Posted January 26, 2015 Author Posted January 26, 2015 So, i should create em on client too? or there's anyway to stay on server side and try use it with out lags.
MisterQuestions Posted January 26, 2015 Author Posted January 26, 2015 Still lagging. (Just if is there 1 player online no lag, If is 2 or more, is laggy)
MisterQuestions Posted January 26, 2015 Author Posted January 26, 2015 Oh yes Its a little long but... Server-Side function peds() if not isElement(RacerPed) then RacerPed = createPed (0,2068.4143066406, 1007.5880737305, 10.190197944641) end if not isElement(RaceVehicle) then RaceVehicle = createVehicle (411,2068.4143066406, 1007.5880737305, 10.190197944641,0,0,0) warpPedIntoVehicle ( RacerPed, RaceVehicle ) triggerClientEvent ( "ondrive", getRootElement(),RacerPed) end end Client-Side function driveit(trped1) if trped1 then setPedControlState(trped1,"accelerate",true) setTimer(function () setPedControlState(trped1,"accelerate",false) end,6000,1) startfollow(trped1) car = getPedOccupiedVehicle(trped1) end end addEvent( "ondrive", true ) addEventHandler( "ondrive", getRootElement(), driveit ) function follow(trped1) local x, y, z = getElementPosition(car) setCameraMatrix(x+5, y+12, z+4, x, y, z) end function startfollow(trped1) --triggerEvent("stopDrawInfo",getRootElement()) addEventHandler("onClientPreRender", getRootElement(),follow) setTimer(function()timerTime = timerTime - 1 end, 1000, 7) Timer = setTimer(function() fadeCamera ( false, 1.0, 0, 0, 0 ) end, 7000, 1) setTimer(function() stopfollow() triggerServerEvent("killracer",getRootElement()) end, 8000, 1) setElementDimension ( getLocalPlayer(), 0 ) end addEvent( "StartFollowing", true ) addEventHandler( "StartFollowing", getRootElement(), startfollow )
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now