IsPlayerMapForced: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
{{Server function}}
This function checks if the specified player's radar-map has been forced on or not.
This function checks if the specified player's radar map has been forced on or not.


==Syntax==
==Syntax==
Line 7: Line 7:


===Required Arguments===
===Required Arguments===
* '''thePlayer''': A [[player]] object referencing the specified player
* '''thePlayer:''' A [[player]] object referencing the specified player


===Returns===
===Returns===
Returns ''true'' if the player's radar-map is forced on, ''false'' otherwise.
Returns ''true'' if the player's radar map is forced on, ''false'' otherwise.


==Example==
==Example==
This example forces a players radar-map on for 10seconds if it hasnt been already
This example forces a players radar map on for 10 seconds if it hasn't been already.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function forceMapForPlayer(callingPlayer,command,who)
function forceMapForPlayer ( callingPlayer, command, whoNick )
player = getPlayerFromNick ( who ) -- do we have a player named "dave"
local who = getPlayerFromNick ( whoNick )                                   -- Look up the specified player
if ( player ) then
if ( who ) then
  if ( isPlayerMapForced ( player ) == false ) then -- if his radar-map isn't already forced on
if ( not isPlayerMapForced ( who ) ) then                           -- if his radar map isn't already forced on
    forcePlayerMap ( player, true ) -- force it on
forcePlayerMap ( who, true )                               -- force it on
    setTimer ( forcePlayerMap, 10000, 1, player, false ) -- force it off in 10secs
setTimer ( forcePlayerMap, 10000, 1, who, false )           -- force it off in 10secs
outputChatBox("Forcing Map for "..who,callingPlayer) -- output a message to the one who entered the command
outputChatBox("Forcing Map for " .. whoNick, callingPlayer) -- output a message to the one who entered the command
  else
else
outputChatBox("Map already forced for "..who,callingPlayer) -- if the map is already forced, output a message
outputChatBox("Map already forced for " .. whoNick, callingPlayer) -- if the map is already forced, output a message
  end
end
else
else
outputChatBox("Couldn't find "..who,callingPlayer) -- if the player wasn't found, output a message
outputChatBox("Couldn't find " .. whoNick,callingPlayer)           -- if the player wasn't found, output a message
end
end
end
end

Revision as of 20:00, 16 August 2007

This function checks if the specified player's radar map has been forced on or not.

Syntax

bool isPlayerMapForced ( player thePlayer )

Required Arguments

  • thePlayer: A player object referencing the specified player

Returns

Returns true if the player's radar map is forced on, false otherwise.

Example

This example forces a players radar map on for 10 seconds if it hasn't been already.

function forceMapForPlayer ( callingPlayer, command, whoNick )
	local who = getPlayerFromNick ( whoNick )                                   -- Look up the specified player
	if ( who ) then
		if ( not isPlayerMapForced ( who ) ) then                           -- if his radar map isn't already forced on
			forcePlayerMap ( who, true )                                -- force it on
			setTimer ( forcePlayerMap, 10000, 1, who, false )           -- force it off in 10secs
			outputChatBox("Forcing Map for " .. whoNick, callingPlayer) -- output a message to the one who entered the command
		else
			outputChatBox("Map already forced for " .. whoNick, callingPlayer) -- if the map is already forced, output a message
		end
	else
		outputChatBox("Couldn't find " .. whoNick,callingPlayer)            -- if the player wasn't found, output a message
	end
end
addCommandHandler("forceMap", forceMapForPlayer) -- add a command handler

See Also