open.mp forum
[Pawn] How to save message with custom color to database? - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] How to save message with custom color to database? (/showthread.php?tid=1321)



How to save message with custom color to database? - Zow - 2020-11-06

PHP Code:
CMD:save(playeridparams[])
{
? ? new 
message[100];
? ? 
sscanf(params"s[100]"message);
? ? 
format(PlayerInfo[playerid][pMessage], 100message);
    
SaveMessage(playerid);
? ? return 
1;
}
CMD:show(playeridparams[])
{
? ? new 
string[100];
? ? if (!
strcmp(PlayerInfo[playerid][pMessage], "None"true))
? ? ? ? ?return 
SendClientMessage(playeridCOLOR_YELLOW"No message");

? ? 
format(stringsizeof string"%s"PlayerInfo[playerid][pMessage]);
? ? 
SendClientMessage(playeridCOLOR_WHITEstring);
? ? return 
1;
}
SaveMessage(playerid)
{
    new 
query[256];
    
mysql_format(dbConquerysizeof(query), "UPDATE `players` SET `MessageText` = '%e' WHERE `ID` = '%d'",
    
PlayerInfo[playerid][pMessage],
    
PlayerInfo[playerid][pSQLID]);
    
mysql_tquery(dbConquery);
    return 
1;


/save {F60000}Message {FFFFFF}Message
But its only save Message?Message?
This is what I want
[Image: unknown.png]


RE: How to save message with custom color to database? - Pinch - 2020-11-06

Code:
CMD:save(playerid, params[]
{
    const MESSAGE_LENGTH_LIMIT = 100;
    if (strlen(params) > MESSAGE_LENGTH_LIMIT)
        return 0; // You probably want to return error message to player here.
        
    strcpy(PlayerInfo[playerid][pMessage], params);
    SaveMessage(playerid);
    return 1;
}



RE: How to save message with custom color to database? - Zow - 2020-11-06

(2020-11-06, 07:30 PM)Pinch Wrote:
Code:
CMD:save(playerid, params[]

{

? ? const MESSAGE_LENGTH_LIMIT = 100;

? ? if (strlen(params) > MESSAGE_LENGTH_LIMIT)

? ? ? ? return 0; // You probably want to return error message to player here.

? ? ? ?

? ? strcpy(PlayerInfo[playerid][pMessage], params);

? ? SaveMessage(playerid);

? ? return 1;

}



The problem is when I do /save {FF0000}Test{FFFFFF}Test

Its only save TestTest not full message

[Image: unknown.png]


RE: How to save message with custom color to database? - Josh - 2020-11-06

Colour codes get removed by SA-MP when a player sends them.


RE: How to save message with custom color to database? - Pinch - 2020-11-06

(2020-11-06, 07:40 PM)Josh Wrote: Colour codes get removed by SA-MP when a player sends them.

They aren't removed when they're sent to the dialogs I think so they can do it via dialog



I thought sscanf removes them, oopsie


RE: How to save message with custom color to database? - Zow - 2020-11-06

Any idea how to do this in other way?



https://youtu.be/m9oY8dXgNPY?t=91



This is what I try to do but I don't know how he save the color


RE: How to save message with custom color to database? - Pinch - 2020-11-06

(2020-11-06, 07:49 PM)Zow Wrote: Any idea how to do this in other way?



https://youtu.be/m9oY8dXgNPY?t=91



This is what I try to do but I don't know how he save the color

Dialogs...



OnDialogResponse, dialog style inputtext, inputtext[]...?


RE: How to save message with custom color to database? - Zow - 2020-11-06

(2020-11-06, 07:51 PM)Pinch Wrote:
(2020-11-06, 07:49 PM)Zow Wrote: Any idea how to do this in other way?



https://youtu.be/m9oY8dXgNPY?t=91



This is what I try to do but I don't know how he save the color

Dialogs...



OnDialogResponse, dialog style inputtext, inputtext[]...?



I was late sorry just post before reading your comment?

Now its worked