InDev Posted February 22, 2010 Share Posted February 22, 2010 I want know some things about the stream of the elements: -Does, when an element is stream for a player, the server as the true position of the element if he move ? ( i suppose yes ) -Does, If it's true, this script working? : For the moment i only take care of the vehicles elements ( it's the most important ) Clientside: addEventHandler( "onClientElementStreamIn", getRootElement( ), function ( ) if getElementType( source ) == "vehicle" then triggerServerEvent( "streamIn", source, source, getLocalPlayer() ) end end ) addEventHandler( "onClientElementStreamOut", getRootElement( ), function ( ) if getElementType( source ) == "vehicle" then triggerServerEvent( "streamOut", source, source, getLocalPlayer() ) end end ) addEvent( "setElementPosForPl", true ) function setElementPosForPl( element, x, y, z, r, lights ) setElementPosition( element, x, y, z ) setVehicleRotation( element, (360-r) ) setVehicleLightState( element, lights ) end addEventHandler( "setElementPosForPl", getRootElement(), setElementPosForPl ) Serverside: function streamIn( element, forpl ) element = element or source if ( not getVehicleOccupant(element, 0) and not getVehicleOccupant( element, 1 ) and not getVehicleOccupant( element, 2 ) and not getVehicleOccupant( element, 3 ) and not getVehicleOccupant( element, 4 ) ) then local x = getElementData( element, "Xs" ) local y = getElementData( element, "Ys" ) local z = getElementData( element, "Zs" ) local r = getElementData( element, "Rots" ) setElementPosition( element, x, y, z ) setVehicleRotation( element, 0, 0, (r-360) ) setVehicleOverrideLights( element, getElementData( element, "lights" ) ) else local x, y, z = getElementPosition( element ) local rx, ry, r = getVehicleRotation( element ) local lights = getElementData( element, "lights" ) triggerClientEvent( forpl, "setElementPosForPl", forpl, element, x, y , z, r, lights ) end end addEvent( "streamIn", true ) addEventHandler( "streamIn", getRootElement(), streamIn ) function streamOut( element, forpl ) element = element or source if ( not getVehicleOccupant(element, 0) and not getVehicleOccupant( element, 1 ) and not getVehicleOccupant( element, 2 ) and not getVehicleOccupant( element, 3 ) and not getVehicleOccupant( element, 4 ) ) then local x, y, z = getElementPosition( element ) local rx,ry,r = getVehicleRotation( element ) setElementData( element, "Xs", x ) setElementData( element, "Ys", y ) setElementData( element, "Zs", z ) setElementData( element, "Rots", r ) local li = getVehicleOverrideLights( element ) setElementData( element, "lights", li ) end end addEvent( "streamOut", true ) addEventHandler( "streamOut", getRootElement(), streamOut ) Thanx for (futures) answers Link to comment
Gamesnert Posted February 22, 2010 Share Posted February 22, 2010 -Does, when an element is stream for a player, the server as the true position of the element if he move ? ( i suppose yes ) I don't understand your question, to be honest. Also, why are you making that code? It should be synced by MTA itself. Seems like a lot of trouble for nothing to be honest. Link to comment
lil Toady Posted February 22, 2010 Share Posted February 22, 2010 I dont see what you are trying to do, mta already handles streaming with position and all the states etc Link to comment
InDev Posted February 22, 2010 Author Share Posted February 22, 2010 I tryed to sync vehicles when they are stream. I thought the vehicles pos sync was not good... My question was: Does the server sync the vehicles for all the players ? Link to comment
Gamesnert Posted February 22, 2010 Share Posted February 22, 2010 My question was:Does the server sync the vehicles for all the players ? Yes. Gladly it does. Link to comment
Kayl Posted February 22, 2010 Share Posted February 22, 2010 I also don't really understand why you feel the need to do so. Is this related to your previous trailer topic? Because if it is so, indeed, if you try, on the client side, to move vehicles for which the local player is not the driver, then MTA doesn't consider the local player as the syncer for those objects. Therefore the positions of the objects you moved will be reset as soon as an other player approaches the vicinity of the local player or the object's last legit position known by the server. Link to comment
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