PDA

View Full Version : Question to chat in the game


styl3raaa
03/10/2011, 01:20 PM
http://files.penchev-bg.eu/fo9jn.png

How do to write and then IDІto name. Example: [BG] Styl3r (ID: 0): dsa

Kostas'
03/10/2011, 01:24 PM
public OnPlayerText(playerid, text[])
{
///{FFFFFF} = White
new name[24], string[128]; GetPlayerName(playerid, name, sizeof name);
format(string, sizeof string, "{FFFFFF}%i %s: %s ", playerid, name, text);
SendClientMessageToAll(GetPlayerColor(playerid), string);
return 0;
}

Also, if you want ID after the name this

format(string, sizeof string, "{FFFFFF}%s %i : %s ", playerid, name, text);

Jafet_Macario
03/10/2011, 01:29 PM
public OnPlayerText(playerid, text[])
{
new
string[128],
name[MAX_PLAYER_NAME]
;
format(string, sizeof(string),"%s (ID: %d): %s", name, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), string);
return false;
}

styl3raaa
03/10/2011, 01:50 PM
@ Jafet_Macario with your code does not show my name and the text is black

Jafet_Macario
03/10/2011, 01:57 PM
Sorry, typo.public OnPlayerText(playerid, text[])
{
new
string[128],
name[MAX_PLAYER_NAME]
;
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),"%s (ID: %d): %s", name, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), string);
return false;
}

styl3raaa
03/10/2011, 01:58 PM
Again all black

Jafet_Macario
03/10/2011, 02:08 PM
Well, if you want another color you can:SendClientMessageToAll(YOUR_COLOR, string);

Change YOUR_COLOR to the color you want.

If you want to show as: (RED)MyName: (BLACK)ID( 0 ) (GREEN)Text. Use HEX Colours

http://wiki.sa-mp.com/wiki/Hex_colours

Example: format(string,sizeof(string),"{FF0000}%s {000000}(ID: %d): {00FF22}%s", name, playerid, text);
SendClientMessageToAll(-1, string);

It will do: MyName (ID: MyID): MyText

iPLEOMAX
03/10/2011, 02:26 PM
Add this to the top of your script:
(Thanks to: http://wiki.sa-mp.com/wiki/ColorFix)
new PlayerColors[200] = {
0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495 EDFF,0xf0e68cFF,0x778899FF,0xFF1493FF,0xF4A460FF,
0xEE82EEFF,0xFFD720FF,0x8b4513FF,0x4949A0FF,0x148b 8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,0x10DC29FF,
0x534081FF,0x0495CDFF,0xEF6CE8FF,0xBD34DAFF,0x247C 1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,0x65ADEBFF,
0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB 10FF,0x54137DFF,0x275222FF,0xF09F5BFF,0x3D0A4FFF,
0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,0x3793 FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF,0x057F94FF,
0xB98519FF,0x388EEAFF,0x028151FF,0xA55043FF,0x0DE0 18FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,0x18F71FFF,
0x4B8987FF,0x491B9EFF,0x829DC7FF,0xBCE635FF,0xCEA6 DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,0x12D6D4FF,
0x48C000FF,0x2A51E2FF,0xE3AC12FF,0xFC42A8FF,0x2FC8 27FF,0x1A30BFFF,0xB740C2FF,0x42ACF5FF,0x2FD9DEFF,
0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x94436EFF,0xC1F7 ECFF,0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,0x3214AAFF,
0x184D3BFF,0xAE4B99FF,0x7E49D7FF,0x4C436EFF,0xFA24 CCFF,0xCE76BEFF,0xA04E0AFF,0x9F945CFF,0xDCDE3DFF,
0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152 C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,0xD8C762FF,
0xD8C762FF,0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC14 3CFF,0x6495EDFF,0xf0e68cFF,0x778899FF,0xFF1493FF,
0xF4A460FF,0xEE82EEFF,0xFFD720FF,0x8b4513FF,0x4949 A0FF,0x148b8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,
0x10DC29FF,0x534081FF,0x0495CDFF,0xEF6CE8FF,0xBD34 DAFF,0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,
0x65ADEBFF,0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39 AAFF,0x53EB10FF,0x54137DFF,0x275222FF,0xF09F5BFF,
0x3D0A4FFF,0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB9 35FF,0x3793FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF,
0x057F94FF,0xB98519FF,0x388EEAFF,0x028151FF,0xA550 43FF,0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,
0x18F71FFF,0x4B8987FF,0x491B9EFF,0x829DC7FF,0xBCE6 35FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,
0x12D6D4FF,0x48C000FF,0x2A51E2FF,0xE3AC12FF,0xFC42 A8FF,0x2FC827FF,0x1A30BFFF,0xB740C2FF,0x42ACF5FF,
0x2FD9DEFF,0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x9443 6EFF,0xC1F7ECFF,0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,
0x3214AAFF,0x184D3BFF,0xAE4B99FF,0x7E49D7FF,0x4C43 6EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF,0x9F945CFF,
0xDCDE3DFF,0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2C D7FF,0x6152C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,
0xD8C762FF,0xD8C762FF
};

And this in "OnPlayerConnect":
SetPlayerColor( playerid, PlayerColors[ random(sizeof PlayerColors) ] );

Now:

OnPlayerText(playerid, text[])
{
new ftext[128], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
format(ftext, sizeof ftext, "%s (ID:%i): %s", PlayerName, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), ftext);
return true;
}

styl3raaa
03/10/2011, 02:32 PM
C:\Documents and Settings\Petromir Penchev\Desktop\server\gamemodes\driftmod.pwn(134) : error 017: undefined symbol "PlayerColors"
C:\Documents and Settings\Petromir Penchev\Desktop\server\gamemodes\driftmod.pwn(134) : error 017: undefined symbol "PlayerColors"
C:\Documents and Settings\Petromir Penchev\Desktop\server\gamemodes\driftmod.pwn(134) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Petromir Penchev\Desktop\server\gamemodes\driftmod.pwn(134) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

Line 134
SetPlayerColor( playerid, PlayerColors[ random(sizeof PlayerColors) ] );

iPLEOMAX
03/10/2011, 02:33 PM
Where did you place "PlayerColors[200]" ?

styl3raaa
03/10/2011, 02:43 PM
I copy and paste after


#define COLOR_AQUAGREEN 0x03D687FF
#define COLOR_NICESKY 0x99FFFFAA
#define COLOR_WHITE 0xFFFFFFFF
#define V_FILE_SAVE "vehiclelists"
#define VERSION 1.0
#if defined FILTERSCRIPT

iPLEOMAX
03/10/2011, 02:51 PM
#define COLOR_AQUAGREEN 0x03D687FF
#define COLOR_NICESKY 0x99FFFFAA
#define COLOR_WHITE 0xFFFFFFFF
#define V_FILE_SAVE "vehiclelists"
#define VERSION 1.0
//Paste it here... <-------------------------------------
#if defined FILTERSCRIPT

styl3raaa
03/10/2011, 02:59 PM
Thanks :)