Can a scripter help me figure out the problem with this:
#1

pawn Код:
CMD:demote(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    new giveplayerid;
    if(isnull(params)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /demote [player id or name]");
    if(FRank[playerid] < 6) return SendClientMessage(playerid, COLOUR_GREY, "You are not a high enough rank.");
    if(Faction[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not in a faction.");
    else if(Faction[giveplayerid] != Faction[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "That player is not in your faction.");

    new string[200], rank;
    FRank[giveplayerid] --;
    new factionid = Faction[playerid];

    if(rank > FRank[giveplayerid]) switch(rank) {
    case 1: format(string, sizeof(string), "You have demoted %s to the rank of %s(2)", GetNameEx(giveplayerid), FactionRank2[factionid]);
    case 2: format(string, sizeof(string), "You have demoted %s to the rank of %s(3)", GetNameEx(giveplayerid), FactionRank3[factionid]);
    case 3: format(string, sizeof(string), "You have demoted %s to the rank of %s(4)", GetNameEx(giveplayerid), FactionRank4[factionid]);
    case 4: format(string, sizeof(string), "You have demoted %s to the rank of %s(5)", GetNameEx(giveplayerid), FactionRank5[factionid]);
    case 5: format(string, sizeof(string), "You have demoted %s to the rank of %s(6)", GetNameEx(giveplayerid), FactionRank6[factionid]);
    case 6: format(string, sizeof(string), "You have demoted %s to the rank of %s(7)", GetNameEx(giveplayerid), FactionRank7[factionid]);
}
    SendClientMessage(playerid, COLOUR_ORANGE, string);

    new string1[200];
    if(rank > FRank[giveplayerid]) switch(rank) {

    case 1: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(2)", GetNameEx(playerid), FactionRank2[factionid]);
    case 2: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(3)", GetNameEx(playerid), FactionRank3[factionid]);
    case 3: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(4)", GetNameEx(playerid), FactionRank4[factionid]);
    case 4: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(5)", GetNameEx(playerid), FactionRank5[factionid]);
    case 5: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(6)", GetNameEx(playerid), FactionRank6[factionid]);
    case 6: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(7)", GetNameEx(playerid), FactionRank7[factionid]);
}
    SendClientMessage(giveplayerid, COLOUR_ORANGE, string1);
    FRank[playerid] = rank;
    MySQL_SetInteger(PlayerSQLID[playerid], "FRank", rank, "Accounts");
    return 1;
}
Basically it wont SendClientMessage and set's the player's rank to 0.

Any help would be nice.
Reply
#2

Try this one:

pawn Код:
CMD:demote(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    new giveplayerid;
    if(isnull(params)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /demote [player id or name]");
    if(FRank[playerid] < 6) return SendClientMessage(playerid, COLOUR_GREY, "You are not a high enough rank.");
    if(Faction[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not in a faction.");
    else if(Faction[giveplayerid] != Faction[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "That player is not in your faction.");

    new string[200], rank;
    FRank[giveplayerid] --;
    new factionid = Faction[playerid];

    if(rank > FRank[giveplayerid]) switch(rank) {
    case 1: format(string, sizeof(string), "You have demoted %s to the rank of %s(2)", GetNameEx(giveplayerid), FactionRank2[factionid]);
    case 2: format(string, sizeof(string), "You have demoted %s to the rank of %s(3)", GetNameEx(giveplayerid), FactionRank3[factionid]);
    case 3: format(string, sizeof(string), "You have demoted %s to the rank of %s(4)", GetNameEx(giveplayerid), FactionRank4[factionid]);
    case 4: format(string, sizeof(string), "You have demoted %s to the rank of %s(5)", GetNameEx(giveplayerid), FactionRank5[factionid]);
    case 5: format(string, sizeof(string), "You have demoted %s to the rank of %s(6)", GetNameEx(giveplayerid), FactionRank6[factionid]);
    case 6: format(string, sizeof(string), "You have demoted %s to the rank of %s(7)", GetNameEx(giveplayerid), FactionRank7[factionid]);
    SendClientMessage(playerid, COLOUR_ORANGE, string);
}

    new string1[200];
    if(rank > FRank[giveplayerid]) switch(rank) {

    case 1: format(string, sizeof(string), "You have demoted %s to the rank of %s(2)", GetNameEx(giveplayerid), FactionRank2[factionid]);
    case 2: format(string, sizeof(string), "You have demoted %s to the rank of %s(3)", GetNameEx(giveplayerid), FactionRank3[factionid]);
    case 3: format(string, sizeof(string), "You have demoted %s to the rank of %s(4)", GetNameEx(giveplayerid), FactionRank4[factionid]);
    case 4: format(string, sizeof(string), "You have demoted %s to the rank of %s(5)", GetNameEx(giveplayerid), FactionRank5[factionid]);
    case 5: format(string, sizeof(string), "You have demoted %s to the rank of %s(6)", GetNameEx(giveplayerid), FactionRank6[factionid]);
    case 6: format(string, sizeof(string), "You have demoted %s to the rank of %s(7)", GetNameEx(giveplayerid), FactionRank7[factionid]);
    SendClientMessage(playerid, COLOUR_ORANGE, string);
}
    FRank[playerid] = rank;
    MySQL_SetInteger(PlayerSQLID[playerid], "FRank", rank, "Accounts");
    return 1;
}
Reply
#3

Not tested.
pawn Код:
CMD:demote(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    new
        giveplayerid;
    else if(isnull(params)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /demote [player id or name]");
    else if(FRank[playerid] < 6) return SendClientMessage(playerid, COLOUR_GREY, "You are not a high enough rank.");
    else if(Faction[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not in a faction.");
    else if(Faction[giveplayerid] != Faction[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "That player is not in your faction.");
    else {
        new
            string[200],
            string1[200],
            rank;
        FRank[giveplayerid] --;
        new
            factionid = Faction[playerid];
        if(rank > FRank[giveplayerid]) switch(rank) {
            case 1: format(string, sizeof(string), "You have demoted %s to the rank of %s(2)", GetNameEx(giveplayerid), FactionRank2[factionid]);
            case 2: format(string, sizeof(string), "You have demoted %s to the rank of %s(3)", GetNameEx(giveplayerid), FactionRank3[factionid]);
            case 3: format(string, sizeof(string), "You have demoted %s to the rank of %s(4)", GetNameEx(giveplayerid), FactionRank4[factionid]);
            case 4: format(string, sizeof(string), "You have demoted %s to the rank of %s(5)", GetNameEx(giveplayerid), FactionRank5[factionid]);
            case 5: format(string, sizeof(string), "You have demoted %s to the rank of %s(6)", GetNameEx(giveplayerid), FactionRank6[factionid]);
            case 6: format(string, sizeof(string), "You have demoted %s to the rank of %s(7)", GetNameEx(giveplayerid), FactionRank7[factionid]);
            SendClientMessage(playerid, COLOUR_ORANGE, string);
            case 1: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(2)", GetNameEx(playerid), FactionRank2[factionid]);
            case 2: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(3)", GetNameEx(playerid), FactionRank3[factionid]);
            case 3: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(4)", GetNameEx(playerid), FactionRank4[factionid]);
            case 4: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(5)", GetNameEx(playerid), FactionRank5[factionid]);
            case 5: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(6)", GetNameEx(playerid), FactionRank6[factionid]);
            case 6: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(7)", GetNameEx(playerid), FactionRank7[factionid]);
            SendClientMessage(giveplayerid, COLOUR_ORANGE, string1);
        }
    }
    FRank[playerid] = rank;
    MySQL_SetInteger(PlayerSQLID[playerid], "FRank", rank, "Accounts");
    return 1;
}
Reply
#4

I'll give them a test! Thanks!
Reply
#5

Second one doesnt work, testing first.
Reply
#6

Second one doesn't work either.
Reply
#7

Try this. I hope to work. I confused on the last cases.
pawn Код:
CMD:demote(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    new
        giveplayerid;
    if(isnull(params)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /demote [player id or name]");
    if(FRank[playerid] < 6) return SendClientMessage(playerid, COLOUR_GREY, "You are not a high enough rank.");
    if(Faction[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not in a faction.");
    if(Faction[giveplayerid] != Faction[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "That player is not in your faction.");
    new
        string[200],
        string1[200],
        rank;
    FRank[giveplayerid] --;
    new
        factionid = Faction[playerid];
    if(rank > FRank[giveplayerid]) {
        switch(rank) {
            case 1: format(string, sizeof(string), "You have demoted %s to the rank of %s(2)", GetNameEx(giveplayerid), FactionRank2[factionid]);
            case 2: format(string, sizeof(string), "You have demoted %s to the rank of %s(3)", GetNameEx(giveplayerid), FactionRank3[factionid]);
            case 3: format(string, sizeof(string), "You have demoted %s to the rank of %s(4)", GetNameEx(giveplayerid), FactionRank4[factionid]);
            case 4: format(string, sizeof(string), "You have demoted %s to the rank of %s(5)", GetNameEx(giveplayerid), FactionRank5[factionid]);
            case 5: format(string, sizeof(string), "You have demoted %s to the rank of %s(6)", GetNameEx(giveplayerid), FactionRank6[factionid]);
            case 6: format(string, sizeof(string), "You have demoted %s to the rank of %s(7)", GetNameEx(giveplayerid), FactionRank7[factionid]);
            SendClientMessage(playerid, COLOUR_ORANGE, string);
            case 7: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(2)", GetNameEx(playerid), FactionRank2[factionid]);
            case 8: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(3)", GetNameEx(playerid), FactionRank3[factionid]);
            case 9: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(4)", GetNameEx(playerid), FactionRank4[factionid]);
            case 10: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(5)", GetNameEx(playerid), FactionRank5[factionid]);
            case 11: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(6)", GetNameEx(playerid), FactionRank6[factionid]);
            case 12: format(string1, sizeof(string1), "%s has demoted you to the rank of %s(7)", GetNameEx(playerid), FactionRank7[factionid]);
            SendClientMessage(giveplayerid, COLOUR_ORANGE, string1);
        }
    }
    FRank[playerid] = rank;
    MySQL_SetInteger(PlayerSQLID[playerid], "FRank", rank, "Accounts");
    return 1;
}
Reply
#8

That command makes no sense. Why would setting their rank to 12 show it as being set to 7?
Reply
#9

I completely re-wrote the command and it works, Used If statements! Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)