Jump to content

One hit Kill when hydra attacks other hydra


Recommended Posts

-- client
explosiveWeaponIDS = { 
[ 51 ] = true,
[ 19 ] = true,
[ 50 ] = true,
}

function check(attacker, weapon)
local theVehicle = getPedOccupiedVehicle ( localPlayer ) 
if theVehicle then
local id = getElementModel ( theVehicle )
if id = 520 then
 triggerServerEvent ( "onVehicleKill", resourceRoot, attacker )
else
end
end
addEventHandler ( "onClientVehicleDamage", root, check )

-- server

function killPlaya(attacker)
    local hisVehicle = getPedOccupiedVehicle(source)
    killPed(source, attacker, 49)
    blowVehicle(hisVehicle)
end
addEvent( "onVehicleKill", true )
addEventHandler( "onVehicleKill", root, killPlaya )

  
  
  

hello ,  i am working on a script in which destroys hydra from one hit and and get the right kill mesaage , can  someone tell me whats wrong :) and sorry if there are mistakes , i am new to scripting 

Link to comment

From my understanding, your script basically kills the attacker when he hits an hydra because you set the triggerServerEvent element to attacker, whereas it should be source because the event is triggered when a vehicle gets damaged. By changing your "attacker" at line 13 to "source", the event should trigger for the person being hit, and not the opposite.

But what you should also fix is that by the way your script is, it triggers by any type of damage, as you don't use the explosiveWeaponIDS table at all.

Edited by Galactix
  • Thanks 1
Link to comment
13 minutes ago, TheGrimReaper said:

thanks alot bro , appreciate your help

@Galactix

i have tried that man but no difference :(

can u show me in script form if possible

I would gladly provide you a working script but unfortunately I wouldn't be able to test it as a second player is required for that. All I can say is that you need to make a if statement that includes your table and would make the event trigger when a player is piloting an hydra and gets hit by one of the 3 explosive id from the table which would then trigger the kill function.

  • Thanks 1
Link to comment

Try this

-- client
explosiveWeaponIDS = { 
	[ 51 ] = true,
	[ 19 ] = true,
	[ 50 ] = true,
}

function check(attacker, weapon)
	local theVehicle = getPedOccupiedVehicle ( localPlayer ) 
	if theVehicle then
		local id = getElementModel ( theVehicle )
		if id == 520 and explosiveWeaponIDS[weapon] then
		 	triggerServerEvent ( "onVehicleKill", localPlayer, attacker, weapon )
		end
	end
end
addEventHandler ( "onClientVehicleDamage", root, check )

-- server

function killPlaya(attacker,weapon)
    local hisVehicle = getPedOccupiedVehicle(source)
    killPed(source, attacker, weapon)
    blowVehicle(hisVehicle)
end
addEvent( "onVehicleKill", true )
addEventHandler( "onVehicleKill", root, killPlaya )

 

  • Thanks 1
Link to comment

Oh my bad... I forgot that triggers for everyone who is streamed in.

function check(attacker, weapon)
    local theVehicle = getPedOccupiedVehicle ( localPlayer ) 
    if theVehicle and source == theVehicle then
        local id = getElementModel ( theVehicle )
        if id == 520 and explosiveWeaponIDS[weapon] then
            triggerServerEvent ( "onVehicleKill", localPlayer, attacker, weapon )
        end
    end
end
addEventHandler ( "onClientVehicleDamage", root, check )

 

Link to comment

@Mr.Loki last question , sorry for this , i know this might be a bit annoying, is there a way which i can make the script trigger just once for each player , right now when u hit with double missles u get dual kills , and also when rammed by another hydra the player dies :( 

and again sorry for so many questions xD 

Link to comment

In the first killPlaya func use the isPedDead function to check if the player is dead so it wont trigger again

and you will want to only use 19 in the explosiveWeaponIDS because 50 is damage of helicopter blades and 51 is exlposive damage so if a vehicle sxploded near u it would destroy your hydra.

If it does not work post what you did and we'll look at it.

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