isGM: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by 4 users not shown)
Line 6: Line 6:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
isGM()
isGM()
</source>
</syntaxhighlight >


b90+ allows to add a string parameter 'player' to check if the player is a GM or not.
<syntaxhighlight lang="mtmacro" line>
<source lang="mtmacro" line>
isGM(player)
isGM('player')
</syntaxhighlight>'''Parameters'''
</source>
{{param|player|player's name as a string to check if he is a GM or not.}}


|examples=
'''1. Test to see if current player is a GM.'''


|example=
<syntaxhighlight lang="mtmacro" line>
<source lang="mtmacro" line>
I am a [r,if(isGM()): "GM"; "Player"]
I am a [r,if(isGM()): "GM"; "Player"]
</source>
</syntaxhighlight>




'''2. Display a list of GMs.'''


b90+
<syntaxhighlight lang="mtmacro">
<source lang="mtmacro" line>
[H: allPlayers = getAllPlayerNames("json")]
[r: player = getPlayerName()] is a [r,if(isGM(player)): "GM"; "Player"]
[H: GMList = "[]"]
</source>
[H: foreach(player,allPlayers), code: {
Note: this macro does not make much sense, since it could be achieved just as well without using the parameter.
  [H, if(isGM(player)): GMList = json.append(GMList,player)]
}]
[R, if(! json.isEmpty(GMList)): "GM List: " + json.toList(GMList); "No players are listed as GM"]
</syntaxhighlight>
 
 
|changes=
*  '''b91''' - Added {{code|player}} parameter}}


}}
[[Category:Permission Function]]
[[Category:Permission Function]]

Latest revision as of 02:07, 13 March 2023

isGM() Function

Introduced in version 1.3b48
Returns true(1) if the player is a GM or false(0) if they are not.

Usage

isGM()
isGM(player)

Parameters

  • player - player's name as a string to check if he is a GM or not.

Examples

1. Test to see if current player is a GM.
I am a [r,if(isGM()): "GM"; "Player"]


2. Display a list of GMs.

[H: allPlayers = getAllPlayerNames("json")]
[H: GMList = "[]"]
[H: foreach(player,allPlayers), code: {
   [H, if(isGM(player)): GMList = json.append(GMList,player)]
}]
[R, if(! json.isEmpty(GMList)): "GM List: " + json.toList(GMList); "No players are listed as GM"]

Version Changes

  • b91 - Added player parameter