Basti160301 Posted April 19, 2022 Posted April 19, 2022 I create my vehicle like this jobVeh[jobVeh.length + 1] = mp.vehicles.new(mp.game.joaat("ambulance"), new mp.Vector3(-487.798, -252.667, 35.454), I want that it spawns with Door Open and Siren(Just Light) on. Greets
Kopra Posted April 19, 2022 Posted April 19, 2022 (edited) Vehicle::Vehicle - RAGE Multiplayer Wiki Here you can see default parameters that you can use when creating vehicles server side. For opening door and siren you will need to use clientside, make events with these functions: Vehicle::setDoorsShut - RAGE Multiplayer Wiki Vehicle::setSiren - RAGE Multiplayer Wiki You will also need to call that event on all the players in stream range in order to apply, for example: CLIENTSIDE // Here we define events that every player on our server will have in his client-side mp.events.add( { 'OPEN_DOORS': (VehicleId, Doors) => { // VehicleId = ID of vehicle on which we want doors to open | Doors = door numbers, check on wiki // Here we get vehicle from pool by VehicleId const RemoteVeh = mp.vehicles.at(VehicleId); // We check if it exists, if not stop here if (!RemoteVeh) return; // We apply function for opening doors, check wiki for more info RemoteVeh.setDoorOpen(Doors, false, true); }, 'TOGGLE_SIREN': (VehicleId, State) => { // VehicleId = ID of vehicle on which we want doors to open | State = true/false // Here we get vehicle from pool by VehicleId const RemoteVeh = mp.vehicles.at(VehicleId); // We check if it exists, if not stop here same as before if (!RemoteVeh) return; // And we apply function for toggling siren on/off, check wiki RemoteVeh.setSiren(State); }, } ) SERVERSIDE const spawnVehicle = (player) => { // Creating vehicle const newVeh = mp.vehicles.new("elegy", player.position); // Put player into vehicle with 200 ms delay, that way we make sure vehicle exists setTimeout(() => { // We check if vehicle does not exist, just to be safe if (!newVeh) return; // For every player that is in 300 radius of vehicle(stream distance), on his client-side open doors for given vehicle(newVeh, your current spawned veh) mp.players.forEachInRange(newVeh.position, 300, (nearPlayer) => { // Call client side events we made up nearPlayer.call("OPEN_DOORS", [newVeh.id, 0]); // 0 = front left door nearPlayer.call("TOGGLE_SIREN", [newVeh.id, true]); }); }, 200); } Edited April 20, 2022 by Kopra
Basti160301 Posted April 20, 2022 Author Posted April 20, 2022 Okay, that looks complicated as hell is just want that the vehicle spawns with door open and siren on i dont get it
Kopra Posted April 20, 2022 Posted April 20, 2022 I edited my post with comments explaining it a bit.
Basti160301 Posted April 20, 2022 Author Posted April 20, 2022 What does this mean? const spawnVehicle = (player) =>
Basti160301 Posted April 20, 2022 Author Posted April 20, 2022 I can do it Simple.. i want to create a Rescue Mission for a Rescue Helicopter.. everything is working really good but i wanted to create an Ambulance for better look. it would look way better but idk why i got everything i got everything selfmade with the Wiki but that is a big part i dont get.. i even got my MySQL Working
Kopra Posted April 20, 2022 Posted April 20, 2022 For that purpose, you can do it way simpler. In your clientside: jobVeh[jobVeh.length + 1] = mp.vehicles.new(mp.game.joaat("ambulance"), new mp.Vector3(-487.798, -252.667, 35.454); setTimeout(() => { jobVeh[jobVeh.length + 1].setDoorOpen(DOOR_INDEX, true, false); jobVeh[jobVeh.length + 1].setSiren(true); }, 200); Change DOOR_INDEX with your desired doors.
Basti160301 Posted April 20, 2022 Author Posted April 20, 2022 Yeah this is how i tried it too.. but look at this https://prnt.sc/m3CQEk26g4ll
Kopra Posted April 21, 2022 Posted April 21, 2022 (edited) Makes sense, length of array gets incremented. // Assagin ID to variable so its consistent const jobVehId = jobVeh.length + 1; jobVeh[jobVehId] = mp.vehicles.new(mp.game.joaat("ambulance"), new mp.Vector3(-487.798, -252.667, 35.454); setTimeout(() => { jobVeh[jobVehId].setDoorOpen(DOOR_INDEX, true, false); jobVeh[jobVehId].setSiren(true); }, 200); Edited April 21, 2022 by Kopra
Basti160301 Posted April 21, 2022 Author Posted April 21, 2022 i think we are Getting Closer but there is one point i dont get i tried a few other ways but look at my Code let ped = mp.peds.new( mp.game.joaat('s_m_m_doctor_01'), new mp.Vector3(358.30535888671875, -589.4619750976562, 28.796092987060547), -111.98, mp.players.local.dimension ); var jobBlips = new Array(); var jobMarker = new Array(); var jobVeh = new Array(); const jobVehId = jobVeh.length +1; mp.events.add('createJobBlipRTH', (player, ID, position, name, color, shortRange) => { jobBlips[jobBlips.length + 1] = mp.blips.new(parseInt(ID), position, { name: name, color: parseInt(color), shortRange: (shortRange === 'true'), }); jobMarker[jobMarker.length + 1] = mp.markers.new(34, position, 1, { direction: new mp.Vector3(0, 0, 75), color: [255, 255, 255, 255], visible: true, dimension: 0 }); mp.console.logWarning(`${position}`, true, true); }); mp.events.add('createJobSceneRTH', (player, MissionID) => { if (MissionID == 2) { jobVeh[jobVehId] = mp.vehicles.new(mp.game.joaat("ambulance"), new mp.Vector3(-487.798, -252.667, 35.454)); setTimeout(() => { jobVeh[jobVehId].setDoorOpen(1, true, false); jobVeh[jobVehId].setSiren(true); }, 200); } mp.console.logWarning(`Mission Nummer: ${MissionID}`, true, true); mp.console.logWarning(`jobVehId: ${jobVehId}`, true, true); mp.console.logWarning(`jobVeh Length: ${jobVeh.length}`, true, true); }); mp.events.add('removeJobBlips', (player) => { jobBlips.forEach(function (object, index) { jobBlips[index].destroy(); }); jobMarker.forEach(function (object, index) { jobMarker[index].destroy(); }); jobVeh.forEach(function (object, index) { jobVeh[index].destroy(); }); jobBlips = null; jobBlips = new Array(); jobMarker = null; jobMarker = new Array(); jobVeh = null; jobVeh = new Array(); }); https://prnt.sc/FrKPaR0cr6lF This is the Debug i did idk if i think wrong^^ iam sorry for so much Question i come from SAMP there was PAWN the Language it was way Simpler
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