Difference between revisions of "SetPedFightingStyle"

From Multi Theft Auto: Wiki
m
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
{{Shared function}}
 
{{Shared function}}
 
Changes a ped's fighting style. Most styles only change the 'special attack' which is done using the Aim and Enter keys.
 
Changes a ped's fighting style. Most styles only change the 'special attack' which is done using the Aim and Enter keys.
{{New feature/item|3.0160|1.5.7|19626|Function also added client-side.}}
+
{{New feature/item|3.0158|1.5.7|19626|Function also added client-side.}}
  
 
==Syntax==  
 
==Syntax==  
Line 30: Line 30:
 
addCommandHandler ( "setstyle",  consoleSetFightingStyle )
 
addCommandHandler ( "setstyle",  consoleSetFightingStyle )
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==Requirements==
 +
{{Requirements|n/a|1.5.7-9.19626|}}
  
 
==See Also==
 
==See Also==
 
{{Shared ped functions}}
 
{{Shared ped functions}}
 
[[ru:setPedFightingStyle]]
 
[[ru:setPedFightingStyle]]

Latest revision as of 13:44, 25 October 2020

Changes a ped's fighting style. Most styles only change the 'special attack' which is done using the Aim and Enter keys. Function also added client-side.

Syntax

bool setPedFightingStyle ( ped thePed, int style )

Required Arguments

  • thePed: The ped whose fighting style to change.
  • style: The fighting style ID to apply.

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

Returns

Returns true in case of success, false otherwise.

Example

This example sets the player's fighting style to the desired style when he types "setstyle" followed by a number from 4 to 16 in console.

function consoleSetFightingStyle ( thePlayer, commandName, id )
	if thePlayer and id then                                                     -- If player and ID are specified
		local status = setPedFightingStyle ( thePlayer, tonumber(id) )       -- set the fighting style
		if not status then                                                   -- if that failed
			outputConsole ( "Failed to set fighting style.", thePlayer ) -- show a message
		end
	end
end
addCommandHandler ( "setstyle",  consoleSetFightingStyle )

Requirements

Minimum supported server n/a
Minimum supported client 1.5.7-9.19626

Note: Using this function requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.5.7-9.19626" />

See Also

BETA: FROM VERSION 1.5.7 r19626 ONWARDS
BETA: FROM VERSION 1.5.7 r19626 ONWARDS