more /update cmd help -.- -
MichaelWharton101 - 10.12.2013
So for some reason /update updates remove, wont remove the update from /updates, and /update motd [texthere] wont change the motd. please help me.
Код:
CMD:update(playerid, params[])
{
// Calculating
new Year, Month, Day, Hour, Minute, option1[32], option2[32], string[128], line;
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] < 1338) 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, motd, rules, reminders");
return 1;
}
if(strcmp(option1, "updates", true, 7) == 0)
{
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, 3) == 0)
{
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: file = 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(file, string);
fclose(file);
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, 6) == 0)
{
if(sscanf(params, "s[32]s[32]s[32]", option1, option2, params))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update updates remove [updateid]");
return 1;
}
if(line < 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid update id.");
fdeleteline("updates.cfg", line);
format(string, sizeof(string), "AdmCmd: %s has removed updates form /updates.", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
return 1;
}
return 1;
}
if(strcmp(option1, "rules", true, 5) == 0)
{
if(strcmp(option2, "serverrules", true, 11) == 0)
{
// Code...
return 1;
}
return 1;
}
if(strcmp(option1, "motd", true, 4) == 0)
{
new File: file = fopen("motd.cfg", io_append);
format(string, sizeof(string), "%s", params);
fwrite(file, string);
fclose(file);
format(string, sizeof(string), "AdmCmd: %s has changed the message of the day to %s.", RPN(playerid), params);
SendClientMessageToAll(COLOR_LIGHTRED, string);
// Code...
return 1;
}
if(strcmp(option1, "reminders", true, 9) == 0)
{
// Code...
return 1;
}
return 1;
}
Re: more /update cmd help -.- -
SickAttack - 10.12.2013
lol here you go:
Код:
CMD:update(playerid, params[])
{
// Calculating
new Year, Month, Day, Hour, Minute, option1[32], option2[32], string[128], line, ServerMOTD[128];
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] < 1338) 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, motd, rules, reminders");
return 1;
}
if(strcmp(option1, "updates", true, 7) == 0)
{
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, 3) == 0)
{
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:addupdates=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(addupdates, string);
fclose(addupdates);
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, 6) == 0)
{
if(sscanf(params, "s[32]s[32]s[32]", option1, option2, params))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update updates remove [updateid]");
return 1;
}
new File:removeupdate=fopen("updates.cfg", io_write);
if(line < 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid update id.");
fdeleteline(removeupdate, line);
fclose(removeupdate);
format(string, sizeof(string), "AdmCmd: %s has removed updates form /updates.", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
return 1;
}
return 1;
}
if(strcmp(option1, "rules", true, 5) == 0)
{
if(strcmp(option2, "serverrules", true, 11) == 0)
{
// Code...
return 1;
}
return 1;
}
if(strcmp(option1, "motd", true, 4) == 0)
{
if(sscanf(params, "s[32]s[32]", option1, params))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update [motd] [text]");
return 1;
}
new File:filemotd=fopen("motd.cfg", io_append);
format(ServerMOTD, 128, "%s", params);
fwrite(filemotd, ServerMOTD);
fclose(filemotd);
format(string, sizeof(string), "AdmCmd: %s has changed the message of the day to %s.", RPN(playerid), params);
SendClientMessageToAll(COLOR_LIGHTRED, string);
// Code...
return 1;
}
if(strcmp(option1, "reminders", true, 9) == 0)
{
// Code...
return 1;
}
return 1;
}
Don't forget to rep+!!!