Jump to content

Peds doesn't look where I want


Kaz

Recommended Posts

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

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
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 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.

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

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

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
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
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
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.

AYkiT.png

Edited by Guest4401
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...