ID Show in Main Chat
#1

Title says all, also I already searched a thousand times for this and haven't found an answer.
I've asked people all over the place and haven't got it the way I wanted.

Ok First, In Main chat I want it to show your (id) by your name when you chat.
Example:
DrPepper(id): Hey guys
Sprite(id): Hey bro

^As you see the id by your name is shown.

Do I need to edit something in the callback: Public OnPlayerText(playerid, text[])
Please respond to this, Thanks!
Reply
#2

Just put your OnPlayerText callback to return 0;, it will make the normal global chat stops.

After that, just use SendClientMessageToAll + format functions:

I did a example for you :

pawn Код:
public OnPlayerText(playerid, text[])
{
    new textvar[128], PlayerNickName[25];
    GetPlayerName(playerid,PlayerNickName,25);
    format(textvar,128,"{33CCFF}%s(%d): {FFFFFF}%s",PlayerNickName,playerid,text);
    SendClientMessage(playerid, 0xFFFFFFAA,textvar);
    return 0;
}
I hope that i have helped
Reply
#3

Try this simple:
pawn Код:
public OnPlayerText(playerid,text[])
{
    new string[128];
    format(string, sizeof(string), "(%i)%s",playerid, text);
    SendPlayerMessageToAll(playerid, string);
    return 0;
}
Reply
#4

Код:
public OnPlayerText(playerid, text[])
{
	if(text[0] == '!') {
		if(playerGang[playerid] > 0) {
		    new gangChat[256];
		    new senderName[MAX_PLAYER_NAME];
		    new string[256];

//		    for(new i = 1; i < strlen(text)+1; i++)
//				gangChat[i]=text[i];

			strmid(gangChat,text,1,strlen(text));

			GetPlayerName(playerid, senderName, sizeof(senderName));
			format(string, sizeof(string),"%s: %s", senderName, gangChat);

			for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++) {
				SendClientMessage(gangMembers[playerGang[playerid]][i], COLOR_LIGHTBLUE, string);
			}
		}

		return 0;
	}
	return 1;
}
Correct it please i also wants that playerid must be shown in chat but a gangchat is also included in it !!!!!!!
Reply
#5

Thank you Clive, works.
Wow, I just found a relative topic to this..I'm so lame.

https://sampforum.blast.hk/showthread.php?tid=67611 <- For anyone else or use this topic.
Reply
#6

OMG! No..

rjjj, in your code message would be show to sender, not players...

Clive, in your code, ID would be after text, like that:
Код:
[ACF]OKStyle: blablabla(0)
Use this, very simple and usefull:

pawn Код:
public OnPlayerText(playerid, text[]) // by Ym[0]n
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(text, 1024, "%s(%d): {FFFFFF}%s", PlayerName, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), text);
return 0;  
}
Reply
#7

Quote:
Originally Posted by OKStyle
Посмотреть сообщение
OMG! No..

rjjj, in your code message would be show to sender, not players...

Clive, in your code, ID would be after text, like that:
Код:
[ACF]OKStyle: blablabla(0)
Use this, very simple and usefull:

pawn Код:
public OnPlayerText(playerid, text[]) // by Ym[0]n
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(text, 1024, "%s(%d): {FFFFFF}%s", PlayerName, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), text);
return 0;  
}
Im sorry, dude it is just working fine, im using it.
Reply
#8

Quote:
Originally Posted by wheelman_WM
Посмотреть сообщение
Код:
public OnPlayerText(playerid, text[])
{
	if(text[0] == '!') {
		if(playerGang[playerid] > 0) {
		    new gangChat[256];
		    new senderName[MAX_PLAYER_NAME];
		    new string[128];

		    for(new i = 1; i < strlen(text)+1; i++)
				gangChat[i]=text[i];

			strmid(gangChat,text,1,strlen(text));

			GetPlayerName(playerid, senderName, sizeof(senderName));
			format(string, sizeof(string),"%s: %s", senderName, gangChat);

			for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++) {
				SendClientMessage(gangMembers[playerGang[playerid]][i], COLOR_LIGHTBLUE, string);
			}
		}

		return 0;
	}
	return 1;
}
Correct it please i also wants that playerid must be shown in chat but a gangchat is also included in it !!!!!!!
try this...
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '!') {
        if(playerGang[playerid] > 0) {
            new gangChat[256];
            new senderName[MAX_PLAYER_NAME];
            new string[256];

//          for(new i = 1; i < strlen(text)+1; i++)
//              gangChat[i]=text[i];

            strmid(gangChat,text,1,strlen(text));

            GetPlayerName(playerid, senderName, sizeof(senderName));
            format(string, sizeof(string),"%s(id:%d): %s", senderName,playerid, gangChat);

            for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++) {
                SendClientMessage(gangMembers[playerGang[playerid]][i], COLOR_LIGHTBLUE, string);
            }
        }

        return 0;
    }
    return 1;
}
Reply
#9

still not working :P
Reply
#10

Quote:
Originally Posted by wheelman_WM
Посмотреть сообщение
still not working :P
i am not sure if it'll work now but i know that i forgot to change the string[256] >>>> string[128];
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '!') {
        if(playerGang[playerid] > 0) {
            new gangChat[256];
            new senderName[MAX_PLAYER_NAME];
            new string[128];

              for(new i = 1; i < strlen(text)+1; i++)
              gangChat[i]=text[i];

            strmid(gangChat,text,1,strlen(text));

            GetPlayerName(playerid, senderName, sizeof(senderName));
            format(string, sizeof(string),"%s(id:%d): %s", senderName,playerid, gangChat);

            for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++) {
                SendClientMessage(gangMembers[playerGang[playerid]][i], COLOR_LIGHTBLUE, string);
            }
        }

        return 0;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)