Topic: Банлист или не показывать игру определенному юзеру
куда копать?(сервер) при этом не трогая бота
PvPGN Community Forums |
forums.pvpgn.pro → [RU] The Source Code → Банлист или не показывать игру определенному юзеру
куда копать?(сервер) при этом не трогая бота
Для Lua есть пример как изменить вывод списка игр для каждого отдельного игрока.
В этот метод передается account, для которого отображаются сортированные игры, и по аналогии можно фильтровать их по другим критериям https://github.com/pvpgn/pvpgn-server/b … a#L68-L107
Для Lua есть пример как изменить вывод списка игр для каждого отдельного игрока.
В этот метод передается account, для которого отображаются сортированные игры, и по аналогии можно фильтровать их по другим критериям https://github.com/pvpgn/pvpgn-server/b … a#L68-L107
вообщем нашел на handle_bnet.cpp и удалось скрыть игру + к нему не может зайти так что думаю все ок!
вот код
char arg1[256];
char* GameMoney;
char t[MAX_MESSAGE_LEN];
unsigned int i, j;
std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1);
for (i = 0; t[i] == ' '; i++); /* skip spaces */
for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */
if (j < sizeof(arg1) - 1) arg1[j++] = t[i];
arg1[j] = '\0';
GameMoney = arg1;
if (atoi(GameMoney) == 50) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open1", conn_get_socket(cbdata->c));
return 0;
}
игра в котором цена равна 50 не будет виден в списке + не могу войти в него говорит что она не найдена
Добавлено: 30.06.2020 17:13
вопрос!
как обратится к юзеру типо t_connection c но тут оно нету вместо него game
static int _glist_cb(t_game * game, void *data)
{
struct glist_cbdata *cbdata = (struct glist_cbdata*)data;
char clienttag_str[5];
t_server_gamelistreply_game glgame;
unsigned int addr;
unsigned short port;
bn_int game_spacer = { 1, 0, 0, 0 };
cbdata->tcount++;
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] considering listing game=\"%s\", pass=\"%s\" clienttag=\"%s\" gtype=%d", conn_get_socket(cbdata->c), game_get_name(game), game_get_pass(game), tag_uint_to_str(clienttag_str, game_get_clienttag(game)), (int) game_get_type(game));
char arg1[256];
char* GameMoney;
char t[MAX_MESSAGE_LEN];
unsigned int i, j;
std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1);
for (i = 0; t[i] == ' '; i++); /* skip spaces */
for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */
if (j < sizeof(arg1) - 1) arg1[j++] = t[i];
arg1[j] = '\0';
GameMoney = arg1;
if (atoi(GameMoney) == 50) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open1", conn_get_socket(cbdata->c));
return 0;
}
if (prefs_get_hide_pass_games() && game_get_flag(game) == game_flag_private) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is passworded or has private flag", conn_get_socket(cbdata->c));
return 0;
}
if (prefs_get_hide_started_games() && game_get_status(game) != game_status_open) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open", conn_get_socket(cbdata->c));
return 0;
}
if (game_get_clienttag(game) != conn_get_clienttag(cbdata->c)) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is for a different client", conn_get_socket(cbdata->c));
return 0;
}
if (cbdata->gtype != game_type_all && game_get_type(game) != cbdata->gtype) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is wrong type", conn_get_socket(cbdata->c));
return 0;
}
if (conn_get_versioncheck(cbdata->c) &&
conn_get_versioncheck(game_get_owner(game)) &&
versioncheck_get_versiontag(conn_get_versioncheck(cbdata->c)) &&
versioncheck_get_versiontag(conn_get_versioncheck(game_get_owner(game))) &&
std::strcmp(versioncheck_get_versiontag(conn_get_versioncheck(cbdata->c)), versioncheck_get_versiontag(conn_get_versioncheck(game_get_owner(game)))) != 0) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is wrong versiontag", conn_get_socket(cbdata->c));
return 0;
}
bn_short_set(&glgame.gametype, gtype_to_bngtype(game_get_type(game)));
bn_short_set(&glgame.unknown1, SERVER_GAMELISTREPLY_GAME_UNKNOWN1);
bn_short_set(&glgame.unknown3, SERVER_GAMELISTREPLY_GAME_UNKNOWN3);
addr = game_get_addr(game);
port = game_get_port(game);
trans_net(conn_get_addr(cbdata->c), &addr, &port);
bn_short_nset(&glgame.port, port);
bn_int_nset(&glgame.game_ip, addr);
bn_int_set(&glgame.unknown4, SERVER_GAMELISTREPLY_GAME_UNKNOWN4);
bn_int_set(&glgame.unknown5, SERVER_GAMELISTREPLY_GAME_UNKNOWN5);
switch (game_get_status(game)) {
case game_status_started:
bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_STARTED);
break;
case game_status_full:
bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_FULL);
break;
case game_status_open:
bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_OPEN);
break;
case game_status_done:
bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_DONE);
break;
default:
eventlog(eventlog_level_warn, __FUNCTION__, "[%d] game \"%s\" has bad status=%d", conn_get_socket(cbdata->c), game_get_name(game), (int) game_get_status(game));
bn_int_set(&glgame.status, 0);
}
bn_int_set(&glgame.unknown6, SERVER_GAMELISTREPLY_GAME_UNKNOWN6);
if (packet_get_size(cbdata->rpacket) + sizeof(glgame) + std::strlen(game_get_name(game)) + 1 + std::strlen(game_get_pass(game)) + 1 + std::strlen(game_get_info(game)) + 1 > MAX_PACKET_SIZE) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] out of room for games", conn_get_socket(cbdata->c));
return -1; /* no more room */
}
if (cbdata->counter) {
packet_append_data(cbdata->rpacket, &game_spacer, sizeof(game_spacer));
}
packet_append_data(cbdata->rpacket, &glgame, sizeof(glgame));
packet_append_string(cbdata->rpacket, game_get_name(game));
packet_append_string(cbdata->rpacket, game_get_pass(game));
packet_append_string(cbdata->rpacket, game_get_info(game));
cbdata->counter++;
return 0;
}
Добавлено: 30.06.2020 18:31
liurna88 wrote:Для Lua есть пример как изменить вывод списка игр для каждого отдельного игрока.
В этот метод передается account, для которого отображаются сортированные игры, и по аналогии можно фильтровать их по другим критериям https://github.com/pvpgn/pvpgn-server/b … a#L68-L107вообщем нашел на handle_bnet.cpp и удалось скрыть игру + к нему не может зайти так что думаю все ок!
вот кодchar arg1[256]; char* GameMoney; char t[MAX_MESSAGE_LEN]; unsigned int i, j; std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1); for (i = 0; t[i] == ' '; i++); /* skip spaces */ for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */ if (j < sizeof(arg1) - 1) arg1[j++] = t[i]; arg1[j] = '\0'; GameMoney = arg1; if (atoi(GameMoney) == 50) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open1", conn_get_socket(cbdata->c)); return 0; }
игра в котором цена равна 50 не будет виден в списке + не могу войти в него говорит что она не найдена
Добавлено: 30.06.2020 17:13
вопрос!
как обратится к юзеру типо t_connection c но тут оно нету вместо него gamestatic int _glist_cb(t_game * game, void *data) { struct glist_cbdata *cbdata = (struct glist_cbdata*)data; char clienttag_str[5]; t_server_gamelistreply_game glgame; unsigned int addr; unsigned short port; bn_int game_spacer = { 1, 0, 0, 0 }; cbdata->tcount++; eventlog(eventlog_level_debug, __FUNCTION__, "[%d] considering listing game=\"%s\", pass=\"%s\" clienttag=\"%s\" gtype=%d", conn_get_socket(cbdata->c), game_get_name(game), game_get_pass(game), tag_uint_to_str(clienttag_str, game_get_clienttag(game)), (int) game_get_type(game)); char arg1[256]; char* GameMoney; char t[MAX_MESSAGE_LEN]; unsigned int i, j; std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1); for (i = 0; t[i] == ' '; i++); /* skip spaces */ for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */ if (j < sizeof(arg1) - 1) arg1[j++] = t[i]; arg1[j] = '\0'; GameMoney = arg1; if (atoi(GameMoney) == 50) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open1", conn_get_socket(cbdata->c)); return 0; } if (prefs_get_hide_pass_games() && game_get_flag(game) == game_flag_private) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is passworded or has private flag", conn_get_socket(cbdata->c)); return 0; } if (prefs_get_hide_started_games() && game_get_status(game) != game_status_open) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open", conn_get_socket(cbdata->c)); return 0; } if (game_get_clienttag(game) != conn_get_clienttag(cbdata->c)) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is for a different client", conn_get_socket(cbdata->c)); return 0; } if (cbdata->gtype != game_type_all && game_get_type(game) != cbdata->gtype) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is wrong type", conn_get_socket(cbdata->c)); return 0; } if (conn_get_versioncheck(cbdata->c) && conn_get_versioncheck(game_get_owner(game)) && versioncheck_get_versiontag(conn_get_versioncheck(cbdata->c)) && versioncheck_get_versiontag(conn_get_versioncheck(game_get_owner(game))) && std::strcmp(versioncheck_get_versiontag(conn_get_versioncheck(cbdata->c)), versioncheck_get_versiontag(conn_get_versioncheck(game_get_owner(game)))) != 0) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is wrong versiontag", conn_get_socket(cbdata->c)); return 0; } bn_short_set(&glgame.gametype, gtype_to_bngtype(game_get_type(game))); bn_short_set(&glgame.unknown1, SERVER_GAMELISTREPLY_GAME_UNKNOWN1); bn_short_set(&glgame.unknown3, SERVER_GAMELISTREPLY_GAME_UNKNOWN3); addr = game_get_addr(game); port = game_get_port(game); trans_net(conn_get_addr(cbdata->c), &addr, &port); bn_short_nset(&glgame.port, port); bn_int_nset(&glgame.game_ip, addr); bn_int_set(&glgame.unknown4, SERVER_GAMELISTREPLY_GAME_UNKNOWN4); bn_int_set(&glgame.unknown5, SERVER_GAMELISTREPLY_GAME_UNKNOWN5); switch (game_get_status(game)) { case game_status_started: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_STARTED); break; case game_status_full: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_FULL); break; case game_status_open: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_OPEN); break; case game_status_done: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_DONE); break; default: eventlog(eventlog_level_warn, __FUNCTION__, "[%d] game \"%s\" has bad status=%d", conn_get_socket(cbdata->c), game_get_name(game), (int) game_get_status(game)); bn_int_set(&glgame.status, 0); } bn_int_set(&glgame.unknown6, SERVER_GAMELISTREPLY_GAME_UNKNOWN6); if (packet_get_size(cbdata->rpacket) + sizeof(glgame) + std::strlen(game_get_name(game)) + 1 + std::strlen(game_get_pass(game)) + 1 + std::strlen(game_get_info(game)) + 1 > MAX_PACKET_SIZE) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] out of room for games", conn_get_socket(cbdata->c)); return -1; /* no more room */ } if (cbdata->counter) { packet_append_data(cbdata->rpacket, &game_spacer, sizeof(game_spacer)); } packet_append_data(cbdata->rpacket, &glgame, sizeof(glgame)); packet_append_string(cbdata->rpacket, game_get_name(game)); packet_append_string(cbdata->rpacket, game_get_pass(game)); packet_append_string(cbdata->rpacket, game_get_info(game)); cbdata->counter++; return 0; }
Всё! так работает. т.е у кого не хватает денег не видят игру и не смогут зайти
char arg1[256];
char* GameMoney;
char t[MAX_MESSAGE_LEN];
unsigned int i, j;
std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1);
for (i = 0; t[i] == ' '; i++); /* skip spaces */
for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */
if (j < sizeof(arg1) - 1) arg1[j++] = t[i];
arg1[j] = '\0';
GameMoney = arg1;
t_account* account = conn_get_account(cbdata->c);
if (atoi(GameMoney) > account_get_money(account)) {
eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open", conn_get_socket(cbdata->c));
return 0;
}
Теперь надо организовать по этому коду банлист в котором можно добавить другого юзера и тот не мог зайти мб у кого то готовый код команды /banlist а есть? ) поделитесь а
liurna88 wrote:Для Lua есть пример как изменить вывод списка игр для каждого отдельного игрока.
В этот метод передается account, для которого отображаются сортированные игры, и по аналогии можно фильтровать их по другим критериям https://github.com/pvpgn/pvpgn-server/b … a#L68-L107вообщем нашел на handle_bnet.cpp и удалось скрыть игру + к нему не может зайти так что думаю все ок!
вот кодchar arg1[256]; char* GameMoney; char t[MAX_MESSAGE_LEN]; unsigned int i, j; std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1); for (i = 0; t[i] == ' '; i++); /* skip spaces */ for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */ if (j < sizeof(arg1) - 1) arg1[j++] = t[i]; arg1[j] = '\0'; GameMoney = arg1; if (atoi(GameMoney) == 50) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open1", conn_get_socket(cbdata->c)); return 0; }
игра в котором цена равна 50 не будет виден в списке + не могу войти в него говорит что она не найдена
Добавлено: 30.06.2020 17:13
вопрос!
как обратится к юзеру типо t_connection c но тут оно нету вместо него gamestatic int _glist_cb(t_game * game, void *data) { struct glist_cbdata *cbdata = (struct glist_cbdata*)data; char clienttag_str[5]; t_server_gamelistreply_game glgame; unsigned int addr; unsigned short port; bn_int game_spacer = { 1, 0, 0, 0 }; cbdata->tcount++; eventlog(eventlog_level_debug, __FUNCTION__, "[%d] considering listing game=\"%s\", pass=\"%s\" clienttag=\"%s\" gtype=%d", conn_get_socket(cbdata->c), game_get_name(game), game_get_pass(game), tag_uint_to_str(clienttag_str, game_get_clienttag(game)), (int) game_get_type(game)); char arg1[256]; char* GameMoney; char t[MAX_MESSAGE_LEN]; unsigned int i, j; std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1); for (i = 0; t[i] == ' '; i++); /* skip spaces */ for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */ if (j < sizeof(arg1) - 1) arg1[j++] = t[i]; arg1[j] = '\0'; GameMoney = arg1; if (atoi(GameMoney) == 50) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open1", conn_get_socket(cbdata->c)); return 0; } if (prefs_get_hide_pass_games() && game_get_flag(game) == game_flag_private) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is passworded or has private flag", conn_get_socket(cbdata->c)); return 0; } if (prefs_get_hide_started_games() && game_get_status(game) != game_status_open) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open", conn_get_socket(cbdata->c)); return 0; } if (game_get_clienttag(game) != conn_get_clienttag(cbdata->c)) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is for a different client", conn_get_socket(cbdata->c)); return 0; } if (cbdata->gtype != game_type_all && game_get_type(game) != cbdata->gtype) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is wrong type", conn_get_socket(cbdata->c)); return 0; } if (conn_get_versioncheck(cbdata->c) && conn_get_versioncheck(game_get_owner(game)) && versioncheck_get_versiontag(conn_get_versioncheck(cbdata->c)) && versioncheck_get_versiontag(conn_get_versioncheck(game_get_owner(game))) && std::strcmp(versioncheck_get_versiontag(conn_get_versioncheck(cbdata->c)), versioncheck_get_versiontag(conn_get_versioncheck(game_get_owner(game)))) != 0) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is wrong versiontag", conn_get_socket(cbdata->c)); return 0; } bn_short_set(&glgame.gametype, gtype_to_bngtype(game_get_type(game))); bn_short_set(&glgame.unknown1, SERVER_GAMELISTREPLY_GAME_UNKNOWN1); bn_short_set(&glgame.unknown3, SERVER_GAMELISTREPLY_GAME_UNKNOWN3); addr = game_get_addr(game); port = game_get_port(game); trans_net(conn_get_addr(cbdata->c), &addr, &port); bn_short_nset(&glgame.port, port); bn_int_nset(&glgame.game_ip, addr); bn_int_set(&glgame.unknown4, SERVER_GAMELISTREPLY_GAME_UNKNOWN4); bn_int_set(&glgame.unknown5, SERVER_GAMELISTREPLY_GAME_UNKNOWN5); switch (game_get_status(game)) { case game_status_started: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_STARTED); break; case game_status_full: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_FULL); break; case game_status_open: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_OPEN); break; case game_status_done: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_DONE); break; default: eventlog(eventlog_level_warn, __FUNCTION__, "[%d] game \"%s\" has bad status=%d", conn_get_socket(cbdata->c), game_get_name(game), (int) game_get_status(game)); bn_int_set(&glgame.status, 0); } bn_int_set(&glgame.unknown6, SERVER_GAMELISTREPLY_GAME_UNKNOWN6); if (packet_get_size(cbdata->rpacket) + sizeof(glgame) + std::strlen(game_get_name(game)) + 1 + std::strlen(game_get_pass(game)) + 1 + std::strlen(game_get_info(game)) + 1 > MAX_PACKET_SIZE) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] out of room for games", conn_get_socket(cbdata->c)); return -1; /* no more room */ } if (cbdata->counter) { packet_append_data(cbdata->rpacket, &game_spacer, sizeof(game_spacer)); } packet_append_data(cbdata->rpacket, &glgame, sizeof(glgame)); packet_append_string(cbdata->rpacket, game_get_name(game)); packet_append_string(cbdata->rpacket, game_get_pass(game)); packet_append_string(cbdata->rpacket, game_get_info(game)); cbdata->counter++; return 0; }
Добавлено: 30.06.2020 18:31
SkyFall wrote:liurna88 wrote:Для Lua есть пример как изменить вывод списка игр для каждого отдельного игрока.
В этот метод передается account, для которого отображаются сортированные игры, и по аналогии можно фильтровать их по другим критериям https://github.com/pvpgn/pvpgn-server/b … a#L68-L107вообщем нашел на handle_bnet.cpp и удалось скрыть игру + к нему не может зайти так что думаю все ок!
вот кодchar arg1[256]; char* GameMoney; char t[MAX_MESSAGE_LEN]; unsigned int i, j; std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1); for (i = 0; t[i] == ' '; i++); /* skip spaces */ for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */ if (j < sizeof(arg1) - 1) arg1[j++] = t[i]; arg1[j] = '\0'; GameMoney = arg1; if (atoi(GameMoney) == 50) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open1", conn_get_socket(cbdata->c)); return 0; }
игра в котором цена равна 50 не будет виден в списке + не могу войти в него говорит что она не найдена
Добавлено: 30.06.2020 17:13
вопрос!
как обратится к юзеру типо t_connection c но тут оно нету вместо него gamestatic int _glist_cb(t_game * game, void *data) { struct glist_cbdata *cbdata = (struct glist_cbdata*)data; char clienttag_str[5]; t_server_gamelistreply_game glgame; unsigned int addr; unsigned short port; bn_int game_spacer = { 1, 0, 0, 0 }; cbdata->tcount++; eventlog(eventlog_level_debug, __FUNCTION__, "[%d] considering listing game=\"%s\", pass=\"%s\" clienttag=\"%s\" gtype=%d", conn_get_socket(cbdata->c), game_get_name(game), game_get_pass(game), tag_uint_to_str(clienttag_str, game_get_clienttag(game)), (int) game_get_type(game)); char arg1[256]; char* GameMoney; char t[MAX_MESSAGE_LEN]; unsigned int i, j; std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1); for (i = 0; t[i] == ' '; i++); /* skip spaces */ for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */ if (j < sizeof(arg1) - 1) arg1[j++] = t[i]; arg1[j] = '\0'; GameMoney = arg1; if (atoi(GameMoney) == 50) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open1", conn_get_socket(cbdata->c)); return 0; } if (prefs_get_hide_pass_games() && game_get_flag(game) == game_flag_private) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is passworded or has private flag", conn_get_socket(cbdata->c)); return 0; } if (prefs_get_hide_started_games() && game_get_status(game) != game_status_open) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open", conn_get_socket(cbdata->c)); return 0; } if (game_get_clienttag(game) != conn_get_clienttag(cbdata->c)) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is for a different client", conn_get_socket(cbdata->c)); return 0; } if (cbdata->gtype != game_type_all && game_get_type(game) != cbdata->gtype) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is wrong type", conn_get_socket(cbdata->c)); return 0; } if (conn_get_versioncheck(cbdata->c) && conn_get_versioncheck(game_get_owner(game)) && versioncheck_get_versiontag(conn_get_versioncheck(cbdata->c)) && versioncheck_get_versiontag(conn_get_versioncheck(game_get_owner(game))) && std::strcmp(versioncheck_get_versiontag(conn_get_versioncheck(cbdata->c)), versioncheck_get_versiontag(conn_get_versioncheck(game_get_owner(game)))) != 0) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is wrong versiontag", conn_get_socket(cbdata->c)); return 0; } bn_short_set(&glgame.gametype, gtype_to_bngtype(game_get_type(game))); bn_short_set(&glgame.unknown1, SERVER_GAMELISTREPLY_GAME_UNKNOWN1); bn_short_set(&glgame.unknown3, SERVER_GAMELISTREPLY_GAME_UNKNOWN3); addr = game_get_addr(game); port = game_get_port(game); trans_net(conn_get_addr(cbdata->c), &addr, &port); bn_short_nset(&glgame.port, port); bn_int_nset(&glgame.game_ip, addr); bn_int_set(&glgame.unknown4, SERVER_GAMELISTREPLY_GAME_UNKNOWN4); bn_int_set(&glgame.unknown5, SERVER_GAMELISTREPLY_GAME_UNKNOWN5); switch (game_get_status(game)) { case game_status_started: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_STARTED); break; case game_status_full: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_FULL); break; case game_status_open: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_OPEN); break; case game_status_done: bn_int_set(&glgame.status, SERVER_GAMELISTREPLY_GAME_STATUS_DONE); break; default: eventlog(eventlog_level_warn, __FUNCTION__, "[%d] game \"%s\" has bad status=%d", conn_get_socket(cbdata->c), game_get_name(game), (int) game_get_status(game)); bn_int_set(&glgame.status, 0); } bn_int_set(&glgame.unknown6, SERVER_GAMELISTREPLY_GAME_UNKNOWN6); if (packet_get_size(cbdata->rpacket) + sizeof(glgame) + std::strlen(game_get_name(game)) + 1 + std::strlen(game_get_pass(game)) + 1 + std::strlen(game_get_info(game)) + 1 > MAX_PACKET_SIZE) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] out of room for games", conn_get_socket(cbdata->c)); return -1; /* no more room */ } if (cbdata->counter) { packet_append_data(cbdata->rpacket, &game_spacer, sizeof(game_spacer)); } packet_append_data(cbdata->rpacket, &glgame, sizeof(glgame)); packet_append_string(cbdata->rpacket, game_get_name(game)); packet_append_string(cbdata->rpacket, game_get_pass(game)); packet_append_string(cbdata->rpacket, game_get_info(game)); cbdata->counter++; return 0; }
Всё! так работает. т.е у кого не хватает денег не видят игру и не смогут зайти
char arg1[256]; char* GameMoney; char t[MAX_MESSAGE_LEN]; unsigned int i, j; std::strncpy(t, game_get_name(game), MAX_MESSAGE_LEN - 1); for (i = 0; t[i] == ' '; i++); /* skip spaces */ for (j = 0; t[i] != ' ' && t[i] != '\0'; i++) /* get command */ if (j < sizeof(arg1) - 1) arg1[j++] = t[i]; arg1[j] = '\0'; GameMoney = arg1; t_account* account = conn_get_account(cbdata->c); if (atoi(GameMoney) > account_get_money(account)) { eventlog(eventlog_level_debug, __FUNCTION__, "[%d] not listing because game is not open", conn_get_socket(cbdata->c)); return 0; }
Теперь надо организовать по этому коду банлист в котором можно добавить другого юзера и тот не мог зайти мб у кого то готовый код команды /banlist а есть? ) поделитесь а
Реализовать по принципу команды friends и поставить проверку по id.
forums.pvpgn.pro → [RU] The Source Code → Банлист или не показывать игру определенному юзеру