Jump to content

Big problem with setPedControlState and giveWeapon !


Recommended Posts

Hi, I have this code:

It's in onClientPlayerRender:

  
    if (Created == 0) then 
        x,y,z = getElementPosition(getLocalPlayer()) 
        x1, y1, z1 = -2816.4443,-1523.5574,140.8438 
    end 
    if (getDistanceBetweenPoints3D(x,y,z, x1, y1, z1) < 3.0) and (Created == 0) then 
        Created = 1 
        zombangle = ( 360 - math.deg ( math.atan2 ( ( x - x1 ), ( y - y1 ) ) ) ) % 360 
        ped = createPed(0, x1, y1, z1, zombangle) 
        setPedControlState(ped, "fire", true) 
        callServerFunction("giveWeapon", ped, 9, 9999, true) 
        setTimer(check, 1000, 0) 
        setPedHeadless(ped, true) 
    end 
  

and timer function:

function check() 
    local x,y,z = getElementPosition(getLocalPlayer()) 
    local x1, y1, z1 = -2816.4443,-1523.5574,140.8438 
    if (getDistanceBetweenPoints3D(x,y,z, x1, y1, z1) < 3.0) then 
        zombangle = ( 360 - math.deg ( math.atan2 ( ( x - x1 ), ( y - y1 ) ) ) ) % 360  
        setPedRotation(ped, zombangle) 
        setPedControlState(ped, "fire", true) 
  
    end 
end 

And on spawns bot, setPedControlState works perfectly, but in function "check" doesn't work :( And "giveWeapon" doesn't work also... But in function check, setPedRotation works perfectly...

Please help me

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