Пример #1
0
func (this *Player) RegisterRole(id int32, player_id int32, server_id int32, nick string, HeroId int32) int32 {

	//检查是否已经拥有了key
	key := "role:" + strconv.Itoa(int(id))
	is_exists, _ := redis.Exists(key)

	//检测heroid是否在配置中
	HeroId_str := strconv.Itoa(int(HeroId))
	if Csv.Create_role[HeroId_str] == nil {
		return global.REGISTERROLEERROR
	}

	if is_exists {
		this.Day = 0
		this.DayFightNumber = 0
		this.Info.ID = id
		this.Info.Nick = nick
		this.Info.RoleId = HeroId

		//写入mysql 做排序
		//user := Player_Rank{ID: id, PlayerId: player_id, ServerId: server_id, Gold: 0}
		//O.Insert(user)

		//写内存数据库
		this.Save()
		return global.REGISTERROLESUCCESS
	}

	return global.REGISTERROLEERROR
}
Пример #2
0
//防外挂 逻辑更严密
func (this *Deal2A) NoteGame(player_id int64) {
	this.deal2amx.Lock()
	defer this.deal2amx.Unlock()

	is_exists, _ := redis.Exists(player_id)
	if !is_exists {
		redis.Modify(player_id, "")
	}
	fmt.Println("通知账号服务", player_id)
}
Пример #3
0
//防外挂 逻辑更严密
func (this *Deal2A) NoteGame(player_id int32) {
	this.deal2amx.Lock()
	defer this.deal2amx.Unlock()

	id := this.server_id + player_id

	key := "role:" + strconv.Itoa(int(id))
	is_exists, _ := redis.Exists(key)

	if !is_exists {
		redis.Add(key, "")
	}
}