GTX Posted March 17, 2012 Posted March 17, 2012 Hello, I'm wondering how can I get the player who killed me with hunter's projectile? I tried everything but I failed, could someone help me in that? What do I need? Thanks in advance!
Al3grab Posted March 17, 2012 Posted March 17, 2012 maybe .. addEventHandler("onPlayerWasted",root,function(ammo,killer) if killer and getElementType(killer) == "vehicle" then vehOwner = getVehicleOccupant(killer,0) if vehOwner then outputChatBox(getPlayerName(vehOwner).." has killed you .",source,255,100,100,true) end end end ) or .. -- Client addEventHandler("onClientProjectileCreation",root,function(creator) if creator then setElementData(source,"creator",creator) end end ) end ) -- Server addEventHandler("onPlayerWasted",root,function(ammo,killer) if killer and getElementType(killer) == "projectile" then proCar = getElementData(killer,"creator") if proCar then vehOwner = getVehicleOccupant(proCar ,0) if vehOwner then outputChatBox(getPlayerName(vehOwner).." has killed you .",source,255,100,100,true) end end end end )
Agon Posted March 17, 2012 Posted March 17, 2012 Maybe this? addEventHandler("onPlayerWasted", root, function(source, killer) if killer and getElementType(killer) =="player" then if getPedOccupiedVehicle(killer) == "theIdOfHunter" then -- put the id of hunter sorry i dont remember that. outputChatBox(getPlayerName(killer).." has killed you.", source, 255, 100, 100, true) end end end)
Castillo Posted March 17, 2012 Posted March 17, 2012 This question has been made more than two times, and the answer always been that you can't get the killer of the rocket that hit you, because you die when the vehicle explodes.
GTX Posted March 17, 2012 Author Posted March 17, 2012 This question has been made more than two times, and the answer always been that you can't get the killer of the rocket that hit you, because you die when the vehicle explodes. It is possible. I have already seen that script in TG server.
GanJaRuleZ Posted March 17, 2012 Posted March 17, 2012 Maybe there is a way , to calculate the way of the rocket , and when it explodes , it gets if a player was in that place.. I don't know.
bandi94 Posted March 17, 2012 Posted March 17, 2012 you can get the creator of the projectile on every projectile lunched check the creator and store it when somebody died bk of a rocket check the stored rocket's and done (whit the projectil store the player name ) https://wiki.multitheftauto.com/wiki/Element/Projectile
Castillo Posted March 17, 2012 Posted March 17, 2012 you can't get the killer of the rocket that hit you, because you die when the vehicle explodes.
arezu Posted March 17, 2012 Posted March 17, 2012 There is no certain way to get the killer, but you can use onClientExplosion and check distance from the explosion to the other vehicle that got exploded in a time frame of 50-250milisecs. I did that for my achievements script and it is working pretty good actually.
denny199 Posted March 17, 2012 Posted March 17, 2012 can u show me the code arezu? edit: i searched for it to
arezu Posted March 17, 2012 Posted March 17, 2012 Ok, here is some shitty old code: -- client sided addEventHandler("onClientExplosion", getRootElement(), function(x, y, z, theType) triggerServerEvent("onRequestShowKiller", source, x, y, z, theType) end) -- server sided addEvent("onRequestShowKiller", true) addEventHandler("onRequestShowKiller", getRootElement(), function(x, y, z, theType) if(x == nil)then return end local player = getElementsByType("player") for i = 1, #player do local vehX, vehY, vehZ = getElementPosition(player[i]) if(getDistanceBetweenPoints3D(x, y, z, vehX, vehY, vehZ) <= 20)then kira[source][#kira[source]+1] = player[i] end end end) and then onVehicleExplode i write who killed who. You will need to edit the code because it is shi**y
GTX Posted March 18, 2012 Author Posted March 18, 2012 Ok, here is some :~ old code: -- client sided addEventHandler("onClientExplosion", getRootElement(), function(x, y, z, theType) triggerServerEvent("onRequestShowKiller", source, x, y, z, theType) end) -- server sided addEvent("onRequestShowKiller", true) addEventHandler("onRequestShowKiller", getRootElement(), function(x, y, z, theType) if(x == nil)then return end local player = getElementsByType("player") for i = 1, #player do local vehX, vehY, vehZ = getElementPosition(player[i]) if(getDistanceBetweenPoints3D(x, y, z, vehX, vehY, vehZ) <= 20)then kira[source][#kira[source]+1] = player[i] end end end) and then onVehicleExplode i write who killed who. You will need to edit the code because it is shi**y Thank you, but how can I get attacker?
GTX Posted March 18, 2012 Author Posted March 18, 2012 GTX learn lua dude! I'm just wondering, because I have no idea how to get attacker!
NeXTreme Posted March 19, 2012 Posted March 19, 2012 The way I did it for TG: When you fire a projectile, mark it with setElementData (store the player that fired it) Then, there are collision spheres around every player. If the missile enters the collision shape of the player, the player is marked with that missile's ID. Now, if the player dies a few moments later, you can simply use getElementData on the missile to find the player that fired the rocket. If the player didn't die within, say, 500 milliseconds, clear the rocket's ID from the player. Not a very reliable way to do it, but it works decently.
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