Mod API Reference:ServerGame: Difference between revisions

From Warzone Wiki
Jump to navigation Jump to search
Created page with "'''ServerGame''': While GameWL contains public information about a game, ServerGame contains private information that's never shared with clients...."
 
No edit summary
Line 17: Line 17:
* '''Settings''' ''[[Mod API Reference:GameSettings|GameSettings]]'':  
* '''Settings''' ''[[Mod API Reference:GameSettings|GameSettings]]'':  
* '''TurnZeroStanding''' ''[[Mod API Reference:GameStanding|GameStanding]]'':
* '''TurnZeroStanding''' ''[[Mod API Reference:GameStanding|GameStanding]]'':
== Functions ==
* '''SetPlayerResource'''('''pid''' ''[[Mod API Reference:PlayerID|PlayerID]]'', '''type''' ''[[Mod API Reference:ResourceType|ResourceType]] (enum)'', '''newValue''' ''integer''):  Used to set the resources of a player, such as the amount of gold they have in a [[commerce]] game. 
This will set their resource value immediately, and update their displayed value on the player's screen so they can spend it immediately for their upcoming turn.
When this function is used, the next turn will start with a GameOrderEvent which tells players that a mod updated their resource value.  This way, there's still a log that something happened in history.
Note that if you reduce a player's gold value after they've committed orders, it may mess up their turn as they won't be able to spend as much gold as they were expecting, leading to failed deployments and failed attacks.  Take care to only do this if the player approves it.
Note that this function should never be called from an AdvanceTurn hook.  Doing so will produce an error message.  If you wish to change a player's resource from an AdvanceTurn hook, instead insert a [[Mod API Reference:GameOrderEvent|GameOrderEvent]] to change it.

Revision as of 22:50, 8 August 2017

ServerGame: While GameWL contains public information about a game, ServerGame contains private information that's never shared with clients. This structure is only available in Server hooks.

Functions

  • SetPlayerResource(pid PlayerID, type ResourceType (enum), newValue integer): Used to set the resources of a player, such as the amount of gold they have in a commerce game.

This will set their resource value immediately, and update their displayed value on the player's screen so they can spend it immediately for their upcoming turn. When this function is used, the next turn will start with a GameOrderEvent which tells players that a mod updated their resource value. This way, there's still a log that something happened in history. Note that if you reduce a player's gold value after they've committed orders, it may mess up their turn as they won't be able to spend as much gold as they were expecting, leading to failed deployments and failed attacks. Take care to only do this if the player approves it. Note that this function should never be called from an AdvanceTurn hook. Doing so will produce an error message. If you wish to change a player's resource from an AdvanceTurn hook, instead insert a GameOrderEvent to change it.