micsko17 Posted May 21, 2020 Posted May 21, 2020 mp.events.addCommand("veh", (player, text) => { if (text == undefined) { let veh = mp.vehicles.new(mp.joaat("T20"), player.position); player.putIntoVehicle(veh, -1); } else { let veh = mp.vehicles.new(mp.joaat(text), player.position); player.putIntoVehicle(veh, -1); } }); I am using this simple script. When I execute veh command it creates the vehicle, but the player is not inside.
[BC]VACEDA[NWD] Posted May 21, 2020 Posted May 21, 2020 (edited) this does not work for servers with more than 1 player, try this: mp.events.addCommand("veh", (player, text) => { if (text == undefined) { player.veh = mp.vehicles.new(mp.joaat("T20"), player.position); player.putIntoVehicle(player.veh, -1); } else { player.veh = mp.vehicles.new(mp.joaat(text), player.position); player.putIntoVehicle(player.veh, -1); } }); Edited May 21, 2020 by [BC]VACEDA[NWD]
micsko17 Posted May 21, 2020 Author Posted May 21, 2020 (edited) 41 minutes ago, [BC]VACEDA[NWD] said: this does not work for servers with more than 1 player, try this: mp.events.addCommand("veh", (player, text) => { if (text == undefined) { player.veh = mp.vehicles.new(mp.joaat("T20"), player.position); player.putIntoVehicle(player.veh, -1); } else { player.veh = mp.vehicles.new(mp.joaat(text), player.position); player.putIntoVehicle(player.veh, -1); } }); Thanks for Quick reply. Will try tomorrow. I also noted that once I entered the same type of car the code worked at the following run. for example: I run: /veh luxor - wont put me inside, but I do manually get in. then I run /veh luxor again and it works Edited May 21, 2020 by micsko17
Division Posted May 21, 2020 Posted May 21, 2020 vor 9 Minuten schrieb micsko17: Thanks for Quick reply. Will try tomorrow. I also noted that once I entered the same type of car the code worked at the following run. for example: I run: /veh luxor - wont put me inside, but I do manually get in. then I run /veh luxor again and it works You using 1.1? It's a known bug
micsko17 Posted May 22, 2020 Author Posted May 22, 2020 A person in discord suggested me doing this and it works for now: setTimeout( () => { player.putIntoVehicle(veh, seat); }, 200);
Nutter Posted May 22, 2020 Posted May 22, 2020 I'm using the following code so I don't have to wrap the call in a timer everytime I want to put a player in a vehicle. It's not all my code, was inspired by the search bar on the RAGE:MP discord server. const putIntoVehicleKey = Symbol('putIntoVehicle'); mp.events.add('entityCreated', entity => { if (entity.type !== 'player') { return; } entity[putIntoVehicleKey] = entity.putIntoVehicle; entity.putIntoVehicle = (vehicle, seat) => { setTimeout(() => { entity[putIntoVehicleKey](vehicle, seat); }, 200); }; });
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