Jump to content

[help] Shooter Kill Detector


Miyuru

Recommended Posts

function cdoshoot()
	if bindTrigger == 1 then
		if not isPedDead(cLP) then
			bindTrigger = 0
			local x,y,z = getElementPosition(theVehicle)
			local rX,rY,rZ = getElementRotation(theVehicle)
			local x = x+4*math.cos(math.rad(rZ+90))
			local y = y+4*math.sin(math.rad(rZ+90))
			createProjectile(theVehicle, 19, x, y, z, 1.0, nil)
			setTimer(allowShoots, 3000, 1)
		end
	end
end

This is my shooting script.

And I want to detect player 

onPlayerWasted

and repair him and give money!

Thank you.

Edited by Miyuru
Link to comment

Can you explain a bit more what the script does and maybe share the entire script? For example, I see a function called allowshoots being called but no function in the code. Are you trying to give the player that shot money, or the player that got killed? If the player got killed, it might be better to give the money upon onPlayerSpawn

The quick answer is you could add something like this:

addEventHandler(‘onPlayerWasted’, getRootElement(),

function(attacker)

if attacker == (some check here if it is a projectile) then

setElementHealth(source,100)
givePlayerMoney(source,100)

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