Sign in to follow this  
kevincouto6

Ped Atack

Recommended Posts

Hello, I would like to tell you some other tip, I think it is not working because I am specifying only the location of the player, but if I use the location of the ped of "a nill value", and the same thing is happening with just the location player

thePed = createPed(104, -2406.92749, -593.24597, 132.64844)

function onPedRender() 
	local x ,y, z = getElementPosition(thePed) 
	local sx, sy, sz = getElementPosition(localPlayer)
	local Dist = getDistanceBetweenPoints3D (x, y, z, sx, sy, sz)
				givePedWeapon(thePed, 31, 5000, true)
  				setElementFrozen( thePed, true)
				setPedControlState(thePed, "fire", true)
				setPedAimTarget(thePed, sx, sy, sz) 		
				setPedRotation(thePed, findRotation(x , y))
end
addEventHandler("onClientRender", root, onPedRender) 
addEventHandler("onClientPedDamage", root, onPedRender) 

Line 11 error " a nill value"

Share this post


Link to post

Tons of things wrong with this. For a starter you're calling the onPedRender function every frame without any kind of checks to see if "thePed" exists, or if he already has the weapon which you're trying to give him - that's extremely bad practice.

Also, where is this "findRotation" function? You haven't included in the code.

In future please provide the full error, I highly doubt it was just "a nil value". That helps no one.

Share this post


Link to post
On 22/06/2018 at 18:35, LopSided_ said:

Tons of things wrong with this. For a starter you're calling the onPedRender function every frame without any kind of checks to see if "thePed" exists, or if he already has the weapon which you're trying to give him - that's extremely bad practice.

Also, where is this "findRotation" function? You haven't included in the code.

In future please provide the full error, I highly doubt it was just "a nil value". That helps no one.

could you help me with the script I'm not very good at scripting I'm learning

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.