Jump to content

How to get a player who shoots at the car.


Flaker

Recommended Posts

How to get a player who shoots at the car.

Client side !!

function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
    if getElementType(hitElement)=="Vehicle" then 
         outputChatBox (..getPlayerName(getLocalPlayer()).."np shot car",getRootElement(), 0, 255, 0 )  
    end 
end 
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) 

Link to comment

Your code is wrong Booo.

addEventHandler ( 'onClientPlayerWeaponFire', root, 
    function ( _, _, _, _, _, _, uHit ) 
        if ( getElementType ( uHit ) == 'vehicle' ) then 
            outputChatBox ( getPlayerName ( source ) .. ' shooted on ' .. getPlayerName ( getPedOccupiedVehicle ( uHit ) ), 255, 255, 255, false ) 
        end 
    end 
) 

Edited by Guest
Link to comment

@Michael#: You're wrong as well, outputChatBox client side doesn't has a visibleTo argument.

-- client side:

addEventHandler ( "onClientPlayerWeaponFire", root, 
    function ( _, _, _, _, _, _, uHit ) 
        if ( uHit and getElementType ( uHit ) == "vehicle" ) then 
            triggerServerEvent ( "sendMessage", localPlayer, uHit ) 
        end 
    end 
) 

-- server side:

addEvent ( "sendMessage", true ) 
addEventHandler ( "sendMessage", root, 
    function ( vehicle ) 
        if ( vehicle ) then 
            outputChatBox ( getPlayerName ( source ) .." shooted on ".. getVehicleName ( vehicle ), root, 255, 255, 255, false ) 
        end 
    end 
) 

Link to comment

If you are using solidsnakes code, remember to use getLocalPlayer() (like you Jaysds1 did in his reply) instead of root, because otherwise it will trigger for every player that has the shooter in its streaming range.

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