BieHDC Posted August 15, 2013 Share Posted August 15, 2013 How to attach a trailer to an existing vehicle with attachTrailerToVehicle for Race gamemode? Is now written in wiki Link to comment
isa_Khamdan Posted August 15, 2013 Share Posted August 15, 2013 Check this attachElements [url=https://wiki.multitheftauto.com/wiki/AttachElements]https://wiki.multitheftauto.com/wiki/AttachElements[/url] Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 You can use attackTrailerToVehicle. The trailer is NOT being created the same time as the vehicle the player is in. So you can do something like this; function attach( thePlayer ) local v = getPedOccupiedVehicle( thePlayer ); local x, y, z = getElementPosition ( thePlayer ); local theTrailer = createVehicle ( , x, y, z+15 ); AttachTrailerToVehicle ( v, theTrailer ); end Trigger the event at the position in your race gamemode where the players are getting warped into their vehicle's. Dont forget to give the player as a parameter. Link to comment
BieHDC Posted August 15, 2013 Author Share Posted August 15, 2013 Ok as event handler can i use onGamemodeMapStart? And what you mean with give player as a parameter? I will first try out with command handler Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 Well, the race gamemode has a start too. I know its hard to believe, mind = blown. But it does have a start. Where everone gets spawned and received a vehicle. At that point, add a trigger to my command with a parameter or the player, because I'm not sure if the player is one of the following; source localPlayer getLocalPlayer() thePlayer Or any costum made one, so just add a trigger to the function like so; triggerEvent("attach", , ); Link to comment
BieHDC Posted August 15, 2013 Author Share Posted August 15, 2013 doesnt work 5: argoment 5 got none 6: nil value i think i dont get z pos function attach( thePlayer ) local thePlayer = getLocalPlayer() local v = getPedOccupiedVehicle( thePlayer ); local x, y, z = getElementPosition( thePlayer ); local theTrailer = createVehicle( 450, x, y, z+15 ); --+15 AttachTrailerToVehicle( v, theTrailer ); end addCommandHandler("attc", attach) Link to comment
xXMADEXx Posted August 15, 2013 Share Posted August 15, 2013 try: ((Not tested)) function attach( thePlayer ) local v = getPedOccupiedVehicle( localPlayer); local x, y, z = getElementPosition( localPlayer); local theTrailer = createVehicle( 450, x, y, z+15 ); --+15 attachTrailerToVehicle( v, theTrailer ); end addCommandHandler("attc", attach) Please remember, Lua is very case-sensitive. Link to comment
BieHDC Posted August 15, 2013 Author Share Posted August 15, 2013 4: arg 5 none 5: arg 2 got boolean Link to comment
Castillo Posted August 15, 2013 Share Posted August 15, 2013 Rotation arguments are optional, I don't see why it would say that. Link to comment
BieHDC Posted August 15, 2013 Author Share Posted August 15, 2013 is thePlayer defined? Link to comment
Castillo Posted August 15, 2013 Share Posted August 15, 2013 This is a server side script? if so, then "localPlayer" should be "thePlayer". function attach ( thePlayer ) local v = getPedOccupiedVehicle ( thePlayer ); local x, y, z = getElementPosition ( thePlayer ); local theTrailer = createVehicle ( 450, x, y, z+15 ); --+15 attachTrailerToVehicle ( v, theTrailer ); end addCommandHandler ( "attc", attach ) Link to comment
BieHDC Posted August 15, 2013 Author Share Posted August 15, 2013 its clientside now but would be server better? and renember, this will get an event handler later for a race map Link to comment
Castillo Posted August 15, 2013 Share Posted August 15, 2013 Well, if you make it client side, nobody will see it but the one that used the command. Link to comment
BieHDC Posted August 15, 2013 Author Share Posted August 15, 2013 ok thx i will try later going to sleep now^ Link to comment
BieHDC Posted August 17, 2013 Author Share Posted August 17, 2013 It works, but only if the truck dont look to south. Its so if the truck looks to north, east or west if get connected, but if it looks to south if dont work, because it would be "on" the vehicle. So the truck has to have the same rotation as the trailer. You understand? i will try to include rotation and if it doesnt work i will post it in here edit: i dont thought to get it work on the first try^i am getting better in scripting yey ^^ here is the code and i will it also release in community^should i add your credits? --serverside function attach ( thePlayer ) local v = getPedOccupiedVehicle ( thePlayer ); local x, y, z = getElementPosition ( thePlayer ); local ra, rb, rc = getElementRotation ( thePlayer ); local theTrailer = createVehicle ( 450, x, y, z+15, ra, rb, rc ); attachTrailerToVehicle ( v, theTrailer ); end addCommandHandler ( "attc", attach ) edit2: only one thing cant be fixed because there is no check if a trailor is already attached, but only set the createVehicle from +15 to -9999 or somewhere it never would be find^ 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