isGM: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function isGM== Returns 1 if the player is a GM or 0 if they are not. ===Usage=== <source lang="mtmacro" line> [h: gm = isGM()] </source> ===Examples=== <source lang="mtmacro" line> I...)
 
No edit summary
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
==Function isGM==
{{MacroFunction
Returns 1 if the player is a GM or 0 if they are not.
|name=isGM
|version=1.3b48
|description=
Returns {{true}} if the player is a GM or {{false}} if they are not.


===Usage===
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: gm = isGM()]
isGM()
</source>
</syntaxhighlight >


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


===Examples===
|examples=
<source lang="mtmacro" line>
'''1. Test to see if current player is a GM.'''
I am a [r: if(isGM(), "GM", "Player")]
 
</source>
<syntaxhighlight lang="mtmacro" line>
I am a [r,if(isGM()): "GM"; "Player"]
</syntaxhighlight>
 
 
'''2. Display a list of GMs.'''
 
<syntaxhighlight lang="mtmacro">
[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"]
</syntaxhighlight>
 
 
|changes=
*  '''b91''' - Added {{code|player}} parameter}}
 
[[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