Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] How to save message with custom color to database?

 
  • 0 Vote(s) - 0 Average
Pawn How to save message with custom color to database?
Zow
Offline

Burgershot Member
Posts: 34
Threads: 20
Joined: Apr 2019
Reputation: 0
Location: Malaysia
#1
2020-11-06, 06:04 PM (This post was last modified: 2020-11-06, 06:55 PM by Zow.)
PHP Code:
CMD:save(playerid, params[])
{
    new message[100];
    sscanf(params, "s[100]", message);
    format(PlayerInfo[playerid][pMessage], 100, message);
    
SaveMessage(playerid);
    return 1;
}
CMD:show(playerid, params[])
{
    new string[100];
    if (!strcmp(PlayerInfo[playerid][pMessage], "None", true))
         return SendClientMessage(playerid, COLOR_YELLOW, "No message");

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

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

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#2
2020-11-06, 07:30 PM (This post was last modified: 2020-11-06, 07:30 PM by Pinch.)
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.
Zow
Offline

Burgershot Member
Posts: 34
Threads: 20
Joined: Apr 2019
Reputation: 0
Location: Malaysia
#3
2020-11-06, 07:39 PM
(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]
Josh
Offline

Administrator

Posts: 129
Threads: 1
Joined: Feb 2019
Reputation: 20
#4
2020-11-06, 07:40 PM
Colour codes get removed by SA-MP when a player sends them.
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#5
2020-11-06, 07:47 PM
(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.
Zow
Offline

Burgershot Member
Posts: 34
Threads: 20
Joined: Apr 2019
Reputation: 0
Location: Malaysia
#6
2020-11-06, 07:49 PM
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
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#7
2020-11-06, 07:51 PM
(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.
Zow
Offline

Burgershot Member
Posts: 34
Threads: 20
Joined: Apr 2019
Reputation: 0
Location: Malaysia
#8
2020-11-06, 07:53 PM
(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
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode