TextDisplayIsObserver: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server function}} This functions checks if player see the textdisplay. ==Syntax== <syntaxhighlight lang="lua">bool textDisplayIsObserver ( textdisplay display, player player )</syntaxhighlight> ===R...)
 
mNo edit summary
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
{{Server function}}
This functions checks if player see the [[textdisplay]].
This function checks if a player can see the specified [[textdisplay]].


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool textDisplayIsObserver ( textdisplay display, player player )</syntaxhighlight>
<syntaxhighlight lang="lua">bool textDisplayIsObserver ( textdisplay display, player thePlayer )</syntaxhighlight>


===Required Arguments===
===Required Arguments===


* '''display''': The [[textdisplay]].
* '''display''': The [[textdisplay]].
* '''player''': The [[player]].
* '''thePlayer''': The [[player]].


===Returns===
===Returns===
Line 15: Line 15:
==Example==
==Example==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Example
serverDisplay = textCreateDisplay()  -- create a text display
serverText = textCreateTextItem ( "Hello world!", 0.5, 0.5 ) -- create a text item for the display
textDisplayAddText ( serverDisplay, serverText )  -- add it to the display so it is displayed
 
function showTextDisplay ( player, command )
local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display
if not isObserver then -- if he is not an observer
textDisplayAddObserver ( serverDisplay, player ) -- make it visible to a player
end
end
addCommandHandler( "showText", showTextDisplay )
 
function removeTextDisplay ( player , command )
local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display
if isObserver then -- if he is an observer
textDisplayRemoveObserver ( serverDisplay , player ) -- remove the player from display
end
end
addCommandHandler( "removeText",removeTextDisplay)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Text functions}}
{{Text functions}}

Latest revision as of 15:28, 22 May 2012

This function checks if a player can see the specified textdisplay.

Syntax

bool textDisplayIsObserver ( textdisplay display, player thePlayer )

Required Arguments

Returns

Return true if textdisplay is showing, or false if not.

Example

serverDisplay = textCreateDisplay()  -- create a text display
serverText = textCreateTextItem ( "Hello world!", 0.5, 0.5 ) -- create a text item for the display
textDisplayAddText ( serverDisplay, serverText )  -- add it to the display so it is displayed

function showTextDisplay ( player, command )
	local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display
	if not isObserver then -- if he is not an observer
		textDisplayAddObserver ( serverDisplay, player ) -- make it visible to a player
	end
end
addCommandHandler( "showText", showTextDisplay )

function removeTextDisplay ( player , command )
	local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display
	if isObserver then -- if he is an observer
		textDisplayRemoveObserver ( serverDisplay , player ) -- remove the player from display
	end
end
addCommandHandler( "removeText",removeTextDisplay)

See Also