util_global.lua 636 B

12345678910111213141516171819202122232425262728293031323334
  1. --[[
  2. Descripttion:玩家事件
  3. version:
  4. Author: Neo,Huang
  5. Date: 2022-07-05 19:59:16
  6. LastEditors: Neo,Huang
  7. LastEditTime: 2022-07-05 20:08:31
  8. --]]
  9. local lib_game_redis = require("lib_game_redis")
  10. local MODULE_NAME = "global"
  11. local root = {}
  12. -- 创建玩家id
  13. function root:gen_user_id()
  14. local uid = lib_game_redis:hincrby(MODULE_NAME, "user:max:id", 1)
  15. if uid < 1000000 then
  16. uid = uid + 1000000
  17. lib_game_redis:set("user:max:id", uid)
  18. end
  19. return uid
  20. end
  21. -- 创建邮件id
  22. function root:gen_mail_id()
  23. local id = lib_game_redis:hincrby(MODULE_NAME, "mail:max:id", 1)
  24. return id
  25. end
  26. return root