TextDisplayIsObserver: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 14: Line 14:
Return true if [[textdisplay]] is showing, or false if not.
Return true if [[textdisplay]] is showing, or false if not.
==Example==
==Example==
<section name="Server" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
serverDisplay = textCreateDisplay()  -- create a text display
serverDisplay = textCreateDisplay()  -- create a text display
Line 22: Line 23:
local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display
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
if not isObserver then -- if he is not an observer
    textDisplayAddObserver ( serverDisplay, player ) -- make it visible to a player
textDisplayAddObserver ( serverDisplay, player ) -- make it visible to a player
end
end
end
end
Line 30: Line 31:
local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display
local isObserver = textDisplayIsObserver ( serverDisplay , player ) -- check if he is already a observer in the server display
if isObserver then -- if he is an observer
if isObserver then -- if he is an observer
  textDisplayRemoveObserver ( serverDisplay , player ) -- remove the player from display
textDisplayRemoveObserver ( serverDisplay , player ) -- remove the player from display
end
end
end
end
addCommandHandler( "removeText",removeTextDisplay)
addCommandHandler( "removeText",removeTextDisplay)
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Text functions}}
{{Text functions}}
[[Category:Needs Example]]
[[Category:Needs Example]]

Revision as of 10:20, 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

Click to collapse [-]
Server
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