PDA

View Full Version : Need help with ranks


ThaCrypte
23/07/2013, 07:46 PM
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:

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;
}

ThaCrypte
23/07/2013, 08:05 PM
Well, that's the CMD to save the ranks.
But here the save/load:


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");

Income
23/07/2013, 09:20 PM
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.


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");

ThaCrypte
23/07/2013, 09:51 PM
Thanks :DDD

ThaCrypte
23/07/2013, 11:33 PM
delete this post please -.-

ThaCrypte
25/07/2013, 07:17 AM
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

IstuntmanI
25/07/2013, 12:39 PM
Change dini_IntSet with dini_Set and
PlayerInfo[playerid][pFRank] = dini_Int(file, "FRank");
with
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.

ThaCrypte
26/07/2013, 03:19 PM
Change dini_IntSet with dini_Set and
PlayerInfo[playerid][pFRank] = dini_Int(file, "FRank");
with
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.

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.

ThaCrypte
27/07/2013, 07:15 AM
Fixed it. Ty for all ya help.