Jump to content

How to get a player who shoots at the car.


Flaker

Recommended Posts

Posted (edited)

you could use: onClientPlayerWeaponFire after getting what the client/player shot at, use

addEventHandler("onClientPlayerWeaponFire",localPlayer,function() 
   if(getElementType(hitElement)=="vehicle)"then 
      --YOUR CODE 
   end 
end) 

Edited by Guest
Posted
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 ) 

Posted (edited)

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
Posted

@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 
) 

Posted

Also, you we're using getPlayerName on a vehicle element. And you also use getPedOccupiedVehicle, but you already have a vehicle element which is "uHit".

Posted

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.

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