danglong Posted December 6, 2012 Share Posted December 6, 2012 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
AhmadQTR Posted December 6, 2012 Share Posted December 6, 2012 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
danglong Posted December 6, 2012 Author Share Posted December 6, 2012 Thank for help, but It still get trouble, the server say:" bad Argument GetElementPosition" ??? "error in attemp x (boolean value) Link to comment
Renkon Posted December 6, 2012 Share Posted December 6, 2012 Firsto f all, you are mixing client and server-side functions. Secondly: thePlayer is NOT defined. And Source, in onResourceStart is the resourcename. My recommendation is that I'd rather you used resourceRoot than getRootElement. Link to comment
danglong Posted December 6, 2012 Author Share Posted December 6, 2012 thePlayer is source? do i need to define it? thank for help, I am new bie, setPedControlState is client script. I see Link to comment
danglong Posted December 6, 2012 Author Share Posted December 6, 2012 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
DiSaMe Posted December 6, 2012 Share Posted December 6, 2012 You're trying to get the position of source, which is the root element of the resource. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now