Describes the api object in the server and exposes the functions used by the server for development.
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(member,data,index) -> Send data to a single player object, member is the user object table that receives the data, data is table data, index is the seat array index, indicating who sent the data, 0 means Server sent
api.broadcastDesk(data, index) -> Only broadcast to desktop players, refer to send for parameters.
api.broadcast(data, index) -> Broadcast to everyone in the room, including those who are watching. For parameters, refer to send
api.broadcastLooker(data, index) -> Broadcast to the room to watch users, excluding those who are sitting down. For parameters, refer to send
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.over() -> After calling, the game ends and desktop players can stand up.
api.loadData(member) -> Load the player’s game data from the database, parameter member, player object table, return returns the player’s data table in the database.
api.saveData(member,mdata,replaced) -> Update the player’s game data, member game player object table, mdata. The player data to be updated must be an object with key=>value, such as {score=100,title =”Title card wins”}, this interface defaults to the update interface, and the key=>value data that is not included in weak mdata will not clear the original data. Weakly clear the unused key=>value data. The third parameter replaced is set to true, indicating that the original data is replaced. The mdata at this time must be the complete data table of your game data. There is no key in the original database. =>value data will be lost, and the default replaced parameter can be omitted, indicating a default update.
api.decreaseGold(member, gold) -> Deduct the player’s gold coins; the parameter member 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.
api.decreaseTicket(member,key,n) -> Deduct the player’s game tickets. The parameter member is a player object; key is a string customized by the developer, such as admission ticket “ticket”, opening ticket “open”, prize ticket “prize”, etc.; parameter n is a positive integer, indicating how many tickets will be deducted, leaving The empty default is 1; return returns number, 0 means success, 1 means parameter error, 2 means it must be a positive integer, 3 means not enough coupons.