GetGameType: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 15: Line 15:


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example sends a message to player when he joins, if the current game type is Race.
This example does...
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--TODO
function playerJoinHandler( )
  if getGameType() == "Race" then
      outputChatBox( "Ready... Get set... GO!!" )
  end
end
addEventHandler( "onPlayerJoin", getRootElement(), playerJoinHandler )
</syntaxhighlight>
</syntaxhighlight>



Revision as of 19:38, 2 April 2008

This function retrieves the current gametype as set by setGameType.

Syntax

string getGameType ()

Returns

Returns the gametype as a string. If no gametype is set it returns nil.

Example

This example sends a message to player when he joins, if the current game type is Race.

function playerJoinHandler( )
   if getGameType() == "Race" then
      outputChatBox( "Ready... Get set... GO!!" )
   end
end
addEventHandler( "onPlayerJoin", getRootElement(), playerJoinHandler )

See Also

Template:ASE functions