SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/10/2011, 01:20 PM   #1
styl3raaa
Little Clucker
 
styl3raaa's Avatar
 
Join Date: Oct 2009
Posts: 38
Reputation: 0
Default Question to chat in the game



How do to write and then IDІto name. Example: [BG] Styl3r (ID: 0): dsa
styl3raaa is offline   Reply With Quote
Old 03/10/2011, 01:24 PM   #2
Kostas'
High-roller
 
Kostas''s Avatar
 
Join Date: Sep 2011
Location: Athens, Greece
Posts: 1,063
Reputation: 101
Default Re: Question to chat in the game

pawn Code:
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
Code:
format(string, sizeof string, "{FFFFFF}%s %i : %s ", playerid, name, text);
Kostas' is offline   Reply With Quote
Old 03/10/2011, 01:29 PM   #3
Jafet_Macario
Huge Clucker
 
Jafet_Macario's Avatar
 
Join Date: Jul 2011
Posts: 439
Reputation: 67
Default Re: Question to chat in the game

pawn Code:
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;
}
__________________
Jafet_Macario is offline   Reply With Quote
Old 03/10/2011, 01:50 PM   #4
styl3raaa
Little Clucker
 
styl3raaa's Avatar
 
Join Date: Oct 2009
Posts: 38
Reputation: 0
Default Re: Question to chat in the game

@ Jafet_Macario with your code does not show my name and the text is black
styl3raaa is offline   Reply With Quote
Old 03/10/2011, 01:57 PM   #5
Jafet_Macario
Huge Clucker
 
Jafet_Macario's Avatar
 
Join Date: Jul 2011
Posts: 439
Reputation: 67
Default Re: Question to chat in the game

Sorry, typo.
pawn Code:
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;
}
__________________
Jafet_Macario is offline   Reply With Quote
Old 03/10/2011, 01:58 PM   #6
styl3raaa
Little Clucker
 
styl3raaa's Avatar
 
Join Date: Oct 2009
Posts: 38
Reputation: 0
Default Re: Question to chat in the game

Again all black
styl3raaa is offline   Reply With Quote
Old 03/10/2011, 02:08 PM   #7
Jafet_Macario
Huge Clucker
 
Jafet_Macario's Avatar
 
Join Date: Jul 2011
Posts: 439
Reputation: 67
Default Re: Question to chat in the game

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:
pawn Code:
format(string,sizeof(string),"{FF0000}%s {000000}(ID: %d): {00FF22}%s", name, playerid, text);
SendClientMessageToAll(-1, string);

It will do:
Code:
MyName (ID: MyID): MyText
__________________
Jafet_Macario is offline   Reply With Quote
Old 03/10/2011, 02:26 PM   #8
iPLEOMAX
High-roller
 
iPLEOMAX's Avatar
 
Join Date: Mar 2011
Location: AE
Posts: 1,250
Reputation: 746
Default Re: Question to chat in the game

Add this to the top of your script:
(Thanks to: http://wiki.sa-mp.com/wiki/ColorFix)
pawn Code:
new PlayerColors[200] = {
0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495EDFF,0xf0e68cFF,0x778899FF,0xFF1493FF,0xF4A460FF,
0xEE82EEFF,0xFFD720FF,0x8b4513FF,0x4949A0FF,0x148b8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,0x10DC29FF,
0x534081FF,0x0495CDFF,0xEF6CE8FF,0xBD34DAFF,0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,0x65ADEBFF,
0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB10FF,0x54137DFF,0x275222FF,0xF09F5BFF,0x3D0A4FFF,
0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,0x3793FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF,0x057F94FF,
0xB98519FF,0x388EEAFF,0x028151FF,0xA55043FF,0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,0x18F71FFF,
0x4B8987FF,0x491B9EFF,0x829DC7FF,0xBCE635FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,0x12D6D4FF,
0x48C000FF,0x2A51E2FF,0xE3AC12FF,0xFC42A8FF,0x2FC827FF,0x1A30BFFF,0xB740C2FF,0x42ACF5FF,0x2FD9DEFF,
0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x94436EFF,0xC1F7ECFF,0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,0x3214AAFF,
0x184D3BFF,0xAE4B99FF,0x7E49D7FF,0x4C436EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF,0x9F945CFF,0xDCDE3DFF,
0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,0xD8C762FF,
0xD8C762FF,0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495EDFF,0xf0e68cFF,0x778899FF,0xFF1493FF,
0xF4A460FF,0xEE82EEFF,0xFFD720FF,0x8b4513FF,0x4949A0FF,0x148b8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,
0x10DC29FF,0x534081FF,0x0495CDFF,0xEF6CE8FF,0xBD34DAFF,0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,
0x65ADEBFF,0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB10FF,0x54137DFF,0x275222FF,0xF09F5BFF,
0x3D0A4FFF,0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,0x3793FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF,
0x057F94FF,0xB98519FF,0x388EEAFF,0x028151FF,0xA55043FF,0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,
0x18F71FFF,0x4B8987FF,0x491B9EFF,0x829DC7FF,0xBCE635FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,
0x12D6D4FF,0x48C000FF,0x2A51E2FF,0xE3AC12FF,0xFC42A8FF,0x2FC827FF,0x1A30BFFF,0xB740C2FF,0x42ACF5FF,
0x2FD9DEFF,0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x94436EFF,0xC1F7ECFF,0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,
0x3214AAFF,0x184D3BFF,0xAE4B99FF,0x7E49D7FF,0x4C436EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF,0x9F945CFF,
0xDCDE3DFF,0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,
0xD8C762FF,0xD8C762FF
};

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

Now:
pawn Code:
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;
}
__________________
Goodbye SA-MP.
iPLEOMAX is offline   Reply With Quote
Old 03/10/2011, 02:32 PM   #9
styl3raaa
Little Clucker
 
styl3raaa's Avatar
 
Join Date: Oct 2009
Posts: 38
Reputation: 0
Default Re: Question to chat in the game

Code:
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
Code:
    SetPlayerColor( playerid, PlayerColors[ random(sizeof PlayerColors) ] );
styl3raaa is offline   Reply With Quote
Old 03/10/2011, 02:33 PM   #10
iPLEOMAX
High-roller
 
iPLEOMAX's Avatar
 
Join Date: Mar 2011
Location: AE
Posts: 1,250
Reputation: 746
Default Re: Question to chat in the game

Where did you place "PlayerColors[200]" ?
__________________
Goodbye SA-MP.
iPLEOMAX is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
In Game Chat zack3021 Help Archive 2 21/10/2010 02:17 AM
Chat with player In-Game while typing in the CMD Server Box Ihsan_Cingisiz Server Support 7 27/05/2010 07:18 PM
Chat / Game Lagging Like Fuck [03]Garsino Client Support 2 27/01/2010 08:23 AM
How do you chat in game? themasterbrewer Client Support 2 22/09/2009 08:14 PM
how to make a main chat, whisper, out of the game and say chats? Idan_McCartney Help Archive 7 09/05/2009 05:59 PM


All times are GMT. The time now is 07:31 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.