Fontcolor
#1

Ok, i've been running in to problems and i can't figure it out. Bascailly what i wanna do is give people the option to change there font color in an OOC chat (main chat pretty much) with the command /ooc. I want the color that the player choose to save to there account so they don't have to set it everytime the login in or whatever.

I have it semi working.

I do /fontcolor [hex code]

Use /ooc command

The font color works fine and it saves to your account just fine.

Here is the problem, When i /gmx or close the server and repoen it. It loads the color but when you go to use the /ooc command it gives you the white text and makes the mysql field where the font color is saved empty

So after restart

You type /ooc [text]

It shows your text but in the color white

it removes the color code from your profile and makes the mysql field blank.

Here is the prints

Before a restart right after i set /fontcolor. This is when it updates the mysql field for fontcolor
Код:
[09:41:28] {FFFFFF}Your new font color will be {666600} This Color {FFFFFF}
[09:41:32] Test_User [1]: {666600}test
As you can see it's putting the color before the text i typed

After server restart
Код:
[09:44:27] Test_User [1]: test
It dosen't put it in like it's suppose to


here is it getting loaded after server restart
Код:
[09:44:25] 1|Test_User|password|28|0|0|0|0|0|0|961888|23|4200|0|0|255|0|0|0|0|0|0|0|0|0|419|420|0|6|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|420|0|53|999|999|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|939|9999|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|122|7|0|0|0|0|0|0|1270|Shadow|0|0|0|-2015.15|161.475|27.6875|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|{666600} <<~~that is the color code
After another restart. Note i haven't done anything to the database.
Код:
[09:47:53] 1|Test_Usert|password|28|0|0|0|0|0|0|961888|23|4200|0|0|255|0|0|0|0|0|0|0|0|0|419|420|0|6|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|420|0|53|999|999|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|939|9999|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|122|7|0|0|0|0|0|0|1270|Shadow|0|0|0|-2015.15|161.475|27.6875|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0||0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|Color code should be right here but it's not
Here is the /ooc command
pawn Код:
if(strcmp(cmd, "/ooc", true) == 0 || strcmp(cmd, "/o", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You havent logged in yet!");
                return 1;
            }
            if ((noooc) && PlayerInfo[playerid][pAdmin] < 1)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   The OOC channel has been disabled by an admin!");
                return 1;
            }
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "   You can't speak, you have been silenced!");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[256];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/o)oc [ooc chat]");
                return 1;
            }
            format(string, sizeof(string),"%s [%d]: %s%s", sendername,playerid,PlayerInfo[playerid][pFontColor],result);
            //ReColour(result);
            ReColor(result);
            OOCOff(COLOR_WHITE,string);
            printf("%s",string);
        }
        return 1;
    }
The command to set /fontcolor
pawn Код:
if(strcmp(cmd, "/fontcolor", true) == 0)
        {
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            //new sql[512];
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[256];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            idx++;
            if(!strlen(result)) return SendClientMessage(playerid, COLOR_GREY, "USE:/fontcolor [color code]"); SendClientMessage(playerid, COLOR_WHITE, "EXAMPLE - /fontcolor (3300FF)"); SendClientMessage(playerid, COLOR_WHITE, "Color Codes Are on the Forums");
            ReColour(result);
            format(string, sizeof(string), "{FFFFFF}Your new font color will be %s This Color {FFFFFF}", result);
            SendClientMessage(playerid, COLOR_GREEN, string);
            printf("%s",string);
            GetPlayerName(playerid, playername, sizeof(playername));
            format(sql, sizeof(sql), "UPDATE table SET field='%s' WHERE field='%s'",result,playername);
            mysql_query(sql);
            printf("%s",sql);
            PlayerInfo[playerid][pFontColor] = result;
            }
        return 1;
        }
Here is the recolor shiznit made by ******
pawn Код:
ReColor(result[])
{
        new
                pos = -1;
        while ((pos = strfind(result, "(", false, pos + 1)) != -1)
        {
                new
                        c = pos + 1,
                        n = 0,
                        ch;
                // Note that the order of these is important!
                while ((ch = result[c]) && n != 6)
                {
                        if (!('a' <= ch <= 'f' || 'A' <= ch <= 'F' || '0' <= ch <= '9'))
                        {
                                break;
                        }
                        ++c;
                        ++n;
                }
                if (n == 6 && ch == ')')
                {
                        result[pos] = '{';
                        result[c] = '}';
                }
        }
}
So does anyone have any idea what it's doing what it's doing?
Reply
#2

I don't understand what is the problem?
Reply
#3

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
I don't understand what is the problem?

Ok, when i set /fontcolor The colors work fine with /ooc command

I restart the server

I Test to see if colors are still set so i type /ooc command

When i do that The color code is removed from the database and the field becomes empty

And you get the default text color.

If i /q the server without restarting and i rejoin i still have my Fontcolor.

If the server gets restarted at all then i run in to the mysql database field becoming empty after using the /ooc command
Reply
#4

I have edited my first post. Hopefully people can better understand it.
Reply
#5

No one has no idea?

The enum for it is

pFontColor[64]
Reply
#6

I guess i have to find another way to do this since no one has any idea it's doing what it's doing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)