MakePedUseGun: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 25: Line 25:


==Example==
==Example==
This page lacks an example
This Example creates a ped and target ped to map, and ped gonna kill target ped
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--add an example here
</syntaxhighlight>
function createPed ()
function createPed ()
   ped = createPed ( 87, 0, 0, 5 ) -- Create our ped..
   ped = createPed ( 87, 0, 0, 5 ) -- Create our ped..
Line 38: Line 35:
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createPed ) -- attach event to function createped
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createPed ) -- attach event to function createped


 
</syntaxhighlight>


==See Also==
==See Also==
{{Client_ped_functions}}
{{Client_ped_functions}}
[[Category:Needs_Example]]
[[Category:Needs_Example]]

Revision as of 15:39, 27 July 2010

This function is used to force a ped to use a gun.

Syntax

bool makePedUseGun ( ped thePed, int useType, element target )

Required Arguments

  • thePed: The ped you wish to force the use of a gun upon.
  • useType: How the weapon should be used, will accept the following values:
    • 0: Do nothing
    • 1: Aim weapon
    • 2: Fire
    • 3: Burst-fire
    • 4: Reload
    • 5: Pistolwhip (Weapon melee)
    • 6: Cancel use
    • 7: Cancel use immediately
  • target: An element referring to the target that the ped will use its weapon against.

Returns

Returns true if the command was successful, false otherwise.

Example

This Example creates a ped and target ped to map, and ped gonna kill target ped

function createPed ()
  ped = createPed ( 87, 0, 0, 5 ) -- Create our ped..
  givePlayerWeapon ( ped, 31, 200 ) -- guve our ped weapon
  pedtarget = createPed ( 88, 0, 3, 5 ) -- Create our target ped..
  makePedUseGun ( ped, 2, pedtarget ) -- and make ped to kill pedTarget
end -- end function createPed
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createPed ) -- attach event to function createped

See Also