1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| local api -- control the street object table, obtained through the sf_start event callback, and stored in module local variables. For details, please refer to (api interface.txt)
-- player structure description -- Each user object table has uid, name, vip, gold, gender attributes -- Each user has a data table, which stores all the user's game data. It will be automatically saved when the user is disconnected. When a new user enters, the data will be empty and the data needs to be initialized immediately.
--- Start initialization event, which will be called directly every time the server is started. -- @function sf_start -- @tab nativeapi, control interface, see gameApi for details local function sf_start(nativeapi) --Put these variables in module variables and use them in other event callbacks api = nativeapi api.log("game start") end
--- Receive client network data response event. -- @function sf_message -- @tab player Which user sent the message? -- @tab data data table table local function sf_message(player,data)
end
--- A user has entered -- @function join -- @int player new user coming in -- @boolean Whether it is a new user logging in. The first login is true and player.data is nil. The data needs to be initialized as a table to save the player's information. If it is false, it indicates that an old user has logged in and he is saved in the data. user data local function sf_join(player,isNewUser)
end
--- A user left -- @function leave -- @int player the user who left local function sf_leave(player)
end
-- Output interface callback return { start=sf_start, message=sf_message, join=sf_join, leave=sf_leave, }
|