subenji99 Posted March 26, 2009 Share Posted March 26, 2009 We were playing with ped functions on my test server today and some functions were missing that we could really have used. 1. allow Weapon functions for peds. I found it incredible that "setPedWeaponSlot" exists, but weapon functions such as "giveWeapon" only work on players! i assume this is actually an oversight, or there is another method i overlooked. 2. setPedRotateAt This is what I expected "setPedLookAt" to do,but that only moves the ped's head - not particularly useful. I ended up attempting some complex vector maths to work out the rotation angle to get a created ped to face my player - and failed. While the ultimate ped functions I would like would be to set a ped's "task", even just the simple primary and/or secondary if complex tasks are not possible, these few functions would help out quite a bit for anyone coding with peds in my opinion. Link to comment
darkdreamingdan Posted March 26, 2009 Share Posted March 26, 2009 The main issue right now is that peds are unable to use weapons at all. Giving peds weapons has limited use as a result. Its something that we hope to resolve in 1.0.1 latest (may be done for 1.0) as it does cripple ped's functionality somewhat. Link to comment
Lordy Posted March 27, 2009 Share Posted March 27, 2009 2. setPedRotateAt This is what I expected "setPedLookAt" to do,but that only moves the ped's head - not particularly useful. I ended up attempting some complex vector maths to work out the rotation angle to get a created ped to face my player - and failed. You could use arctan for getting the angle. Something like this I guess, if I mess up, don't blame me, technically I've not learned this in school yet. (tan alpha was a/b right?) local x1, y1,_ = getElementPosition(thePlayer) local x2,y2,_ = getElementPosition(thePed) local xdist, ydist = = x1 - x2, y1 - y2 local theRot = math.atan(xdist/ydist) setPedRotation(thePed, theRot) Now if someone finds something wrong, please correct me Link to comment
Slothman Posted March 27, 2009 Share Posted March 27, 2009 heres a bit of code i ripped off of an old script by erorr404. this sounds like what you need. local targetx, targety, targetz = getElementPosition ( yourtarget ) local pedx, pedy, pedz = getElementPosition ( theped ) newangle = ( 360 - math.deg ( math.atan2 ( ( targetx - pedx ), ( targety - pedy ) ) ) ) % 360 as far as i know, its witchcraft, so dont ask me to explain how it works, but it does Link to comment
50p Posted March 27, 2009 Share Posted March 27, 2009 Take a look here: https://community.multitheftauto.com/index.php?p= ... ils&id=234 Link to comment
Slothman Posted April 2, 2009 Share Posted April 2, 2009 thats actually pretty nice 50p, dont suppose youd mind people using some of that if they give you credit? Link to comment
50p Posted April 3, 2009 Share Posted April 3, 2009 thats actually pretty nice 50p, dont suppose youd mind people using some of that if they give you credit? OK. Also, updated description with a link to video. 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