Xwad Posted October 27, 2016 Share Posted October 27, 2016 Is it possible to set the players position inside a vehicle? I tried it bit nothing happened Link to comment
iPrestege Posted October 27, 2016 Share Posted October 27, 2016 You mean the seat in the vehicle? You can use this optional argument : seat: An integer representing the seat ID. 0 represents the driver, any higher represent passenger seats. For warpPedIntoVehicle Link to comment
Xwad Posted October 27, 2016 Author Share Posted October 27, 2016 (edited) No, i mean the x y z position:D Edited October 27, 2016 by Xwad Link to comment
iPrestege Posted October 27, 2016 Share Posted October 27, 2016 Why you want to put the player position inside the vehicle for what? because i'm not sure it's possible but there's another way to do it like this maybe are you trying to do something like this? it's a ped inside the vehicle with a camera view : I've used : setElementCollidableWith @Xwad Link to comment
Xwad Posted October 27, 2016 Author Share Posted October 27, 2016 No, i mean setting the x,y,z position. Gor example: I enter in a vehicle and set the z position of the player +10. Then the player will not inside the vehicle anymore, because its on the top of the vehicle. But it can still drive the car untin he exit from the car. Link to comment
GTX Posted October 27, 2016 Share Posted October 27, 2016 (edited) I don't think that's possible but you can do a workaround: Create a ped (dummy) and attach it on the vehicle with specific offset (so in your case, Z => 10) and set its animation to be like he's sitting in a car or whatever you'd like. Next, set your alpha to 0 and you're done. I can do an example, but not now. Functions/events would be: createPed setElementAlpha attachElements "onVehicleExit" "onVehicleEnter" Edited October 27, 2016 by GTX Added functions 1 Link to comment
GTX Posted October 27, 2016 Share Posted October 27, 2016 (edited) Because I can't edit my post (This) (I didn't test this example, but it should work): -- Server side script local g_Offset = {0,0,2} -- Your offset (How far from vehicle it should be) (X, Y, Z) local lPeds = {} -- Here we store peds of players function onEnter(lPlayer) local lVehicleX, lVehicleY, lVehicleZ = getElementPosition(source) -- Get vehicle's position lPeds[lPlayer] = createPed(getElementModel(lPlayer),lVehicleX,lVehicleY,lVehicleZ) -- Create our dummy attachElements(lPeds[lPlayer],source,g_Offset[1],g_Offset[2],g_Offset[3]) -- Attach our dummy to the car with offset -- You can set your own animation here setPedAnimation(lPeds[lPlayer],"car","sit_relaxed") -- Set our dummy's animation setElementAlpha(lPlayer,0) -- Hide us end addEventHandler("onVehicleEnter",root,onEnter) -- When player sits in the car function onStartExit(lPlayer) setElementAlpha(lPlayer,255) -- Set alpha back destroyElement(lPeds[lPlayer]) -- Destroy our dummy end addEventHandler("onVehicleStartExit",root,onStartExit) -- When you press to exit the car You can edit the script however you want. Edited October 27, 2016 by GTX Fixed typo Link to comment
Xwad Posted October 29, 2016 Author Share Posted October 29, 2016 yes, it worked , thanks:) 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