Mod API Reference:GameOrderCustom: Difference between revisions

From Warzone Wiki
Jump to navigation Jump to search
Kaninchen (talk | contribs)
Added a warning due to possible hacking
Kaninchen (talk | contribs)
m Forgot to remove that part yesterday
 
(4 intermediate revisions by 3 users not shown)
Line 7: Line 7:
* '''CostOpt''' ''Table<[[Mod API Reference:ResourceType|ResourceType]] (enum),integer>'': Defines how much gold the order will cost the player in a [[Commerce]] game.  This should only be set in commerce games.  If CostOpt is set to nil, then it's assumed to be the same as having a cost of 0.  The game will take care of taking the player's resources away correctly, both on the client and server, when inserting an order with a cost into their orders list.
* '''CostOpt''' ''Table<[[Mod API Reference:ResourceType|ResourceType]] (enum),integer>'': Defines how much gold the order will cost the player in a [[Commerce]] game.  This should only be set in commerce games.  If CostOpt is set to nil, then it's assumed to be the same as having a cost of 0.  The game will take care of taking the player's resources away correctly, both on the client and server, when inserting an order with a cost into their orders list.
* '''OccursInPhaseOpt''' ''[[Mod API Reference:Nullable|Nullable]]<[[Mod API Reference:TurnPhase|TurnPhase]] (enum)>'':  If not nil, then orders will be forced to be placed in this phase.  Players will not be able to move this order above an order of a lower phase, or below an order of a higher phase.  Added in v5.22.0.
* '''OccursInPhaseOpt''' ''[[Mod API Reference:Nullable|Nullable]]<[[Mod API Reference:TurnPhase|TurnPhase]] (enum)>'':  If not nil, then orders will be forced to be placed in this phase.  Players will not be able to move this order above an order of a lower phase, or below an order of a higher phase.  Added in v5.22.0.
'''Important to note'''


The Server [[Mod_Hooks]] which accept the '''GameOrderCustom''' should only depend on the payload, as hackers may modify all fields ('''Message''', '''Payload''', '''CostOpt''' and '''OccursInPhaseOpt''') to gain an advantage. Note that, since hackers can modify '''Payload''' too, it is essential to verify that it was even possible for the player to send the received '''Payload''' in the first place. All other Fields should be recreated by the Server.
[[Mod_Security|Mod security]] should be applied to [[Mod_Hooks|Mod Hooks]] working with this card
== Functions ==


* '''WL.GameOrderCustom.Create'''('''playerID''' ''[[Mod API Reference:PlayerID|PlayerID]]'', '''message''' ''string'', '''payload''' ''string'', '''costOpt''' ''Table<[[Mod API Reference:ResourceType|ResourceType]] (enum),integer>'') (static) returns [[Mod API Reference:GameOrderCustom|GameOrderCustom]]:
* '''WL.GameOrderCustom.Create'''('''playerID''' ''[[Mod API Reference:PlayerID|PlayerID]]'', '''message''' ''string'', '''payload''' ''string'', '''costOpt''' ''Table<[[Mod API Reference:ResourceType|ResourceType]] (enum),integer>'') (static) returns [[Mod API Reference:GameOrderCustom|GameOrderCustom]]:
[[Category:Mod API Reference]]
[[Category:Mod API Reference]]

Latest revision as of 16:58, 18 April 2024

GameOrderCustom: Subclass of GameOrder. This order does nothing on its own, but it can be used by mods for custom orders. GameOrderCustom is typically sent up from clients to the server, in contrast to GameOrderEvent which is typically sent down from the server to clients.

In order to make sure your mod doesn't break when used in conjunction with other mods, you should prepend a unique string (such as the name of your mod plus an underscore) to the Payload. When reading a GameOrderCustom, check if the payload starts with your unique string, and if it doesn't it means this order isn't one your mod made and you should ignore it. If you act on another mod's messages, or skip them, it will create unexpected behavior for your mod or another mod.

  • Message string: The message that will appear in the orders list. This is what players see.
  • Payload string: Data the mod wishes to store along with this order, but does not want players to see.
  • CostOpt Table<ResourceType (enum),integer>: Defines how much gold the order will cost the player in a Commerce game. This should only be set in commerce games. If CostOpt is set to nil, then it's assumed to be the same as having a cost of 0. The game will take care of taking the player's resources away correctly, both on the client and server, when inserting an order with a cost into their orders list.
  • OccursInPhaseOpt Nullable<TurnPhase (enum)>: If not nil, then orders will be forced to be placed in this phase. Players will not be able to move this order above an order of a lower phase, or below an order of a higher phase. Added in v5.22.0.

Mod security should be applied to Mod Hooks working with this card