Rank Names -
Luis- - 16.03.2013
Hey, I'm currently developing the factions part of a script i'm making and have encountered a problem. First of all i'm loading the rank
names from the MySQL table and they're loading fine, then I have a variable for every player's faction rank which is an
integer, I've also made a stock function to convert it form an
integer to a
string but it doesn't actually work, i've got a command which is
/showbadge to show a players faction badge to another player.
Код:
/* COMMANDS */
CMD:showbadge(playerid, params[]) {
new tarID, String[256];
if(sscanf(params, "i", tarID)) SendUsageMessage(playerid, "/showbadge [targetid]");
if(!IsPlayerConnected(tarID)) return SendClientMessage(playerid, COLOR_GREY, "Target isn't connected.");
else {
format(String, sizeof String, "[%s - %s]", GetName(playerid), FactionInfo[PlayerInfo[playerid][pFaction]][fName]);
SendClientMessage(tarID, COLOR_YELLOW, String);
format(String, sizeof String, "Rank: %s(%d)", GetRankName(playerid), PlayerInfo[playerid][pFacRank]);
SendClientMessage(tarID, COLOR_YELLOW, String);
}
return 1;
}
/* Get Rank Names */
stock GetRankName(playerid) {
new String[128];
switch(PlayerInfo[playerid][pFacRank]) {
case 0: format(String, sizeof String, "N/A");
case 1: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank1]);
case 2: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank2]);
case 3: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank3]);
case 4: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank4]);
case 5: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank5]);
case 6: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank6]);
case 7: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank7]);
case 8: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank8]);
case 9: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank9]);
case 10: format(String, sizeof String, "%s", FactionInfo[PlayerInfo[playerid][pFaction]][fRank10]);
}
return String;
}
As you can see, i've got the stock to convert it but nothing actually shows when I type the command which is odd.
Re: Rank Names -
Scenario - 16.03.2013
Does FactionInfo[PlayerInfo[playerid][pFaction]][fRank1] hold any value?
Re: Rank Names -
Luis- - 16.03.2013
Yes, i'm loading it from the MySQL database and setting the variable to whatever is on the database.
Re: Rank Names -
Scenario - 16.03.2013
Right, but have you made sure that data actually exists in the variable (i.e. using the printf function)?
Either way, try replacing
return String; with
return "Hello."; and see if it shows
"Hello." in the
/showbadge command.
Re: Rank Names -
Luis- - 16.03.2013
Yep, i've used that method, I also have set my rank to 0 to see whether it shows my rank as "N/A" and it does.
Re: Rank Names -
Luis- - 17.03.2013
Hey, I could still use a little help with this!
Re: Rank Names -
mrtms - 17.03.2013
Well first off this sscanf(params, "i", tarID) should be sscanf(params, "u", tarID).
Second did you printf(); one of the values like FactionInfo[PlayerInfo[playerid][pFaction]][fRank1] and is it working?
Re: Rank Names -
Luis- - 17.03.2013
No, it shouldn't be "u", it can be "i" cause i'm only using the ID of the player..
And yes I did.
Re: Rank Names -
stabker - 17.03.2013
Each faction has 10 ranks?
Re: Rank Names -
Luis- - 17.03.2013
Yep.