Jump to content

Hunter target


denny199

Recommended Posts

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 )   

Link to comment

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
Link to comment
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 ) 

Link to comment

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 ) 

Link to comment
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
Link to comment
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
Link to comment
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) 

Link to comment

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