Kaz Posted June 8, 2012 Share Posted June 8, 2012 First of all, hi I'm having problems "scripting" (if can be called like that) my peds. I have a "peds.lua" file in my map file and the proper meta.xml My problem is that some peds doesn't look where I want (North = 0º) but other peds are looking good. This is the code of the bugged peds local af = createPed ( 287, 236.89999389648, 1970.6999511719, 18,800000, 0 ) local af1 = createPed ( 287, 237.89999389648, 1970.6999511719, 18,800000, 0 ) local af2= createPed ( 287, 238.89999389648, 1970.6999511719, 18,800000, 0 ) local af3 = createPed ( 287, 239.89999389648, 1970.6999511719, 18,800000, 0 ) Instead of facing the north, they face the west. This is the code of the good peds local Staff2 = createPed ( 217, 1534.6999511719, -1526.5999755859, 22.80000038147, 88 ) local Staff3 = createPed ( 211, 1535.4000244141, -1523.0999755859, 22.80000038147, 288 ) local Staff4 = createPed ( 217, 1547.4000244141, -1536.0999755859, 22.80000038147, 258 ) local Staff5 = createPed ( 217, 1471.8000488281, -1519, 22.80000038147, 4 ) Whats different between one code and the other? From now, thanks Link to comment
Al3grab Posted June 8, 2012 Share Posted June 8, 2012 you will need to change the rotation : ped createPed ( int modelid, float x, float y, float z [size=6][, float rot = 0.0 ][/size] ) Link to comment
myonlake Posted June 8, 2012 Share Posted June 8, 2012 As long as I am concerned, GTA peds point at north as they spawn. Link to comment
Axel Posted June 8, 2012 Share Posted June 8, 2012 I think he means looking at a point. Well there is a function https://wiki.multitheftauto.com/wiki/SetPedLookAt I suggest using it to look at getLocalPlayer() function setLook() local x,y,z = getElementPosition(getLocalPlayer()) for i,v in ipairs(getElementsByType("ped")) do setPedLookAt(v,x,y,z,-1,getLocalPlayer()) end end addEventHandler("onResourceStart",getRootElement(),setLook) addEventHandler("onClientRender",getRootElement(),setLook) Note: It is not synced as it is clientside if there is 2 players they will see the ped looking at them. Link to comment
micheal1230 Posted June 8, 2012 Share Posted June 8, 2012 You Could Use setElementRotation Link to comment
Kaz Posted June 8, 2012 Author Share Posted June 8, 2012 You Could Use setElementRotation In the console says peds.lua:70: Bad argument @ 'setElementRotation' I tryied this setElementRotation (af, true) this setElementRotation (af, 0, true) and this setElementRotation (af, 0) What im doing wrong? I think he means looking at a point. Well there is a functionhttps://wiki.multitheftauto.com/wiki/SetPedLookAt I suggest using it to look at getLocalPlayer() function setLook() local x,y,z = getElementPosition(getLocalPlayer()) for i,v in ipairs(getElementsByType("ped")) do setPedLookAt(v,x,y,z,-1,getLocalPlayer()) end end addEventHandler("onResourceStart",getRootElement(),setLook) addEventHandler("onClientRender",getRootElement(),setLook) Note: It is not synced as it is clientside if there is 2 players they will see the ped looking at them. No, im not asking that, infact im asking how to rotate them. Thanks for the help anyway I did this SS wich I think can help to understand http://imageshack.us/photo/my-images/83 ... 62944.png/ http://imageshack.us/photo/my-images/51 ... 62956.png/ (For a strange reason I couldn't use the [*img] tag) Link to comment
Vision Posted June 8, 2012 Share Posted June 8, 2012 Try this setElementRotation(af,0,0,0) Link to comment
myonlake Posted June 8, 2012 Share Posted June 8, 2012 No... use the below function, it's meant for it. setElementRotation and setPedRotation has a huge difference. setPedRotation Link to comment
Axel Posted June 8, 2012 Share Posted June 8, 2012 https://wiki.multitheftauto.com/wiki/SetPedRotation local af = createPed ( 287, 236.89999389648, 1970.6999511719, 18,800000, 0 ) setPedRotation(af, 360) -- change 360 however you want to Link to comment
myonlake Posted June 8, 2012 Share Posted June 8, 2012 Learn maths, whoever started this thread. 0 degrees = no change 90 degrees = 3/4 of a full rotation 180 degrees = 2/4 of a full rotation -90 degrees = 1/4 of a full rotation 360 degrees = no change Find "circle 2d" on Google and you'll see the scale. Link to comment
Kaz Posted June 8, 2012 Author Share Posted June 8, 2012 https://wiki.multitheftauto.com/wiki/SetPedRotation local af = createPed ( 287, 236.89999389648, 1970.6999511719, 18,800000, 0 ) setPedRotation(af, 360) -- change 360 however you want to This helped me. Thank you and all who helped. Im glad to see ppl helping others in them problems Link to comment
Tete omar Posted June 9, 2012 Share Posted June 9, 2012 Try this function CreateMyPed ( ARMY ) local af = createPed ( 287, 236.89999389648, 1970.6999511719, 18,800000 ) local af1 = createPed ( 287, 237.89999389648, 1970.6999511719, 18,800000 ) local af2= createPed ( 287, 238.89999389648, 1970.6999511719, 18,800000 ) local af3 = createPed ( 287, 239.89999389648, 1970.6999511719, 18,800000 ) addEventHandler ( "onResourceStart", getResourceRootElement(), CreateMyPed ) Link to comment
myonlake Posted June 9, 2012 Share Posted June 9, 2012 Try this function CreateMyPed ( ARMY ) local af = createPed ( 287, 236.89999389648, 1970.6999511719, 18,800000 ) local af1 = createPed ( 287, 237.89999389648, 1970.6999511719, 18,800000 ) local af2= createPed ( 287, 238.89999389648, 1970.6999511719, 18,800000 ) local af3 = createPed ( 287, 239.89999389648, 1970.6999511719, 18,800000 ) addEventHandler ( "onResourceStart", getResourceRootElement(), CreateMyPed ) Wrong. addEventHandler("onResourceStart", resourceRoot, function() af = createPed(287, 236.89, 1970.69, 18.80) af1 = createPed(287, 237.89, 1970.69, 18.80) af2 = createPed(287, 238.89, 1970.69, 18.80) af3 = createPed(287, 239.89, 1970.69, 18.80) end ) Link to comment
albers14 Posted June 9, 2012 Share Posted June 9, 2012 Learn maths, whoever started this thread.0 degrees = no change 90 degrees = 3/4 of a full rotation 180 degrees = 2/4 of a full rotation -90 degrees = 1/4 of a full rotation 360 degrees = no change Find "circle 2d" on Google and you'll see the scale. Its called 270 anyways. Link to comment
Guest Guest4401 Posted June 9, 2012 Share Posted June 9, 2012 (edited) Learn maths, whoever started this thread.0 degrees = no change 90 degrees = 3/4 of a full rotation 180 degrees = 2/4 of a full rotation -90 degrees = 1/4 of a full rotation 360 degrees = no change Find "circle 2d" on Google and you'll see the scale. Its called 270 anyways. Edited June 9, 2012 by Guest4401 Link to comment
myonlake Posted June 9, 2012 Share Posted June 9, 2012 Exactly, and I prefer to use -90. Link to comment
Moderators IIYAMA Posted June 11, 2012 Moderators Share Posted June 11, 2012 I love it To set degrees in negative value. It is much easier and you can also use it, when you want a map being symmetrical. I recommend you to use it. 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