CMD:rankname doesnt save
#1

Evening I created an /rankname command for the faction leaders that they can set an Custom Rank but its not saving in the file can someone help me out of it

pawn Код:
CMD:rankname(playerid, params[])
{
    new 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(sscanf(params, "us", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /rankname [playerid] [rank]");
    if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't change your rank.");
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(PlayerInfo[playerb][pFac] != PlayerInfo[playerid][pFac]) return SendClientMessage(playerid, COLOR_GREY, "Player is not in your faction.");
    format(PlayerInfo[playerb][pFacRanN], 60, "%s", params);
    format(string, sizeof(string), "You have changed the Rank Name from %s to %s.", RPN(playerb), params);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "%s has changed your Rank Name to %s", RPN(playerid), params);
    SendClientMessage(playerb, COLOR_LIGHTBLUE, string);
    return 1;
}
pawn Код:
//on stock loadhcar

format(PlayerInfo[playerid][pFacRanN], 60, "%s", dini_Get(file, "FacRanN"));
pawn Код:
//on savechar

dini_IntSet(file, "FacRankN", PlayerInfo[playerid][pFacRanN]);
pawn Код:
//on clear char
    format(PlayerInfo[playerid][pFacRanN], 64, "");
pawn Код:
pFacRanN[60],
Reply
#2

First off, you should change the sscanf line in your command to something like this:
Код:
    new playerb, rank[64], string[128];
    if(sscanf(params, "us", playerb, rank)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /rankname [playerid] [rank]");
Second, make sure your string sizes are all equal (this isn't the cause of the problem, just to prevent irregularities. These should all be the same number (60 or 64)

Код:
pFacRanN[60],
format(PlayerInfo[playerid][pFacRanN], 60, "%s", dini_Get(file, "FacRanN"));
format(PlayerInfo[playerid][pFacRanN], 64, "");
Finally, the cause of your problem

Код:
dini_IntSet(file, "FacRankN", PlayerInfo[playerid][pFacRanN]);
Since the faction rank name is a string not an integer this needs to be changed to:

Код:
dini_Set(file, "FacRankN", PlayerInfo[playerid][pFacRanN]);
Hope this helps, good luck.
Reply
#3

Quote:

First off, you should change the sscanf line in your command to something like this:
Code:
new playerb, rank[64], string[128];
if(sscanf(params, "us", playerb, rank)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /rankname [playerid] [rank]");
Second, make sure your string sizes are all equal (this isn't the cause of the problem, just to prevent irregularities. These should all be the same number (60 or 64)

Code:
pFacRanN[60],
format(PlayerInfo[playerid][pFacRanN], 60, "%s", dini_Get(file, "FacRanN"));
format(PlayerInfo[playerid][pFacRanN], 64, "");
Finally, the cause of your problem

Code:
dini_IntSet(file, "FacRankN", PlayerInfo[playerid][pFacRanN]);
Since the faction rank name is a string not an integer this needs to be changed to:

Code:
dini_Set(file, "FacRankN", PlayerInfo[playerid][pFacRanN]);
Hope this helps, good luck.

Yes sure , +rep
Reply
#4

Quote:
Originally Posted by Divergent
Посмотреть сообщение
First off, you should change the sscanf line in your command to something like this:
Код:
    new playerb, rank[64], string[128];
    if(sscanf(params, "us", playerb, rank)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /rankname [playerid] [rank]");
Second, make sure your string sizes are all equal (this isn't the cause of the problem, just to prevent irregularities. These should all be the same number (60 or 64)

Код:
pFacRanN[60],
format(PlayerInfo[playerid][pFacRanN], 60, "%s", dini_Get(file, "FacRanN"));
format(PlayerInfo[playerid][pFacRanN], 64, "");
Finally, the cause of your problem

Код:
dini_IntSet(file, "FacRankN", PlayerInfo[playerid][pFacRanN]);
Since the faction rank name is a string not an integer this needs to be changed to:

Код:
dini_Set(file, "FacRankN", PlayerInfo[playerid][pFacRanN]);
Hope this helps, good luck.
Still not working.. I tryed everything..
Reply
#5

Fixed thanks for the help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)