IsPlayerMapForced: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function checks if the specified player's radar-map has been forced on or not.
{{Server client function}}
This function checks if the specified player's map (F11) has been forced on or not.


==Syntax==
==Syntax==
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">bool isPlayerMapForced ( player thePlayer )</syntaxhighlight>
<syntaxhighlight lang="lua">bool isPlayerMapForced ( player thePlayer )</syntaxhighlight>
 
{{OOP||[[player]]:isMapForced|mapForced|forcePlayerMap}}
===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 map is forced on, ''false'' otherwise.
</section>
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">bool isPlayerMapForced ()</syntaxhighlight>
{{OOP||[[Player]].isMapForced||forcePlayerMap}}
===Returns===
Returns ''true'' if the local player's map is forced on, ''false'' otherwise.
</section>


==Example==
==Example==
This example forces a players radar-map on for 10seconds if it hasnt been already
<section name="Server" class="server" show="true">
This example forces a player's map on for 10 seconds if it hasn't been already.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
player = getPlayerByNick ( "dave" ) -- do we have a player named "dave"
function forceMapForPlayer ( callingPlayer, command, whoNick )
if ( player ) then
local who = getPlayerFromName ( whoNick )                                   -- Look up the specified player
  if ( isPlayerMapForced ( player ) == false ) then -- if his radar-map isn't already forced on
if ( who ) then
    forcePlayerMap ( player, true ) -- force it on
if ( not isPlayerMapForced ( who ) ) then                           -- if their map isn't already forced on
    setTimer ( "forcePlayerMap", 10000, 1, false ) -- force it off in 10secs
forcePlayerMap ( who, true )                               -- force it on
  end
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
end
addCommandHandler ( "forcemap", forceMapForPlayer ) -- add a command handler
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}

Latest revision as of 11:53, 9 November 2024

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

Syntax

Click to collapse [-]
Server
bool isPlayerMapForced ( player thePlayer )

OOP Syntax Help! I don't understand this!

Method: player:isMapForced(...)
Variable: .mapForced
Counterpart: forcePlayerMap


Required Arguments

  • thePlayer: A player object referencing the specified player

Returns

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

Click to collapse [-]
Client
bool isPlayerMapForced ()

OOP Syntax Help! I don't understand this!

Method: Player.isMapForced(...)
Counterpart: forcePlayerMap


Returns

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

Example

Click to collapse [-]
Server

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

function forceMapForPlayer ( callingPlayer, command, whoNick )
	local who = getPlayerFromName ( whoNick )                                   -- Look up the specified player
	if ( who ) then
		if ( not isPlayerMapForced ( who ) ) then                           -- if their 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