Jump to content

Hunter target


denny199

Recommended Posts

Posted

hi there I was wondering that some servers have liek this: a hunter fight; Danny hitted Joop with his hunter like that but how?

i maded like this: but when i shoot it comes test: and a error in debugscript:

ser bad argument 17: getelementtype but i wanna make if a player hits a another player with his rocket that it comes in the chatbox that he hitted him please help me ;-)

-- i know from wiki but i dnunno were to start

  
function onPlayerTarget ( targetElem ) 
    if getElementType ( targetElem ) == "vehicle" and getElementModel ( targetElem ) == 425 then 
outputChatBox ( "test" ) 
    end 
end 
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTarget )   

Posted (edited)

Code Updated ! 2

local him = getPlayerName(killer) 
local me = getPlayerName(source) 
local what = getElementType() 
local mta = getElementModel() 
function kill ( ammo, killer, killerweapon, bodypart) 
    if (what == "vehicle" and mta == 425) then 
outputChatBox ( "him .. Has Killed .. me with .. what .. mta" ) 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill ) 

Edited by Guest
Posted

ofc,

If you have got a hunter fight

Like this:

I shoot you and you got killed by me then i will that in the chatbox comes: ( "Danny has killed Kennix with his hunter" )

Posted
function kill ( ammo, killer, killerweapon, bodypart ) 
    local vehicle = getPedOccupiedVehicle( killer ) 
    if isElement( vehicle ) and getElementModel( vehicle ) == 425 then 
        outputChatBox ( getPlayerName( killer )..' has killed '..getPlayerName( source )..' with his hunter.' ) 
    end 
end 
addEventHandler ( "onPlayerWasted", root, kill ) 

Evil-Cod3r,Your code is wrong.

local him = getPlayerName(killer) -- variable killer is nil 
local me = getPlayerName(source) -- variable source is nil ( source used in event you can read [url=https://wiki.multitheftauto.com/wiki/Predefined_variables_list]https://wiki.multitheftauto.com/wiki/Pre ... ables_list[/url] ) 
local what = getElementType() -- not use arguments so return false 
local mta = getElementModel() -- same 
function kill ( ammo, killer, killerweapon, bodypart) 
    if (what == "vehicle" and mta == 425) then 
outputChatBox ( "him .. Has Killed .. me with .. what .. mta" ) 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill ) 

Posted

it says bad argument @ getpecoccupiedvehicle used this code

function kill ( ammo, killer, killerweapon, bodypart ) 
    local vehicle = getPedOccupiedVehicle( killer ) 
    if isElement( vehicle ) and getElementModel( vehicle ) == 425 then 
        outputChatBox ( getPlayerName( killer )..' has killed '..getPlayerName( source )..' with his hunter.' ) 
    end 
end 
addEventHandler ( "onPlayerWasted", root, kill ) 

Posted (edited)
function kill ( ammo, killer, killerweapon, bodypart ) 
    if killer and killer ~= source then 
        if isPedInVehicle( killer ) and killerweapon == 19 or killerweapon == 51 then 
            local vehicle = getPedOccupiedVehicle( killer ) 
            if isElement( vehicle ) and getElementModel( vehicle ) == 425 then 
                outputChatBox ( getPlayerName( killer )..' has killed '..getPlayerName( source )..' with his hunter.' ) 
            end 
        end  
    end  
end 
addEventHandler ( "onPlayerWasted", root, kill ) 

Updated.

You need for race gm?

Edited by Guest
Posted

There's no really way to know who shoot you, because you get killed caused by your vehicle explosion, not by the rocket fired.

I don't know if "onClientVehicleCollision" detects the rocket, and if you're able to track the projectile creator.

Posted (edited)
well, kenix code didn't work it does nothing now i saw the updated, thanks for that but it's now serverside

My code is wrong I actually was realized.

We can't get who create projectile.

I think better request parameter attacker for event onVehicleExplode in bug tracker.

Edited by Guest
Posted
function projectileCreation() 
    local target = getProjectileTarget(source) 
    if (target and getElementType(target) == "vehicle" and getVehicleController(target)) then 
        local player = getVehicleController(target) 
        outputChatBox(getPlayerName(player)) 
    end 
end 
addEventHandler("onClientProjectileCreation", getRootElement(), projectileCreation) 

Posted

That's like a example, if the rocket has a target and the target is a vehicle and the vehicle has a driver, then output it's name to the client.

Posted (edited)

Client

addEventHandler( "onClientProjectileCreation", root,  
    function( creator ) 
        local target = getProjectileTarget( source ) 
        if isElement( target ) and getElementType( target ) == 'vehicle' and  
        isElement( creator ) and getElementType( creator ) == 'vehicle' then 
            local attacker = getVehicleController( creator ) 
            local player = getVehicleController( target ) 
            if isElement( attacker ) and isElement( player ) then 
                triggerServerEvent( 'onVehicleExploded',player,attacker ) 
            end  
        end  
    end 
) 

Server

addEvent( 'onVehicleExploded',true ) 
addEventHandler( 'onVehicleExploded',root, 
    function( attacker ) 
        outputChatBox ( getPlayerName( attacker )..' has killed '..getPlayerName( source )..' with his hunter.',root,255,0,0 ) 
    end 
)    

Updated again.

Edited by Guest
Posted

Try again.

And check each row with outputChatBox/outputDebugString.

Maybe projectile creator is player ( not vehicle ).

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