OnClientPedWeaponFire: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 16: Line 16:
The [[event system#Event source|source]] of this event is the [[ped]] who fired the weapon.
The [[event system#Event source|source]] of this event is the [[ped]] who fired the weapon.


==Example==  
==Example==
This Example output the player weapon and the player that they hit.
 
<syntaxhighlight lang="lua">
function hitme(weapon, hitElement)
local me = getPlayerName(source) -- Get the player that shot
local gun = getPedWeapon(source, weapon) -- Get the player gun
local hit = getPlayerName(hitElement) -- Get the killed person
if ( me ) then
  outputChatBox( ..me.. "shot an" ..gun.. "and killed" ..hit..)
end
end</syntaxhighlight>


==See Also==
==See Also==

Revision as of 03:26, 19 August 2011

This event is called when ped shoots a weapon. This does not trigger for projectiles based, or melee weapons. Also note that this event is only triggered for peds nearby the local player's camera. This is due to elements far away being streamed out.

Parameters

 int weapon, int ammo, int ammoInClip, float hitX, float hitY, float hitZ, element hitElement
  • weapon: an int representing weapon used for making a shot.
  • ammo: an int ammount of ammo left for this weapon type.
  • ammoInClip: an int ammount of ammo left for this weapon type in clip.
  • hitX, hitY, hitZ: float world coordinates representing a hit point.
  • hitElement: an element which was hit by a shot.

Source

The source of this event is the ped who fired the weapon.

Example

This Example output the player weapon and the player that they hit.

function hitme(weapon, hitElement)
 local me = getPlayerName(source) -- Get the player that shot
 local gun = getPedWeapon(source, weapon) -- Get the player gun
 local hit = getPlayerName(hitElement) -- Get the killed person
 if ( me ) then
  outputChatBox( ..me.. "shot an" ..gun.. "and killed" ..hit..)
 end
end

See Also

Client ped events


Client event functions