Jump to content

[help] ped follows


Recommended Posts

Alright ... i see

server:

    ped = createPed ( 248, 0, 0, 5 ) 
    triggerClientEvent ( root, "onControlState", ped ) 

client:

    addEvent ( "onControlState", true ) 
    addEventHandler ( "onControlState", root, function () 
    setPedControlState ( source, "fire", true ) 
    end ) 
      

i tried it but got error:

server trigger clientside event onControlState,but event is not added clientside  

whatever why you suggested me to do "attachElement"?

Link to comment

Example:

ped = createPed(0, getElementPosition(localPlayer)) 
  
addEventHandler("onClientRender", root, 
function() 
    local x, y, z = getElementPosition(localPlayer) 
    local tx, ty, tz = getElementPosition(ped) 
    local dis = getDistanceBetweenPoints2D(x, y, tx, ty) 
    if dis > 2 then 
        setPedControlState(ped, "forwards", true) 
    else 
        setPedControlState(ped, "forwards", false) 
    end 
    setPedRotation(ped, findRotation(tx, ty, x, y)) 
end) 
  
function findRotation(x1,y1,x2,y2) 
    local t = -math.deg(math.atan2(x2-x1,y2-y1)) 
    if t < 0 then t = t + 360 end 
    return t 
end 

Link to comment

Example:

ped = createPed(0, getElementPosition(localPlayer)) 
  
addEventHandler("onClientRender", root, 
function() 
    local x, y, z = getElementPosition(localPlayer) 
    local tx, ty, tz = getElementPosition(ped) 
    local dis = getDistanceBetweenPoints2D(x, y, tx, ty) 
    if dis > 2 then 
        setPedControlState(ped, "forwards", true) 
    else 
        setPedControlState(ped, "forwards", false) 
    end 
    setPedRotation(ped, findRotation(tx, ty, x, y)) 
end) 
  
function findRotation(x1,y1,x2,y2) 
    local t = -math.deg(math.atan2(x2-x1,y2-y1)) 
    if t < 0 then t = t + 360 end 
    return t 
end 

Thanks but i think i will use slothbot :D anyway THANKS A LOT!

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