IsPedReloadingWeapon: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Switched the outputChatBox message in the example so that it now correctly displays whether the player is (not) reloading a weapon.)
m (Shared)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Shared function}}
{{New feature/item|3.0156|1.5.5|11856|
{{New feature/item|3.0156|1.5.5|11856|
This function is used to determine whether or not a ped is currently reloading their weapon. Useful to stop certain quick reload exploits.}}
This function is used to determine whether or not a ped is currently reloading their weapon. Useful to stop certain quick reload exploits.}}
Line 17: Line 17:


==Example==
==Example==
<section name="Client" class="client" show="true">
This example checks if the player who enters the ''/amireloading'' command is reloading and outputs a message.
This example checks if the player who enters the ''/amireloading'' command is reloading and outputs a message.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 27: Line 28:
end
end
addCommandHandler( "amireloading", isHeReloading )
addCommandHandler( "amireloading", isHeReloading )
</syntaxhighlight>
</syntaxhighlight></section>
 
==Changelog==
{{ChangelogHeader}}
{{ChangelogItem|1.6.0-22909|Added to the server side, the function is now shared}}


==See Also==
==See Also==
{{Client_ped_functions}}
{{Client_ped_functions}}

Revision as of 16:32, 11 January 2025

This function is used to determine whether or not a ped is currently reloading their weapon. Useful to stop certain quick reload exploits.

Syntax

bool isPedReloadingWeapon ( ped thePed )

OOP Syntax Help! I don't understand this!

Method: ped:isReloadingWeapon(...)
Variable: .reloadingWeapon


Required Arguments

  • thePed: The ped you are checking.

Returns

Returns true if the ped is currently reloading a weapon, false otherwise.

Example

Click to collapse [-]
Client

This example checks if the player who enters the /amireloading command is reloading and outputs a message.

function isHeReloading( )
    if isPedReloadingWeapon( localPlayer ) then
        outputChatBox( "You are reloading a weapon" )
    else
        outputChatBox( "No, you're not reloading a weapon" )
    end
end
addCommandHandler( "amireloading", isHeReloading )

Changelog

Version Description
1.6.0-22909 Added to the server side, the function is now shared

See Also