Topic: [Info] /move /follow
/move <user> <channel> - мувает игрока на указанный канал
/follow <user> - заходит на канал который стоит указанный юзер
static int _handle_move_command(t_connection * c, char const * text) //KMC724
{
t_connection * user;
char * user_name;
char * channel_name;
char t[MAX_MESSAGE_LEN];
unsigned int i,j;
char arg1[256];
char arg2[256];
std::strncpy(t, text, MAX_MESSAGE_LEN - 1);
for (i=0; t[i]!=' ' && t[i]!='\0'; i++);
for (; t[i]==' '; i++);
for (j=0; t[i]!=' ' && t[i]!='\0'; i++)
if (j<sizeof(arg1)-1) arg1[j++] = t[i];
arg1[j] = '\0';
for (; t[i]==' '; i++);
for (j=0; t[i]!='\0'; i++)
if (j<sizeof(arg2)-1) arg2[j++] = t[i];
arg2[j] = '\0';
user_name = arg1;
channel_name = arg2;
if (!(user = connlist_find_connection_by_accountname(user_name))) {
message_send_text(c,message_type_error,c,"Геймер не найден");
return 0;
} else {
snprintf(msgtemp2, sizeof(msgtemp2), "%s",channel_name);
conn_set_channel(user,msgtemp2);
return 0;
}
}
static int _handle_follow_command(t_connection * c, char const * text) //KMC724
{
t_connection * user;
text = skip_command(text);
if (text[0]=='\0') {
message_send_text(c,message_type_info,c,"используйте: /follow <Геймер>");
return 0;
}
if (!(user = connlist_find_connection_by_accountname(text))) {
message_send_text(c,message_type_error,c,"Геймер не найден");
return 0;
} else {
conn_set_channel(c,channel_get_name(conn_get_channel(user)));
return 0;
}
}