Topic: /setstats HELP
static int _handle_setstats_command(t_connection * c, char const * text)
{
t_account * account;
char * username;
unsigned int pts;
unsigned int wins;
unsigned int losses;
char t[MAX_MESSAGE_LEN];
unsigned int i,j;
char arg1[256];
int arg2[64];
int arg3[64];
int arg4[64];
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]!=' ' && t[i]!='\0'; i++)
if (j<sizeof(arg2)-1) arg2[j++] = t[i];
arg2[j] = '\0';
for (; t[i]==' '; i++);
for (j=0; t[i]!='\0'; i++)
if (j<sizeof(arg3)-1) arg3[j++] = t[i];
arg3[j] = '\0';
for (; t[i]==' '; i++);
for (j=0; t[i]!='\0'; i++)
if (j<sizeof(arg4)-1) arg4[j++] = t[i];
arg4[j] = '\0';
username = arg1;
pts = arg2;
wins = arg3;
losses = arg4;
if (arg1[0] =='\0') {
message_send_text(c,message_type_info,c,"используйте: /setstats <nik> <pts> <win> <loose>");
return 0;
}
else if (!(account = accountlist_find_account(username))) {
message_send_text(c,message_type_error,c,"Invalid user.");
return 0;
}
else {
account_set_pts(account,pts);
account_set_wins(account,wins);
account_set_losses(account,losses);
}
return 0;
}
помогите пожалуйста доработать