30.12.2010, 18:45
(
Последний раз редактировалось ihatetn931; 31.12.2010 в 14:55.
Причина: new code
)
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
As you can see it's putting the color before the text i typed
After server restart
It dosen't put it in like it's suppose to
here is it getting loaded after server restart
After another restart. Note i haven't done anything to the database.
Here is the /ooc command
The command to set /fontcolor
Here is the recolor shiznit made by ******
So does anyone have any idea what it's doing what it's doing?
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
After server restart
Код:
[09:44:27] Test_User [1]: test
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
Код:
[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
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;
}
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;
}
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] = '}';
}
}
}