GivePlayerSpell: Difference between revisions

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search
Complete Lua function catalog
Document 0.1a Lua API, identities, moderation and synchronized spells
 
Line 1: Line 1:
<!-- This page is generated automatically from the function definition: givePlayerSpell. -->
= givePlayerSpell =
= givePlayerSpell =
Grants or clears a player's authoritative spell ownership state.
Grants or clears a player's authoritative spell ownership state.
Line 23: Line 22:


== Examples ==
== Examples ==
Grant Fire Arrow to a player:
Grant Fire Bolt to a player:
<syntaxhighlight lang="lua" line>
<syntaxhighlight lang="lua" line>
givePlayerSpell(playerId, SPELL.FIRE_ARROW)
givePlayerSpell(playerId, SPELL.fire_bolt)
</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>setPlayerSpellGranted</code>.
* This is an alias of <code>setPlayerSpellGranted</code>.
* Grant state and cast support are separate. See [[Synchronized spell catalog]] and check <code>getSpellDefinition(spell).implemented</code> before exposing a spell to players.


[[Category:Lua Functions]]
[[Category:Lua Functions]]

Latest revision as of 11:36, 27 August 2026

givePlayerSpell

Grants or clears a player's authoritative spell ownership state.

Syntax

bool givePlayerSpell(int playerId, int|string spell [, bool enabled = true])

Parameters

Name Type Required Description
playerId int yes The connected player identifier.
spell string yes A spell id, a stable spell key, or a value from the global SPELL table.
enabled bool no True to grant the spell or false to revoke it; defaults to true.

Returns

Returns true when the spell grant state is accepted; otherwise returns false.

Examples

Grant Fire Bolt to a player:

givePlayerSpell(playerId, SPELL.fire_bolt)

Notes

  • Available only in server-side resource scripts.
  • This is an alias of setPlayerSpellGranted.
  • Grant state and cast support are separate. See Synchronized spell catalog and check getSpellDefinition(spell).implemented before exposing a spell to players.