Jump to content

Please help in ped scripting error!!


danglong

Recommended Posts

I have just done my scripting to spawn ped, give ped weapon and set ped target. How ever it have problem.

My string:

 local x, y, z = 1700.55, -1500.46, 10 
function taoPed() 
local x,y,z = getElementPosition ( thePlayer ) 
x = x + math.random ( 5, 10 ) 
y = y + math.random ( 5, 10 ) 
z = z + math.random ( 5, 10 ) 
local pedVn = createPed (29,x,y,z) 
if ( pedVn == true ) then 
giveweapon ( pedVn, 38, 1000 ) 
end 
end 
addEventHandler ( "onResourceStart", getRootElement(), taoPed ) 
function pedTarget() 
if ( taoPed ) then 
setPedTarget ( pedVn, thePlayer ) 
setPedControlState ( pedVn, forwards, true ) 
setPedControlState ( pedVn, fire, true ) 
end 
if ( getElementPosition ( thePlayer ) == getElementPosition ( pedVn ) ) then 
setPedControlState ( pedVn, forwards, false ) 
end 
end 
addEventHandler ( "onResourceStart", getRootElement(), pedTarget ) 
  

scripting team please help me :(

Link to comment
     local x, y, z = 1700.55, -1500.46, 10 
    function taoPed() 
    local x,y,z = getElementPosition ( thePlayer ) 
    x = x + math.random ( 5, 10 ) 
    y = y + math.random ( 5, 10 ) 
    z = z + math.random ( 5, 10 ) 
    local pedVn = createPed (29,x,y,z) 
    if ( pedVn == true ) then 
    giveWeapon ( pedVn, 38, 1000 ) 
    end 
    end 
    addEventHandler ( "onResourceStart", getRootElement(), taoPed ) 
    function pedTarget() 
    if ( taoPed ) then 
    setPedTarget ( pedVn, thePlayer ) 
    setPedControlState ( pedVn, forwards, true ) 
    setPedControlState ( pedVn, fire, true ) 
    end 
    if ( getElementPosition ( thePlayer ) == getElementPosition ( pedVn ) ) then 
    setPedControlState ( pedVn, forwards, false ) 
    end 
    end 
    addEventHandler ( "onResourceStart", getRootElement(), pedTarget ) 

Link to comment

I finally change the function to this, but Ped still not spawn, what happen? It could run without error, but no ped spawn

local x, y, z = 1700.55, -1500.46, 10

function taoPed()

local x,y,z = getElementPosition ( source )

x = x + math.random ( 5, 10 )

y = y + math.random ( 5, 10 )

local pedVn = createPed (90,x,y,z)

if ( pedVn == true ) then

setTimer ( pedWeapon , 2500)

setTimer ( taoPed, 2500, 1000)

end

end

addEventHandler ( "onResourceStart", resourceRoot, taoPed)

function pedWeapon()

if ( taoPed ) then

giveWeapon ( pedVn, 38, 1000, true )

setPedRotation( pedVn, 60)

end

end

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