Describes the api object in the global server and exposes the functions used by the server development. Please note that the method is different from the api object method in the room.
api control interface, obtained from the sf_start parameter of the server entry module ServerMain.lua
api.log(…) -> Server output log encapsulation, please do not use print.
api.send(player,data) -> Send data to a single player object. Player is the user object table that receives data, and data is table data.
api.broadcast(data) -> broadcast to game owners, refer to send for parameters
api.timeout(ti, func) -> timer, t is in seconds, supports decimals, func callback method, return returns the function to cancel the timer
api.time() -> Returns the UTC time in seconds (accuracy is two decimal places). The difference between UTC time and Beijing time is 8 hours.
api.getPlayer(uid) -> Get the player table identified by the uid, return value player table, parameters: uid player id.
api.getPlayers() -> Get the list of online users, return value players, an array containing the player table.
api.decreaseGold(player,gold) -> Deduct the player’s gold coins; the parameter player is the player object; the parameter gold is a positive integer, the number of gold coins to be deducted must be passed in; return returns number, 0 means success, 1 means the parameter Error, 2 means it must be a positive integer, 3 means there are not enough gold coins.