So for example lets say I type /update motd it then acts as if i typed /update updates add, even though i did not. so how do i fix this? I've tried multiple things and just can't get it to work! please help me.
Код:
CMD:update(playerid, params[])
{
// Calculating
new Year, Month, Day, Hour, Minute, option1[32], option2[32], string[128], line, bugname[10];
getdate(Year, Month, Day);
gettime(Hour, Minute);
{
new ActualDay;
PlayerInfo[playerid][pIDay] = ActualDay;
PlayerInfo[playerid][pIMonth] = Month;
PlayerInfo[playerid][pIDay] = Day;
PlayerInfo[playerid][pIMonth] = Month;
PlayerInfo[playerid][pIYear] = Year;
PlayerInfo[playerid][pIHour] = Hour;
PlayerInfo[playerid][pIMinute] = Minute;
}
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
if(sscanf(params, "s[32]", option1))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update [option]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: updates, motds, reminders, bugs");
return 1;
}
if(!strcmp(option1, "updates", true, 7))
{
if(sscanf(params, "s[32]s[32]", option1, option2))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update updates [option]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: add, remove");
return 1;
}
if(strcmp(option2, "add", true))
{
if(sscanf(params, "s[32]s[32]s[100]", option1, option2, params))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update updates add [text]");
return 1;
}
new File:updates=fopen("updates.cfg", io_append);
format(string, sizeof(string), "%s - [%d/%d/%d - %d:%d]\r\n", params, PlayerInfo[playerid][pIMonth], PlayerInfo[playerid][pIDay], PlayerInfo[playerid][pIYear], PlayerInfo[playerid][pIHour], PlayerInfo[playerid][pIMinute]);
fwrite(updates, string);
fclose(updates);
format(string, sizeof(string), "AdmCmd: %s has posted updates, use /updates to view it.", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
return 1;
}
if(strcmp(option2, "remove", true))
{
if(sscanf(params, "s[32]s[32]i", option1, option2, line))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update updates remove [updateid]");
return 1;
}
if(line < 1) return SendClientMessage(playerid, COLOR_GREY, "Invalid update id.");
fdeleteline("updates.cfg", line);
format(string, sizeof(string), "AdmCmd: %s has removed updates from /updates.", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
return 1;
}
return 1;
}
if(!strcmp(option1, "reminders", true, 9))
{
if(sscanf(params, "s[32]s[32]", option1, option2))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update reminders [option]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: add, remove");
return 1;
}
if(strcmp(option2, "add", true))
{
if(sscanf(params, "s[32]s[32]s[100]", option1, option2, params))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update reminders add [text]");
return 1;
}
new File:updates=fopen("reminders.cfg", io_append);
format(string, sizeof(string), "%s - [%d/%d/%d - %d:%d]\r\n", params, PlayerInfo[playerid][pIMonth], PlayerInfo[playerid][pIDay], PlayerInfo[playerid][pIYear], PlayerInfo[playerid][pIHour], PlayerInfo[playerid][pIMinute]);
fwrite(updates, string);
fclose(updates);
format(string, sizeof(string), "AdmWarn: %s has added reminders, use /reminders to view it.", RPN(playerid));
SendAdminMessage(COLOR_LIGHTRED, 1, string);
return 1;
}
if(strcmp(option2, "remove", true))
{
if(sscanf(params, "s[32]s[32]i", option1, option2, line))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update reminders remove [reminderid]");
return 1;
}
if(line < 1) return SendClientMessage(playerid, COLOR_GREY, "Invalid update id.");
fdeleteline("reminders.cfg", line);
format(string, sizeof(string), "AdmWarn: %s has removed reminders from /reminders.", RPN(playerid));
SendAdminMessage(COLOR_LIGHTRED, 1, string);
return 1;
}
return 1;
}
if(!strcmp(option1, "bugs", true, 4))
{
if(sscanf(params, "s[32]s[32]", option1, option2))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update bugs [option]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: add, remove");
return 1;
}
if(strcmp(option2, "add", true))
{
if(sscanf(params, "s[32]s[32]s[10]s[128]", option1, option2, bugname, params))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update bugs add [bugname] [info]");
return 1;
}
new File: file = fopen("bugs.cfg", io_append);
format(string, sizeof(string), "{5BA74B}Bug: {FF6347}%s {5BA74B}- Info: %s\r\n", bugname, params);
fwrite(file, string);
fclose(file);
format(string, sizeof(string), "AdmCmd: %s has added bugs, use /bugs to view it.", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
return 1;
}
if(strcmp(option2, "remove", true))
{
if(sscanf(params, "s[32]s[32]i", option1, option2, line))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update bugs remove [bugid]");
return 1;
}
if(line < 1) return SendClientMessage(playerid, COLOR_GREY, "Invalid bug id.");
fdeleteline("bugs.cfg", line);
format(string, sizeof(string), "AdmCmd: %s has removed bugs from /bugs.", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
return 1;
}
return 1;
}
if(!strcmp(option1, "motds", true, 5))
{
if(sscanf(params, "s[32]s[32]", option1, option2))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update motds [option]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: motd1, motd2, motd3");
return 1;
}
if(strcmp(option2, "motd1", true))
{
if(sscanf(params, "s[32]s[32]s[100]", option1, option2, params))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update motds motd1 [text]");
return 1;
}
format(ServerMOTD1, sizeof(ServerMOTD1), "%s", params);
format(string, sizeof(string), "AdmCmd: [motd1]%s has changed the message of the day to %s.", RPN(playerid), params);
SendClientMessageToAll(COLOR_LIGHTRED, string);
format(string, sizeof(string), "%s", params);
TextDrawSetString(MainMenuTxtdraw[6], string);
return 1;
}
if(strcmp(option2, "motd2", true))
{
if(sscanf(params, "s[32]s[32]i", option1, option2, line))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update motds motd2 [text]");
return 1;
}
format(ServerMOTD2, sizeof(ServerMOTD2), "%s", params);
format(string, sizeof(string), "AdmCmd: [motd2]%s has changed the message of the day to %s.", RPN(playerid), params);
SendClientMessageToAll(COLOR_LIGHTRED, string);
format(string, sizeof(string), "%s", params);
TextDrawSetString(MainMenuTxtdraw[7], string);
return 1;
}
if(strcmp(option2, "motd3", true))
{
if(sscanf(params, "s[32]s[32]i", option1, option2, line))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update motds motd3 [text]");
return 1;
}
format(ServerMOTD3, sizeof(ServerMOTD3), "%s", params);
format(string, sizeof(string), "AdmCmd: [motd3]%s has changed the message of the day to %s.", RPN(playerid), params);
SendClientMessageToAll(COLOR_LIGHTRED, string);
format(string, sizeof(string), "%s", params);
TextDrawSetString(MainMenuTxtdraw[8], string);
return 1;
}
return 1;
}
return 1;
}