Need help with ranks
#1

Well, currently i've been having trouble's with ranks.
The command works, but there's a slight bug in the saving to the userfile.
Since whenever you set the rank, it show's correctly, but saves as numbers in the .ini
And when you relogg, the rank is being weird.
For example:

Bob does /setrank Peter Boss.

Peter logs out to piss, and logs back in.

Peter type's /stats, and notice's his rank name is Bo.

The cmd:
pawn Код:
CMD:setrank(playerid, params[])
{
    new name[32], playerb, string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pFacLeader]) return SendClientMessage(playerid, COLOR_GREY, "You are not a faction leader.");
    if(PlayerInfo[playerb][pFac] != PlayerInfo[playerid][pFac]) return SendClientMessage(playerid, COLOR_GREY, "Player is not in your faction.");
    if(sscanf(params, "us[32]", playerb, name)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /setrank [player] [name]");

    {
        format(PlayerInfo[playerb][pFRank], 32,"%s", name);
        format(string, sizeof(string), "You have changed the rankname to %s", name);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    }

    return 1;
}
Reply
#2

Well, that's the CMD to save the ranks.
But here the save/load:
pawn Код:
enum pInfo
{
    pFRank,
}



// at the savechar stock:
            dini_IntSet(file, "FRank", PlayerInfo[playerid][pFRank]);


// At the Loadchar stock:
    PlayerInfo[playerid][pFRank] = dini_Int(file, "FRank");
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
That's not a string, but you set it to a string in the command - you can't do that.
Yup, you haven't declared that as a string, but you did count that as a string as written in your command.
Also, don't forget to change the the load/save methods afterwards to string instead of int.

pawn Код:
enum pInfo
{
    pFRank[32], // 32 chars
}
// at the savechar stock:
dini_IntSet(file, "FRank", PlayerInfo[playerid][pFRank]);
// At the Loadchar stock:
PlayerInfo[playerid][pFRank] = dini_Int(file, "FRank");
Reply
#4

Thanks DD
Reply
#5

delete this post please -.-
Reply
#6

I just noticed that the ranks does indeed save as a string now, and that's the good thing
The bad thing is that i realised that it doesn't load the string correctly, as in /stats it remains blank.... also in /members.

I'm sorry for double posting, but i cant remove my post's , so ye
Reply
#7

Change dini_IntSet with dini_Set and
pawn Код:
PlayerInfo[playerid][pFRank] = dini_Int(file, "FRank");
with
pawn Код:
strcat( ( PlayerInfo[playerid][pFRank] = EOS, PlayerInfo[playerid][pFRank] ), dini_Get(file, "FRank") );
... ****** already told you that that variable is not a integer, but a string.

You should use Y_INI in future.
Reply
#8

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
Change dini_IntSet with dini_Set and
pawn Код:
PlayerInfo[playerid][pFRank] = dini_Int(file, "FRank");
with
pawn Код:
strcat( ( PlayerInfo[playerid][pFRank] = EOS, PlayerInfo[playerid][pFRank] ), dini_Get(file, "FRank") );
... ****** already told you that that variable is not a integer, but a string.

You should use Y_INI in future.
pawn Код:
strcat( ( PlayerInfo[playerid][pFRank] = EOS, PlayerInfo[playerid][pFRank] ), dini_Get(file, "FRank") );
Didn't seem to work but also aint giving errors. And i already made it as a string on the enum.
Reply
#9

Fixed it. Ty for all ya help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)