GetPlayerWantedLevel
From Multi Theft Auto: Wiki
This function gets a player's current wanted level. The wanted level is indicated by the amount of stars a player has on the GTA HUD.
Syntax
Click to collapse [-]
Serverint getPlayerWantedLevel ( player thePlayer )
OOP Syntax Help! I don't understand this!
- Method: player:getWantedLevel(...)
- Variable: .wantedLevel
- Counterpart: setPlayerWantedLevel
Required Arguments
- thePlayer: The player whose wanted level you wish to get
Click to collapse [-]
Clientint getPlayerWantedLevel ( )
OOP Syntax Help! I don't understand this!
- Method: Player.getWantedLevel(...)
- Counterpart: setPlayerWantedLevel
Returns
Returns an int from 0 to 6 representing the player's wanted level, false if the player does not exist.
Example
Click to collapse [-]
Example 1: ServerThis 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 ipairs(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 ( getPlayerName ( thePlayer ) .. " has a wanted level of " .. level .. " stars!" ) end end
Click to collapse [-]
Example 2: ClientThis script output your wanted level when you type /wanted.
function outputWantedLevel () local wantedLvl = getPlayerWantedLevel ( ) if wantedLvl == 0 then outputChatBox ( "You clean", 0, 255, 0) else outputChatBox ( "You have "..wantedLvl.." wanted stars!", 255, 0, 0) end end addCommandHandler ( "wanted", outputWantedLevel )
See Also
- forcePlayerMap
- getAlivePlayers
- getDeadPlayers
- getPlayerACInfo
- getPlayerAnnounceValue
- getPlayerBlurLevel
- getPlayerCount
- getPlayerFromName
- getPlayerIdleTime
- getPlayerIP
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
FROM VERSION 1.5.7 r19626 ONWARDS
- getPlayerSerial
- getPlayerTeam
- getPlayerVersion
- getPlayerWantedLevel
- getRandomPlayer
- givePlayerMoney
- isPlayerMapForced
- isPlayerMuted
- isPlayerNametagShowing
- isVoiceEnabled
- redirectPlayer
- resendPlayerACInfo
- resendPlayerModInfo
- setPlayerAnnounceValue
- setPlayerBlurLevel
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerMuted
- setPlayerName
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
FROM VERSION 1.5.7 r19626 ONWARDS
- setPlayerTeam
- setPlayerVoiceBroadcastTo
- setPlayerVoiceIgnoreFrom
- setPlayerWantedLevel
- spawnPlayer
- takePlayerMoney
- takePlayerScreenShot