DarkLink Posted June 17, 2012 Posted June 17, 2012 Hi there guys, I read something by 50p on another post on how to do this.. and from what I understood on that day, I would need to use onClientPreRender, and setElementPosition and setElementRotation on the handler function of the event... So I made this: local object function pickweed() local x,y,z = getElementPosition(getLocalPlayer()) local xr,yr,zr = getElementRotation(getLocalPlayer()) object = createObject (1578, x,y-0.0999755859,z+0.300000191) setElementRotation(object, xr, yr+82, zr+270) addEventHandler ( "onClientPreRender", getRootElement(), updateObjectCoords) end addCommandHandler ("pick", pickweed ) function updateObjectCoords() local x,y,z = getElementPosition(getLocalPlayer()) local xr,yr,zr = getElementRotation(getLocalPlayer()) setElementPosition(object, x,y-0.0999755859,z+0.300000191) setElementRotation(object, xr, yr+82, zr+270) end And I guess its fine, but the camera changes gets ZOOMED alot... I dont know why I tryed to change camera with "V" key and nothing ... Thanks alot in advance guys ! Borderpatrol Project Gamemode - Under Development (80%)
DiSaMe Posted June 17, 2012 Posted June 17, 2012 I think that's because it has collision which camera cannot go though. Try disabling the collision of object: setElementCollisionsEnabled -
ahdon Posted June 17, 2012 Posted June 17, 2012 function pickweed() local x,y,z = getElementPosition(localPlayer) local xr,yr,zr = getElementRotation(localPlayer) object = createObject (1578, x,y-0.0999755859,z+0.300000191) setElementRotation(object, xr, yr+82, zr+270) addEventHandler("onClientPreRender",root,updateObjectCoords) end addCommandHandler ("pick", pickweed ) function updateObjectCoords() local x,y,z = getElementPosition(localPlayer) local xr,yr,zr = getElementRotation(localPlayer) setElementPosition(object, x,y-0.0999755859,z+0.300000191) setElementRotation(object, xr, yr+82, zr+270) setElementCollisionsEnabled(object, false) end "People who think they know everything are annoying to those of us who do"
DarkLink Posted June 17, 2012 Author Posted June 17, 2012 Thanks alot mate, u seem like a boss Problem solved ! Borderpatrol Project Gamemode - Under Development (80%)
50p Posted June 18, 2012 Posted June 18, 2012 function pickweed() local x,y,z = getElementPosition(localPlayer) local xr,yr,zr = getElementRotation(localPlayer) object = createObject (1578, x,y-0.0999755859,z+0.300000191) setElementRotation(object, xr, yr+82, zr+270) addEventHandler("onClientPreRender",root,updateObjectCoords) end addCommandHandler ("pick", pickweed ) function updateObjectCoords() local x,y,z = getElementPosition(localPlayer) local xr,yr,zr = getElementRotation(localPlayer) setElementPosition(object, x,y-0.0999755859,z+0.300000191) setElementRotation(object, xr, yr+82, zr+270) setElementCollisionsEnabled(object, false) end You don't have to do it on every frame. Just disable collision after creating the object. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
DNL291 Posted June 18, 2012 Posted June 18, 2012 You want attach an object on the back of player? if yes just use the function attachElements() Please do not PM me with scripting related question nor support, use the forums instead.
DarkLink Posted June 18, 2012 Author Posted June 18, 2012 Okay thanks alot mate, got it fixed Borderpatrol Project Gamemode - Under Development (80%)
DiSaMe Posted June 18, 2012 Posted June 18, 2012 Or even better, attach it using bone attachments resource from here or here and it will move and rotate with the body part which it is attached to. -
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