String not showing correctly.
#1

Hi, I've got a strange bug.

I want to use a string which can be edited dynamic to color the family's name in /families:

PHP код:
CMD:fcolor(playeridparams[])
{
    new 
familycolorcode[25], string2[26];
    if(
sscanf(params"is[25]"familycolorcode))
    {
        
SendClientMessage(playeridCOLOR_GREY"/fcolor [familyid] [HEX-Colorcode]");
        return 
1;
    }
    
format(string2sizeof(string2), "%s",colorcode);
    
//strmid(FamilyInfo[family][fColor], string2, 0, 24);
    
strcpy(FamilyInfo[family][fColor], string225);
     
format(stringsizeof(string), "You have adjusted Family %d's Color to ID {%s}%s"family,colorcodeFamilyInfo[family][fColor]);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
SaveFamilies();
    return 
1;

When I used that ^ command if would show the embedding works:



But it isn't working on the /families:

PHP код:
for(new 0sizeof(FamilyInfo); i++)
            {
                if(
FamilyInfo[i][FamilyTaken] == 1)
                {
                    
number ++;
                    
format(stringsizeof(string), "** {%s}%s{F0F0F0} - Led by %s - Current Members: %d - Family Cookies: 0 - Strikes: %d of 3",FamilyInfo[i][fColor], FamilyInfo[i][FamilyName],FamilyInfo[i][FamilyLeader],FamilyInfo[i][FamilyMembers],FamilyInfo[i][fCookies] ,FamilyInfo[i][FStrikes]);
                    
SendClientMessage(playeridCOLOR_GRAD6string);
                }
            } 
SS:

I hope one of you guys know what I am doing wrong or something.

Thanks in advance!

Remco.
Reply
#2

First, Hex color code, starts with 0x and ends with FF, and your color code is HTML

The code below should work, because every HTML color must have a { & } (Bracket)

pawn Код:
for(new i = 0; i < sizeof(FamilyInfo); i++)
{
    if(FamilyInfo[i][FamilyTaken] == 1)
    {
        number ++;
        format(string, sizeof(string), "** {%s} %s{F0F0F0} - Led by %s - Current Members: %d - Family Cookies: 0 - Strikes: %d of 3",FamilyInfo[i][fColor], FamilyInfo[i][FamilyName],FamilyInfo[i][FamilyLeader],FamilyInfo[i][FamilyMembers],FamilyInfo[i][fCookies] ,FamilyInfo[i][FStrikes]);
        SendClientMessage(playerid, COLOR_GRAD6, string);
    }
}
Reply
#3

Ye, but somehow it isn't embedding the family's name.



'Hi' Should be embedded in the purple color.
Reply
#4

Try debugging the Enumerator, FamilyInfo[i][fColor] if it does print the same as what you set using the command /fcolor and show us the result when you have finished.
Reply
#5

I've created this command for debug:

PHP код:
CMD:fcheckcolor(playeridparams[])
{
    new 
family;
    if(
sscanf(params"i"family))
    {
        
SendClientMessage(playeridCOLOR_GREY"/fcolor [familyid]");
        return 
1;
    }
    
format(stringsizeof(string), "Family %d's color is ID {%s}%s"familyFamilyInfo[family][fColor], FamilyInfo[family][fColor]);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    return 
1;

That is working correctly.

Reply
#6

Quote:
Originally Posted by ikbenremco
Посмотреть сообщение
I've created this command for debug:

PHP код:
CMD:fcheckcolor(playeridparams[])
{
    new 
family;
    if(
sscanf(params"i"family))
    {
        
SendClientMessage(playeridCOLOR_GREY"/fcolor [familyid]");
        return 
1;
    }
    
format(stringsizeof(string), "Family %d's color is ID {%s}%s"familyFamilyInfo[family][fColor], FamilyInfo[family][fColor]);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    return 
1;

That is working correctly.

I have noticed that you're using FamilyInfo[family][fColor] twice to check the color, I am not sure if this is going to work, but at least give it a try

pawn Код:
for(new i = 0; i < sizeof(FamilyInfo); i++)
{
    if(FamilyInfo[i][FamilyTaken] == 1)
    {
        number ++;
        format(string, sizeof(string), "** {%s}%s %s{F0F0F0} - Led by %s - Current Members: %d - Family Cookies: 0 - Strikes: %d of 3", FamilyInfo[i][fColor], FamilyInfo[i][fColor], FamilyInfo[i][FamilyName], FamilyInfo[i][FamilyLeader], FamilyInfo[i][FamilyMembers], FamilyInfo[i][fCookies], FamilyInfo[i][FStrikes]);
        SendClientMessage(playerid, COLOR_GRAD6, string);
    }
}
Reply
#7

This code:

PHP код:
for(new 0sizeof(FamilyInfo); i++) 

    if(
FamilyInfo[i][FamilyTaken] == 1
    { 
        
number ++; 
        
format(stringsizeof(string), "** {%s}%s %s{F0F0F0} - Led by %s - Current Members: %d - Family Cookies: 0 - Strikes: %d of 3"FamilyInfo[i][fColor], FamilyInfo[i][fColor], FamilyInfo[i][FamilyName], FamilyInfo[i][FamilyLeader], FamilyInfo[i][FamilyMembers], FamilyInfo[i][fCookies], FamilyInfo[i][FStrikes]); 
        
SendClientMessage(playeridCOLOR_GRAD6string);
    }

That code doesn't make sense.

It's now not displaying the family's name? Because you added one more FamilyINfo[i][fColor] Variable.
Reply
#8

Quote:
Originally Posted by ikbenremco
Посмотреть сообщение
This code:

PHP код:
for(new 0sizeof(FamilyInfo); i++) 

    if(
FamilyInfo[i][FamilyTaken] == 1
    { 
        
number ++; 
        
format(stringsizeof(string), "** {%s}%s %s{F0F0F0} - Led by %s - Current Members: %d - Family Cookies: 0 - Strikes: %d of 3"FamilyInfo[i][fColor], FamilyInfo[i][fColor], FamilyInfo[i][FamilyName], FamilyInfo[i][FamilyLeader], FamilyInfo[i][FamilyMembers], FamilyInfo[i][fCookies], FamilyInfo[i][FStrikes]); 
        
SendClientMessage(playeridCOLOR_GRAD6string);
    }

That code doesn't make sense.

It's now not displaying the family's name? Because you added one more FamilyINfo[i][fColor] Variable.
It does, let me elaborate this.

Placeholder
  • First %s inside a bracket( { & } ) = HTML Color Code.
  • Second %s = HTML Color code. (Experiment, from previous code you had)
  • Third %s = Family Name.
It's a debug, because I wanted to know if it shows the right html code you placed, because at the moment it returns Null

The message should look like this.
Код:
** /*Color Violet*/ C7B1E6 /*Color White*/ SAMP_Family - Led by: pds2k12 - Current Members: 2012 - Family Cookies: 2012 - Strikes: 0 of 3
Reply
#9

Oh, I missed a %s I am sorry.

I've tried the code you've send me here is the outcome:

Reply
#10

Print the string in the console which will show if the color is being embedded into the string.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)