IsPlayerMapForced: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 14: Line 14:
This example forces a players radar-map on for 10seconds if it hasnt been already
This example forces a players radar-map on for 10seconds if it hasnt been already
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
player = getPlayerByNick ( "dave" ) -- do we have a player named "dave"
function forceMapForPlayer(callingPlayer,command,who)
if ( player ) then
player = getPlayerFromNick ( who ) -- do we have a player named "dave"
  if ( isPlayerMapForced ( player ) == false ) then -- if his radar-map isn't already forced on
if ( player ) then
    forcePlayerMap ( player, true ) -- force it on
  if ( isPlayerMapForced ( player ) == false ) then -- if his radar-map isn't already forced on
    setTimer ( "forcePlayerMap", 10000, 1, false ) -- force it off in 10secs
    forcePlayerMap ( player, true ) -- force it on
  end
    setTimer ( forcePlayerMap, 10000, 1, player, false ) -- force it off in 10secs
outputChatBox("Forcing Map for "..who,callingPlayer) -- output a message to the one who entered the command
  else
outputChatBox("Map already forced for "..who,callingPlayer) -- if the map is already forced, output a message
  end
else
outputChatBox("Couldn't find "..who,callingPlayer) -- if the player wasn't found, output a message
end
end
end
addCommandHandler("forceMap", forceMapForPlayer) -- add a command handler
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 18:35, 30 July 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 10seconds if it hasnt been already

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

See Also