SA-MP Forums Archive
I need help to complete the code, please. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: I need help to complete the code, please. (/showthread.php?tid=653112)



I need help to complete the code, please. - RichKiez - 26.04.2018

1. Now I want to make a command to send a message to the player, through a new function:
Example:
Код:
SendTextPlayer(playerid, RESOURCE, color);
2. Here "RESOURCE" I will define for each section
Example:
Код:
#define EROR_TEXT      1
#define TEXT_INFO       2
#define TEXT_GUN        3
3. And every define I will format the text in a new stock
Example:
Код:
stock TextPlayer(playerid)
{
    new string[128];
    case EROR_TEXT: format(string, sizeof(string), "Command incorrect.");
    case TEXT_INFO: format(string, sizeof(string), "This is Test.");
    case TEXT_GUN: format(string, sizeof(string), "This is Gun Test.");
    return 1;
}
4. And this is what I want, when the function is initialized
Код:
SendTextPlayer(playerid, EROR_TEXT, 0xFFFFFFFF);
It will send to that player: "Command incorrect"
I hope everyone will help me, let me finish it.


Re: I need help to complete the code, please. - CrystalGamer - 26.04.2018

you can do it by this
PHP код:
stock SendPlayerText(playeridmessagecolor)
{
    new 
string[128];
    case 
EROR_TEXTformat(stringsizeof(string), "Command incorrect.");
    case 
TEXT_INFOformat(stringsizeof(string), "This is Test.");
    case 
TEXT_GUNformat(stringsizeof(string), "This is Gun Test.");
    
SendClientMessage(playeridcolormessage);
    return 
1;

you can use it like this
SendPlayerText(playerid, EROR_TEXT, COLOR_BLUE);

or use this code

PHP код:
new  EROR_TEXTTEXT_INFOTEXT_GUN;
stock SendPlayerText(playeridmessagecolor)
{
    if(
message == EROR_TEXT)
    {
     
SendClientMessage(playeridcolor"Command incorrect.");
    }
    if(
message == TEXT_INFO)
    {
     
SendClientMessage(playeridcolor"This is Test.");
    }
    if(
message == TEXT_GUN)
    {
     
SendClientMessage(playeridcolor"This is Gun Test.");
    }
    return 
1;
}
//SendPlayerText(playerid, EROR_TEXT, COLOR_BLUE);