/update cmd help
#1

Okay two things, first I need to know how to make my code do when i type /update updates, it will then show the options the add, and remove options, then it will say depending on if I choose remove it will say something like /update updates remove [updateid] and for /update updates add [update] also when I try to type /update motd [text] it does not change my motd. :/ please help.

Код:
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]s[32]s[128]", option1, option2, params))
    {
        SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update [option1] [option2] [text]");
        SendClientMessage(playerid, COLOR_GREY, "OPTIONS: updates, motd, rules, reminders");
        return 1;
    }
    if(strcmp(option1, "updates", true, 7) == 0)
    {
        if(strcmp(option2, "add", true, 11) == 0)
        {
            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, 11) == 0)
        {
            if(line < 1) return SendClientMessage(playerid, COLOR_GREY, "Invalid update id.");
            fdeleteline("updates.cfg", line);
            return 1;
        }
        return 1;
    }
    if(strcmp(option1, "motd", true, 4) == 0)
    {
        format(ServerMOTD, sizeof(ServerMOTD), "%s", params);
        format(string, sizeof(string), "AdmCmd: %s has changed the message of the day to %s.", RPN(playerid), params);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        return 1;
    }
    if(strcmp(option1, "reminders", true, 9) == 0)
    {
        new File: file = 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(file, string);
        fclose(file);
        format(string, sizeof(string), "AdmWarn: %s has posted reminders, use /reminders to view it.", RPN(playerid));
        SendAdminMessage(COLOR_DARKRED, 1, string);
        return 1;
    }
    return 1;
}
Reply
#2

Hope it helps

Код:
CMD:update(playerid, params[])
{
    new option1[32], option2[32];
    if(sscanf(params, "s[32]", option1))
    {
        SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update [option1] [option2] [text]");
        SendClientMessage(playerid, COLOR_GRAY, "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] [option2] [text]");
	        SendClientMessage(playerid, COLOR_GRAY, "OPTIONS: add, remove");
	        return 1;
	    }
	    if(strcmp(option2, "add", true, 3) == 0)
	    {
	        if(sscanf(params, "s[32]s[32]s[32]", option1, option2, params))
		    {
		        SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /update [updates] [add] [text]");
		        SendClientMessage(playerid, COLOR_GRAY, "<!> Please insert your text!");
		        return 1;
		    }
			// Code...
	        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] [text]");
		        SendClientMessage(playerid, COLOR_GRAY, "<!> Please insert your text!");
		        return 1;
		    }
			// Code...
	        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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)