Y_INI Help!! big problem
#1

I have this command:
pawn Код:
CMD:createfaction(playerid, params[]) {
    if(PlayerInfo[playerid][pAdmin] >= 4) {

        new
            iFac = getFreeFaction(), amount, weapons, string[128];

        if(iFac == -1) {
            return SendClientMessage(playerid, -1, "There is too many factions.");
        }

        if(sscanf(params, "s[64]d", arrFaction[iFac][g_szFactionName], amount, weapons)) {
            return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /createfaction [name] [type(/factypes)]");
        }

        format(string, sizeof(string), "You have created a faction called %s, faction ID %i & type %d has been assigned to it!", arrFaction[iFac][g_szFactionName], iFac, amount);

        arrFaction[iFac][g_iFactionType] = amount;
        SendClientMessageEx(playerid, COLOR_WHITE, string);
        CreateDynamicFaction(iFac);
        SaveDynamicFaction();
    }
    return 1;
}
It creates the faction and adds the name in etc
But then when I add in a rank via /frankname it resets the faction name and the type and everything else to 0 so how can i make it fetch anything that is above 0 and then if it is save with the ranks and anything else??



pastebin link to saving, creating and loading code: http://pastebin.com/2R19fkTN

thanks
frankname cmd:
pawn Код:
CMD:frankname(playerid, params[])
{
    if(arrFaction[playerid][p_iMember] < 0)
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "You aren't in a faction.");
        return 1;
    }
    new factionid = arrFaction[playerid][g_iFactionID];
    new string[128], rank, rankname[32];
    if(sscanf(params, "ds[32]", rank, rankname)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /frankname [rank number 1-12] [rank name]");

    if(arrFaction[playerid][p_iMember] == 12)
    {
        if(rank < 1 || rank > 12)
        {
            SendClientMessageEx(playerid, COLOR_GREY, "Rank number must be from 1 to 12.");
            return 1;
        }
        if(strfind(rankname, "|", true) != -1)
        {
            SendClientMessageEx(playerid, COLOR_GRAD2,  "You can't use '|' in a rank name.");
            return 1;
        }
        if(strlen(rankname) >= 19 )
        {
            SendClientMessageEx( playerid, COLOR_GRAD1, "That rank name is too long, please refrain from using more than 19 characters." );
            return 1;
        }
        if(rank == 1)
        {
            strmid(arrFaction[factionid][p_iRank1], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 1 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 2)
        {
            strmid(arrFaction[factionid][p_iRank2], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 2 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 3)
        {
            strmid(arrFaction[factionid][p_iRank3], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 3 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 4)
        {
            strmid(arrFaction[factionid][p_iRank4], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 4 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 5)
        {
            strmid(arrFaction[factionid][p_iRank5], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 5 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 6)
        {
            strmid(arrFaction[factionid][p_iRank6], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 6 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 7)
        {
            strmid(arrFaction[factionid][p_iRank7], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 7 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 8)
        {
            strmid(arrFaction[factionid][p_iRank8], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 8 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 9)
        {
            strmid(arrFaction[factionid][p_iRank9], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 9 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 10)
        {
            strmid(arrFaction[factionid][p_iRank10], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 10 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 11)
        {
            strmid(arrFaction[factionid][p_iRank11], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 11 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }
        if(rank == 12)
        {
            strmid(arrFaction[factionid][p_iRank12], rankname, 0, strlen(rankname), 32);
            format(string, sizeof(string), "* You have changed Rank 12 to %s.",rankname);
            SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
        }

        format(string, sizeof(string), "%s adjusted faction %d's rank %d to %s", GetPlayerNameEx(playerid), factionid+1, rank, rankname);
        Log("logs/factions.log", string);
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GREY, "   You are not high rank enough to use this command!");
        return 1;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)