hdrtop Posted May 12, 2020 Share Posted May 12, 2020 Hello! I'm creating a vehicle system and I'm adding a fuel system. In serverside i got this: // The chat says that fuel is 80, THIS IS CORRECT, when I create the vehicle I give 80 of fuel. function playerEnterVehicleHandler(player, vehicle, seat) { player.outputChatBox(`${player.name} got into the car with ID: ${vehicle.id}. Seat: ${seat}. Fuel: ${vehicle.fuel}`); if(seat == -1) { if(vehicle.fuel === 0) { player.outputChatBox("Vehicle Tank is empty."); vehicle.engine = false; } } } But when I try to get the variable from client it says "undefined": // The output says: (example) Speed: 120, gear: 4, RPM: 4.44..., Fuel: undefined mp.events.add("render", () => { var player = mp.players.local; if (player.vehicle && player.vehicle.getPedInSeat(-1)) { var veh = player.vehicle; var rpm = player.vehicle.rpm; var gear = player.vehicle.gear; var fuel = player.vehicle.fuel; if(velocimetro) { mp.gui.chat.push("Speed: "+veh.getSpeed()", gear: "+gear+", RPM: "+rpm+", Fuel: "+fuel); } } }); Anyone? Thanks in advice! Link to comment Share on other sites More sharing options...
MrPancakers Posted May 12, 2020 Share Posted May 12, 2020 Simply adding a property onto an object doesn't instantly make it synced to the client. In order to do this you either need to use "entity.data.fuel" or "entity.setVariable('fuel', value);" and clientside you'd use "entity.getVariable('fuel');" https://wiki.rage.mp/index.php?title=Entity::setVariable https://wiki.rage.mp/index.php?title=Entity::getVariable https://wiki.rage.mp/index.php?title=Entity::data 1 Link to comment Share on other sites More sharing options...
hdrtop Posted May 12, 2020 Author Share Posted May 12, 2020 Thanks for the info! Link to comment Share on other sites More sharing options...
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