GetPlayerFightingStyle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 15: Line 15:
===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
*Returns the player's current fighting style as an integer ID
Returns the player's current fighting style as an integer ID, ''false'' if it fails to retrieve a value.
*Returns false if it fails to retrieve a value
 
{{Fighting Styles}}


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
This will allow any player to check what fighting style they are currently using
This will allow any player to check what fighting style they are currently using, by typing the 'getfightingstyle' command.
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "getfightingstyle", "getPlayerFightStyle" )
function getPlayerFightStyle ( player, commandName )
function getPlayerFightStyle ( player, commandName )
playerstyle = getPlayerFightingStyle ( player )
local playerstyle = getPlayerFightingStyle ( player ) -- store the fighting style in a variable
if playerstyle == 4 then
outputChatBox(tostring(playerstyle),player) -- output it to the player
outputChatBox ( "Style: standard" )
elseif playerstyle == 5 then
outputChatBox ( "Style: boxing" )
elseif playerstyle == 6 then
outputChatBox ( "Style: kungfu" )
elseif playerstyle == 7 then
outputChatBox ( "Style: taebo (knees)" )
end
end
end
addCommandHandler ( "getfightingstyle", getPlayerFightStyle )
</syntaxhighlight>
</syntaxhighlight>



Revision as of 22:15, 29 July 2007

This allows you to retrieve what fighting style a player is currently using.

Syntax

int getPlayerFightingStyle ( player theplayer ) 

Required Arguments

  • theplayer: The player whose current fighting style ID you wish to retrieve

Returns

Returns the player's current fighting style as an integer ID, false if it fails to retrieve a value.

Fighting Styles:

Fighting Style ID
STYLE_STANDARD 4
STYLE_BOXING 5
STYLE_KUNG_FU 6
STYLE_KNEE_HEAD 7
STYLE_GRAB_KICK 15
STYLE_ELBOWS 16

Example

This will allow any player to check what fighting style they are currently using, by typing the 'getfightingstyle' command.

function getPlayerFightStyle ( player, commandName )
	local playerstyle = getPlayerFightingStyle ( player ) -- store the fighting style in a variable
	outputChatBox(tostring(playerstyle),player) -- output it to the player
end
addCommandHandler ( "getfightingstyle", getPlayerFightStyle )

See Also