TheGrimReaper Posted July 1, 2018 Share Posted July 1, 2018 -- 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
Galactix Posted July 1, 2018 Share Posted July 1, 2018 (edited) 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 July 1, 2018 by Galactix 1 Link to comment
TheGrimReaper Posted July 1, 2018 Author Share Posted July 1, 2018 thanks alot bro , appreciate your help @Galactix i have tried that man but no difference can u show me in script form if possible Link to comment
Galactix Posted July 1, 2018 Share Posted July 1, 2018 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. 1 Link to comment
TheGrimReaper Posted July 1, 2018 Author Share Posted July 1, 2018 well we do have a hosted server , if u wish we can test it there or u can just provide me with a untested script as an example and i could try to figure it out if there are any mistakes Link to comment
Mr.Loki Posted July 1, 2018 Share Posted July 1, 2018 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 ) 1 Link to comment
Galactix Posted July 1, 2018 Share Posted July 1, 2018 Well, try Mr.Loki's solution and I'll help you if it doesn't work, but it seems good for me. Link to comment
TheGrimReaper Posted July 1, 2018 Author Share Posted July 1, 2018 thanks to u both @Mr.Loki the script kills the attacker too the script works as i wanted to but it kills attacker and hydra doesnt blow Link to comment
Mr.Loki Posted July 1, 2018 Share Posted July 1, 2018 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
TheGrimReaper Posted July 2, 2018 Author Share Posted July 2, 2018 @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 Link to comment
Mr.Loki Posted July 2, 2018 Share Posted July 2, 2018 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
TheGrimReaper Posted July 2, 2018 Author Share Posted July 2, 2018 okai thanks man , ill try it now 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