GetPlayerWantedLevel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 4: Line 4:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int getWantedLevel ( player thePlayer )
int getPlayerWantedLevel ( player thePlayer )
</syntaxhighlight>  
</syntaxhighlight>  


Line 18: Line 18:
local players = getElementsByType ( "player" ) -- get a table of all the players in the server
local players = getElementsByType ( "player" ) -- get a table of all the players in the server
for theKey,thePlayer in players do -- use a generic for loop to step through each player
for theKey,thePlayer in players do -- use a generic for loop to step through each player
   local level = getWantedLevel ( thePlayer ) -- get the wanted level of the player
   local level = getPlayerWantedLevel ( thePlayer ) -- get the wanted level of the player
   if ( level > 0 ) then -- if the player has any stars, announce it in the chat:
   if ( level > 0 ) then -- if the player has any stars, announce it in the chat:
       outputChatBox ( getClientName ( thePlayer ) .. " has a wanted level of " .. level .. "  stars!" )
       outputChatBox ( getClientName ( thePlayer ) .. " has a wanted level of " .. level .. "  stars!" )

Revision as of 09:14, 12 September 2006

This function gets a player's current wanted level. The wanted level is indicated by the amount of stars a player has on the HUD.

Syntax

int getPlayerWantedLevel ( player thePlayer )

Required Arguments

  • thePlayer: The player whose wanted level you wish to get

Returns

Returns an int from 0 to 6 representing the player's wanted level, false if the player does not exist.

Example

This example finds which players in the server have a wanted level:

local players = getElementsByType ( "player" ) -- get a table of all the players in the server
for theKey,thePlayer in players do -- use a generic for loop to step through each player
   local level = getPlayerWantedLevel ( thePlayer ) -- get the wanted level of the player
   if ( level > 0 ) then -- if the player has any stars, announce it in the chat:
      outputChatBox ( getClientName ( thePlayer ) .. " has a wanted level of " .. level .. "  stars!" )
   end 
end

See Also