Jump to content

How can I get the player who killed me with hunter rocket?


GTX

Recommended Posts

Posted

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!

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

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 )  
  

ING : [xXx]~Al3grab

Posted

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) 

Posted

It doesn't work.

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

You can ask them how they did it then.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
you can't get the killer of the rocket that hit you, because you die when the vehicle explodes.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

Posted

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

Posted
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?

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
GTX learn lua dude!

I'm just wondering, because I have no idea how to get attacker!

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

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.

Website: http://www.twisted-gamers.net

Don't you just love the error messages in LUA?

notmem11.png

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