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