HasPlayerSpell: Difference between revisions
Jump to navigation
Jump to search
Automatyczna aktualizacja dokumentacji funkcji |
Document 0.1a Lua API, identities, moderation and synchronized spells |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
= hasPlayerSpell = | = hasPlayerSpell = | ||
Checks whether a player has an authoritative spell grant. | Checks whether a player has an authoritative spell grant. | ||
| Line 23: | Line 22: | ||
Grant a spell only when it is missing: | Grant a spell only when it is missing: | ||
<syntaxhighlight lang="lua" line> | <syntaxhighlight lang="lua" line> | ||
if not hasPlayerSpell(playerId, SPELL. | if not hasPlayerSpell(playerId, SPELL.fire_bolt) then | ||
givePlayerSpell(playerId, SPELL. | givePlayerSpell(playerId, SPELL.fire_bolt) | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 31: | Line 30: | ||
* Available only in server-side resource scripts. | * Available only in server-side resource scripts. | ||
* This is an alias of <code>isPlayerSpellGranted</code>. | * This is an alias of <code>isPlayerSpellGranted</code>. | ||
* A granted catalog entry is not necessarily castable. See [[Synchronized spell catalog]] for the basic synchronized set in G1R:MP 0.1a. | |||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:Magic Functions]] | [[Category:Magic Functions]] | ||
[[Category:Player Functions]] | [[Category:Player Functions]] | ||
Latest revision as of 11:36, 27 August 2026
hasPlayerSpell
Checks whether a player has an authoritative spell grant.
Syntax
bool hasPlayerSpell(int playerId, int|string spell)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
spell |
string | yes | A spell id, stable spell key, or value from the global SPELL table. |
Returns
Returns true when the spell is granted; otherwise returns false.
Examples
Grant a spell only when it is missing:
if not hasPlayerSpell(playerId, SPELL.fire_bolt) then
givePlayerSpell(playerId, SPELL.fire_bolt)
end
Notes
- Available only in server-side resource scripts.
- This is an alias of
isPlayerSpellGranted. - A granted catalog entry is not necessarily castable. See Synchronized spell catalog for the basic synchronized set in G1R:MP 0.1a.