• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] How to save message with custom color to database?
#1
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]
  Reply
#2
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;
}
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#3
(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]
  Reply
#4
Colour codes get removed by SA-MP when a player sends them.
  Reply
#5
(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
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#6
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
  Reply
#7
(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[]...?
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#8
(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
  Reply


Forum Jump: