GetPedMoveState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
{{Needs Example}}
__NOTOC__
__NOTOC__
This function returns the current move state for the specified [[ped]].
This function returns the current move state for the specified [[ped]].
Line 18: Line 17:


==Example==
==Example==
<section name="Client" class="client" show="true">
<section show="true">
'''Example 1:''' This example shows how you can output a players current movestate.
'''Example 1:''' This example shows how you can output a players current movestate.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function getMoveState( command, playerName )
function getMoveState( command, playerName )
-- If the player name exists we will have out 'player'
-- If the player name exists we will have our 'player'
local player = getPlayerFromName( playerName )
local player = getPlayerFromName( playerName )
-- If the player does not exist, the script will stop.
-- If the player does not exist, the script will stop.
if not player then  
if not player then  
Line 30: Line 28:
return false
return false
end
end
-- If we found the player from the name, we can get his movestate.
-- If we found the player from the name, we can get his movestate.
local moveState = getPedMoveState( player )
local moveState = getPedMoveState( player )
-- If a player and a movestate is found, the script will output it to the chatbox.
-- If a player and a movestate is found, the script will output it to the chatbox.
outputChatBox( playerName .. "'s current moveState is: " .. moveState, 0, 150, 0, true )
outputChatBox( playerName .. "'s current moveState is: " .. moveState, 0, 150, 0, true )
end
end
addCommandHandler( "getMoveState", getMoveState) -- To execute this command, simply write: /getMoveState playerName
addCommandHandler( "getMoveState", getMoveState ) -- To execute this command, simply write: /getMoveState playerName
</syntaxhighlight>
</syntaxhighlight></section>


==See Also==
==See Also==
{{Ped functions}}
{{Ped functions}}
[[hu:getPedMoveState]]

Latest revision as of 13:14, 23 July 2022

This function returns the current move state for the specified ped.

Syntax

string getPedMoveState ( ped thePed )

Required Arguments

  • thePed: The ped whose move state you want to know

Returns

Returns a string indicating the ped's move state, or false if the ped is not streamed in, the movement type is unknown, the ped is in a vehicle or the ped is invalid.

  • stand: The ped is standing still.
  • walk: The ped is walking.
  • powerwalk: The ped is walking quickly.
  • jog: The ped is jogging.
  • sprint: The ped is sprinting.
  • crouch: The ped is crouching still.
  • crawl: The ped is crawling (moving and ducked).
  • jump: The ped is jumping into the air.
  • fall: The ped is falling to the ground.
  • climb: The ped is climbing onto an object.

Example

Click to collapse [-]

Example 1: This example shows how you can output a players current movestate.

function getMoveState( command, playerName )
-- If the player name exists we will have our 'player'
	local player = getPlayerFromName( playerName )
	-- If the player does not exist, the script will stop.
	if not player then 
		outputChatBox( "No player named " .. playerName .. " was found.", 250, 0, 0, true )
		return false
	end
	-- If we found the player from the name, we can get his movestate.
	local moveState = getPedMoveState( player )
	-- If a player and a movestate is found, the script will output it to the chatbox.
	outputChatBox( playerName .. "'s current moveState is: " .. moveState, 0, 150, 0, true )
end
addCommandHandler( "getMoveState", getMoveState ) -- To execute this command, simply write: /getMoveState playerName

See Also