TextItemSetText: 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}}
Overwrites a previously created text item with the specified text.
Overwrites a previously created text item with the specified text.


Line 6: Line 7:


===Required Arguments===  
===Required Arguments===  
*'''textitem:''' Equal to a varible of an already existing '''textDisplayAddText''' you previously specified
*'''textitem:''' An existing text item that was previously created with '''textDisplayAddText'''
*'''text:''' A string that the '''textDisplayAddText''' you previously created will be changed to
*'''text:''' The new text for the text item


==Example==  
==Example==  
Here, it is being used to update a scoreboard:
Here, it is being used to update a scoreboard:
<syntaxhighlight lang="lua">addEventHandler ( "onPlayerWasted", getRootElement(), "onPlayerWasted")
<syntaxhighlight lang="lua">
function onPlayerWasted ( ammo, killer, weapon )
function onPlayerWasted ( ammo, killer, weapon )
if ( killer ~= false) then --Checks to see if anything killed the player. This can be false but it never equals true.
if ( killer ~= false) then --Checks to see if anything killed the player. This can be false but it never equals true.
if (players[getPlayerName(killer)].gang == "grove") then --If a player killed this person and they are part of the grove gang
if (players[getClientName(killer)].gang == "grove") then --If a player killed this person and they are part of the grove gang
groveteamscore = groveteamscore + 1 --Grove gets 1 point
groveteamscore = groveteamscore + 1 --Grove gets 1 point
textItemSetText ( scoregrove, tostring(groveteamscore) ) --Updated scoreboard Uses tostring() to change the varible to a string to satisfy the function.
textItemSetText ( scoregrove, tostring(groveteamscore) ) --Update scoreboard. Use tostring() to change the varible to a string to satisfy the function.
elseif (players[getPlayerName(killer)].gang == "balla") then --If a player killed this person and they are part of the balla gang
elseif (players[getClientName(killer)].gang == "balla") then --If a player killed this person and they are part of the balla gang
ballateamscore = ballateamscore + 1 --Ballas get 1 point
ballateamscore = ballateamscore + 1 --Ballas get 1 point
textItemSetText ( scoreballa, tostring(ballateamscore) ) --Updated scoreboard. Uses tostring() to change the varible to a string to satisfy the function.
textItemSetText ( scoreballa, tostring(ballateamscore) ) --Update scoreboard.
end
end
end
end</syntaxhighlight>
end
end
addEventHandler ( "onPlayerWasted", getRootElement(), onPlayerWasted )
</syntaxhighlight>


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

Revision as of 16:59, 15 August 2007

Overwrites a previously created text item with the specified text.

Syntax

void textItemSetText ( textitem textitem, string text )

Required Arguments

  • textitem: An existing text item that was previously created with textDisplayAddText
  • text: The new text for the text item

Example

Here, it is being used to update a scoreboard:

function onPlayerWasted ( ammo, killer, weapon )
	if ( killer ~= false) then --Checks to see if anything killed the player. This can be false but it never equals true.
		if (players[getClientName(killer)].gang == "grove") then --If a player killed this person and they are part of the grove gang
			groveteamscore = groveteamscore + 1 --Grove gets 1 point
			textItemSetText ( scoregrove, tostring(groveteamscore) ) --Update scoreboard. Use tostring() to change the varible to a string to satisfy the function.
		elseif (players[getClientName(killer)].gang == "balla") then --If a player killed this person and they are part of the balla gang
			ballateamscore = ballateamscore + 1 --Ballas get 1 point
			textItemSetText ( scoreballa, tostring(ballateamscore) ) --Update scoreboard.
		end
	end
end
addEventHandler ( "onPlayerWasted", getRootElement(), onPlayerWasted )

See Also