Strcat
#1

Once again, I have run into a problem.. and as I have no experience using this function what-so-ever, I can't even attempt to solve this by myself. Although it doesn't provide me with an error, it doesn't work as I want it to.

Here's the code:

pawn Код:
COMMAND:stats(playerid, params[])
{
    new string[256], holder[256], FactionName[50], FactionRankName[50], VIPName[50], JobName[50];
    if(PVar[playerid][pFaction] == 0)
    {
        FactionName = "Civilian";
    }
    else if(PVar[playerid][pFaction] == 1)
    {
        FactionName = "Los Santos Police Department";
    }
    else if(PVar[playerid][pFaction] == 2)
    {
        FactionName = "The Agency";
    }
    if(PVar[playerid][pFRank] == 0 && PVar[playerid][pFaction] == 0)
    {
        FactionRankName = "N/A";
    }
    else if(PVar[playerid][pFRank] == 1 && PVar[playerid][pFaction] == 1)
    {
        FactionRankName = "Trainee";
    }
    else if(PVar[playerid][pFRank] == 2 && PVar[playerid][pFaction] == 1)
    {
        FactionRankName = "Officer";
    }
    else if(PVar[playerid][pFRank] == 3 && PVar[playerid][pFaction] == 1)
    {
        FactionRankName = "Sergeant";
    }
    else if(PVar[playerid][pFRank] == 4 && PVar[playerid][pFaction] == 1)
    {
        FactionRankName = "Major";
    }
    else if(PVar[playerid][pFRank] == 5 && PVar[playerid][pFaction] == 1)
    {
        FactionRankName = "Chief";
    }
    else if(PVar[playerid][pFRank] == 1 && PVar[playerid][pFaction] == 2)
    {
        FactionRankName = "Agent";
    }
    else if(PVar[playerid][pFRank] == 2 && PVar[playerid][pFaction] == 2)
    {
        FactionRankName = "C.E.O";
    }
    if(PVar[playerid][VIPLevel] == 0)
    {
        VIPName = "None";
    }
    else if(PVar[playerid][VIPLevel] == 1)
    {
        VIPName = "Bronze";
    }
    else if(PVar[playerid][VIPLevel] == 2)
    {
        VIPName = "Bronze";
    }
    else if(PVar[playerid][VIPLevel] == 3)
    {
        VIPName = "Steel";
    }
    else if(PVar[playerid][VIPLevel] == 4)
    {
        VIPName = "Platinum";
    }
    else if(PVar[playerid][VIPLevel] == 5)
    {
        VIPName = "Gold";
    }
    if(PVar[playerid][pJob] == 0)
    {
        JobName = "Unemployed";
    }
    else if(PVar[playerid][pJob] == 1)
    {
        JobName = "Arms Dealer";
    }
    format(string, sizeof(string), "{0FA0D1}Name: {FFFFFF}%s (ID: %d)\n{0FA0D1}VIP Rank: {FFFFFF}%s (%d)\n{0FA0D1}Skin ID: {FFFFFF}%d\n{0FA0D1}Job:{FFFFFF} %s\n{0FA0D1}Money: {FFFFFF}$%d\n{0FA0D1}Faction: {FFFFFF}%s |", pName(playerid), playerid, VIPName, PVar[playerid][VIPLevel], PVar[playerid][pSkin], JobName, PVar[playerid][pMoney], FactionName);
    strcat(holder, string, sizeof(holder));
    format(string, sizeof(string), "{0FA0D1}Rank: {FFFFFF}%s (Rank: %d)\n{0FA0D1}Materials: {FFFFFF}%d | {0FA0D1}Drugs: {FFFFFF}%d", FactionRankName, PVar[playerid][pFRank], PVar[playerid][pMaterials], PVar[playerid][pDrugs]);
    strcat(holder, string, sizeof(holder)); // You need a new variable called 'holder' to hold all the data concenated with strcat
    ShowPlayerDialog(playerid, STATS, DIALOG_STYLE_MSGBOX, "{0FA0D1}Godfather Reborn: Statistics", holder, "Hide", "");
    return 1;
}
Screenshot of the problem:

Reply
#2

Make the string size bigger. If the data is too big make it 256 or 512
Reply
#3

Maybe the string cant support more letters, make a button 'next' and add another dialog
Reply
#4

Quote:
Originally Posted by admantis
Посмотреть сообщение
Make the string size bigger. If the data is too big make it 256 or 512
Both string and holder? I made it 256, and it was too small, still!
Reply
#5

Quote:
Originally Posted by Marricio
Посмотреть сообщение
Maybe the string cant support more letters, make a button 'next' and add another dialog
You don't need to do that so read my first post.

Quote:
Originally Posted by Skylar Paul
Посмотреть сообщение
Both string and holder? I made it 256, and it was too small, still!
Yes, make them both 256 (512)
Reply
#6

Quote:
Originally Posted by admantis
Посмотреть сообщение
Yes, make them both 256 (512)
Thank you very much once again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)