Rank Names
#1

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.
Reply
#2

Does FactionInfo[PlayerInfo[playerid][pFaction]][fRank1] hold any value?
Reply
#3

Yes, i'm loading it from the MySQL database and setting the variable to whatever is on the database.
Reply
#4

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.
Reply
#5

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.
Reply
#6

Hey, I could still use a little help with this!
Reply
#7

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?
Reply
#8

No, it shouldn't be "u", it can be "i" cause i'm only using the ID of the player..

And yes I did.
Reply
#9

Each faction has 10 ranks?
Reply
#10

Yep.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)