help please
#1

can someone please help me i added this under

public OnplayerText

Код:
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pName,sizeof(pName));
    format(string,sizeof(string),"%s[%i]: %s",pName,playerid,text);
    printf(string);
    SendClientMessageToAll( blue,string);
so that i can get ids in messages

look what happened



it is posting double messages

my full onplayer text
Код:
//==============================OnPlayerText====================================
public OnPlayerText(playerid, text[])
{
	if(IsIPInText(text)) {
	    SendClientMessage(playerid,RED,"You are not allowed to use IP adresses in your chat!");
		return 1;
	}
	if(text[0] == '#' && PlayerInfo[playerid][Level] >= 1) {
	    new string[128]; GetPlayerName(playerid,string,sizeof(string));
		format(string,sizeof(string),"Admin Chat: %s: %s",string,text[1]);
		MessageToAdmins(green,string);
	    return 0;
	}
	if(text[0] == '!') {
		new gangChat[128];
		new senderName[MAX_PLAYER_NAME];
		new string[128];
		strmid(gangChat,text,1,strlen(text));
		GetPlayerName(playerid, senderName, sizeof(senderName));
		format(string, sizeof(string),"%s: %s", senderName, gangChat);
		for(new i = 0; i < MAX_PLAYERS; i++) {
		    if(PlayerInfo[i][team] == PlayerInfo[playerid][team]) {
				SendClientMessage(i, COLOR_YELLOW, string);
			}
		}
		return 0;
	}
	for(new i = 1; i < MAX_CHAT_LINES-1; i++) Chat[i] = Chat[i+1];
 	new ChatSTR[128]; GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR)); format(ChatSTR,128,"[lchat]%s: %s",ChatSTR, text[0] );
	Chat[MAX_CHAT_LINES-1] = ChatSTR;
	if(PlayerInfo[playerid][Caps] == 1) UpperToLower(text);
	if(ServerInfo[NoCaps] == 1) UpperToLower(text);
	if(ServerInfo[DisableChat] == 1) {
		SendClientMessage(playerid,red,"Chat has been disabled");
	 	return 0;
	}
 	if(PlayerInfo[playerid][Muted] == 1)
	{
 		PlayerInfo[playerid][MuteWarnings]++;
 		new string[128];
		if(PlayerInfo[playerid][MuteWarnings] < ServerInfo[MaxMuteWarnings]) {
			format(string, sizeof(string),"WARNING: You are muted, if you continue to speak you will be kicked. (%d / %d)", PlayerInfo[playerid][MuteWarnings], ServerInfo[MaxMuteWarnings] );
			SendClientMessage(playerid,red,string);
		} else {
			SendClientMessage(playerid,red,"You have been warned ! Now you have been kicked");
			format(string, sizeof(string),"***%s (ID %d) was kicked for exceeding mute warnings", PlayerName2(playerid), playerid);
			SendClientMessageToAll(grey,string);
			SaveToFile("KickLog",string); Kick(playerid);
		}
		return 0;
	}

	if(ServerInfo[AntiSpam] == 1 && (PlayerInfo[playerid][Level] == 0 && !IsPlayerAdmin(playerid)) )
	{
		if(PlayerInfo[playerid][SpamCount] == 0) PlayerInfo[playerid][SpamTime] = TimeStamp();

	    PlayerInfo[playerid][SpamCount]++;
		if(TimeStamp() - PlayerInfo[playerid][SpamTime] > SPAM_TIMELIMIT) { // Its OK your messages were far enough apart
			PlayerInfo[playerid][SpamCount] = 0;
			PlayerInfo[playerid][SpamTime] = TimeStamp();
		}
		else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS) {
			new string[64]; format(string,sizeof(string),"%s has been kicked (Flood/Spam Protection)", PlayerName2(playerid));
			SendClientMessageToAll(grey,string); print(string);
			SaveToFile("KickLog",string);
			Kick(playerid);
		}
		else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS-1) {
			SendClientMessage(playerid,red,"Anti Spam Warning! Next is a kick.");
			return 0;
		}
	}
	if(ServerInfo[AntiSwear] == 1 && PlayerInfo[playerid][Level] < ServerInfo[MaxAdminLevel])
	for(new s = 0; s < ForbiddenWordCount; s++)
    {
		new pos;
		while((pos = strfind(text,ForbiddenWords[s],true)) != -1) for(new i = pos, j = pos + strlen(ForbiddenWords[s]); i < j; i++) text[i] = '*';
	}
	
	if (Calling[playerid] > -1 && Answered[playerid] == 1)
	{
		new string[128];
		new sendername[MAX_PLAYER_NAME];
		GetPlayerName(playerid, sendername, sizeof(sendername));
		format(string, sizeof(string), "%s: %s", sendername, text);
		SendClientMessage(Calling[playerid], COLOR_YELLOW, string);
		format(string, sizeof(string), "%s: %s", sendername, text);
		SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
		format(string, sizeof(string), "%s: %s", sendername, text);
		print(string);
		format(string, sizeof(string), "%s: %s", sendername, text);
		print(string);
		return 0;
	}
	else
	{
		new to_others[MAX_CHATBUBBLE_LENGTH+1];
		format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
		SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
	}
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pName,sizeof(pName));
    format(string,sizeof(string),"%s[%i]: %s",pName,playerid,text);
    printf(string);
    SendClientMessageToAll( blue,string);

	return 1;
}
Reply
#2

pawn Код:
//==============================OnPlayerText====================================
public OnPlayerText(playerid, text[])
{
    if(IsIPInText(text)) {
        SendClientMessage(playerid,RED,"You are not allowed to use IP adresses in your chat!");
        return 1;
    }
    if(text[0] == '#' && PlayerInfo[playerid][Level] >= 1) {
        new string[128]; GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"Admin Chat: %s: %s",string,text[1]);
        MessageToAdmins(green,string);
        return 0;
    }
    if(text[0] == '!') {
        new gangChat[128];
        new senderName[MAX_PLAYER_NAME];
        new string[128];
        strmid(gangChat,text,1,strlen(text));
        GetPlayerName(playerid, senderName, sizeof(senderName));
        format(string, sizeof(string),"%s: %s", senderName, gangChat);
        for(new i = 0; i < MAX_PLAYERS; i++) {
            if(PlayerInfo[i][team] == PlayerInfo[playerid][team]) {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
        return 0;
    }
    for(new i = 1; i < MAX_CHAT_LINES-1; i++) Chat[i] = Chat[i+1];
    new ChatSTR[128]; GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR)); format(ChatSTR,128,"[lchat]%s: %s",ChatSTR, text[0] );
    Chat[MAX_CHAT_LINES-1] = ChatSTR;
    if(PlayerInfo[playerid][Caps] == 1) UpperToLower(text);
    if(ServerInfo[NoCaps] == 1) UpperToLower(text);
    if(ServerInfo[DisableChat] == 1) {
        SendClientMessage(playerid,red,"Chat has been disabled");
        return 0;
    }
    if(PlayerInfo[playerid][Muted] == 1)
    {
        PlayerInfo[playerid][MuteWarnings]++;
        new string[128];
        if(PlayerInfo[playerid][MuteWarnings] < ServerInfo[MaxMuteWarnings]) {
            format(string, sizeof(string),"WARNING: You are muted, if you continue to speak you will be kicked. (%d / %d)", PlayerInfo[playerid][MuteWarnings], ServerInfo[MaxMuteWarnings] );
            SendClientMessage(playerid,red,string);
        } else {
            SendClientMessage(playerid,red,"You have been warned ! Now you have been kicked");
            format(string, sizeof(string),"***%s (ID %d) was kicked for exceeding mute warnings", PlayerName2(playerid), playerid);
            SendClientMessageToAll(grey,string);
            SaveToFile("KickLog",string); Kick(playerid);
        }
        return 0;
    }

    if(ServerInfo[AntiSpam] == 1 && (PlayerInfo[playerid][Level] == 0 && !IsPlayerAdmin(playerid)) )
    {
        if(PlayerInfo[playerid][SpamCount] == 0) PlayerInfo[playerid][SpamTime] = TimeStamp();

        PlayerInfo[playerid][SpamCount]++;
        if(TimeStamp() - PlayerInfo[playerid][SpamTime] > SPAM_TIMELIMIT) { // Its OK your messages were far enough apart
            PlayerInfo[playerid][SpamCount] = 0;
            PlayerInfo[playerid][SpamTime] = TimeStamp();
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS) {
            new string[64]; format(string,sizeof(string),"%s has been kicked (Flood/Spam Protection)", PlayerName2(playerid));
            SendClientMessageToAll(grey,string); print(string);
            SaveToFile("KickLog",string);
            Kick(playerid);
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS-1) {
            SendClientMessage(playerid,red,"Anti Spam Warning! Next is a kick.");
            return 0;
        }
    }
    if(ServerInfo[AntiSwear] == 1 && PlayerInfo[playerid][Level] < ServerInfo[MaxAdminLevel])
    for(new s = 0; s < ForbiddenWordCount; s++)
    {
        new pos;
        while((pos = strfind(text,ForbiddenWords[s],true)) != -1) for(new i = pos, j = pos + strlen(ForbiddenWords[s]); i < j; i++) text[i] = '*';
    }
   
    if (Calling[playerid] > -1 && Answered[playerid] == 1)
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(Calling[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        print(string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        print(string);
        return 0;
    }
    else
    {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
    }
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pName,sizeof(pName));
    format(string,sizeof(string),"%s[%i]: %s",pName,playerid,text);
    printf(string);
    SendClientMessageToAll( blue,string);

    return 0;
}
Reply
#3

Returning 0 at the end of the callback, will send the custom chat and will ignore the default one.
Reply
#4

but man u can see it is like this

Hello [0]: hi everyone

i want it like this

hello [0]: hi everyone

or with no color because it has different random colors automatically each skin has its different colors
Reply
#5

pawn Код:
//==============================OnPlayerText====================================
public OnPlayerText(playerid, text[])
{
    if(IsIPInText(text)) {
        SendClientMessage(playerid,RED,"You are not allowed to use IP adresses in your chat!");
        return 1;
    }
    if(text[0] == '#' && PlayerInfo[playerid][Level] >= 1) {
        new string[128]; GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"Admin Chat: %s: %s",string,text[1]);
        MessageToAdmins(green,string);
        return 0;
    }
    if(text[0] == '!') {
        new gangChat[128];
        new senderName[MAX_PLAYER_NAME];
        new string[128];
        strmid(gangChat,text,1,strlen(text));
        GetPlayerName(playerid, senderName, sizeof(senderName));
        format(string, sizeof(string),"%s: %s", senderName, gangChat);
        for(new i = 0; i < MAX_PLAYERS; i++) {
            if(PlayerInfo[i][team] == PlayerInfo[playerid][team]) {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
        return 0;
    }
    for(new i = 1; i < MAX_CHAT_LINES-1; i++) Chat[i] = Chat[i+1];
    new ChatSTR[128]; GetPlayerName(playerid,ChatSTR,sizeof(ChatSTR)); format(ChatSTR,128,"[lchat]%s: %s",ChatSTR, text[0] );
    Chat[MAX_CHAT_LINES-1] = ChatSTR;
    if(PlayerInfo[playerid][Caps] == 1) UpperToLower(text);
    if(ServerInfo[NoCaps] == 1) UpperToLower(text);
    if(ServerInfo[DisableChat] == 1) {
        SendClientMessage(playerid,red,"Chat has been disabled");
        return 0;
    }
    if(PlayerInfo[playerid][Muted] == 1)
    {
        PlayerInfo[playerid][MuteWarnings]++;
        new string[128];
        if(PlayerInfo[playerid][MuteWarnings] < ServerInfo[MaxMuteWarnings]) {
            format(string, sizeof(string),"WARNING: You are muted, if you continue to speak you will be kicked. (%d / %d)", PlayerInfo[playerid][MuteWarnings], ServerInfo[MaxMuteWarnings] );
            SendClientMessage(playerid,red,string);
        } else {
            SendClientMessage(playerid,red,"You have been warned ! Now you have been kicked");
            format(string, sizeof(string),"***%s (ID %d) was kicked for exceeding mute warnings", PlayerName2(playerid), playerid);
            SendClientMessageToAll(grey,string);
            SaveToFile("KickLog",string); Kick(playerid);
        }
        return 0;
    }

    if(ServerInfo[AntiSpam] == 1 && (PlayerInfo[playerid][Level] == 0 && !IsPlayerAdmin(playerid)) )
    {
        if(PlayerInfo[playerid][SpamCount] == 0) PlayerInfo[playerid][SpamTime] = TimeStamp();

        PlayerInfo[playerid][SpamCount]++;
        if(TimeStamp() - PlayerInfo[playerid][SpamTime] > SPAM_TIMELIMIT) { // Its OK your messages were far enough apart
            PlayerInfo[playerid][SpamCount] = 0;
            PlayerInfo[playerid][SpamTime] = TimeStamp();
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS) {
            new string[64]; format(string,sizeof(string),"%s has been kicked (Flood/Spam Protection)", PlayerName2(playerid));
            SendClientMessageToAll(grey,string); print(string);
            SaveToFile("KickLog",string);
            Kick(playerid);
        }
        else if(PlayerInfo[playerid][SpamCount] == SPAM_MAX_MSGS-1) {
            SendClientMessage(playerid,red,"Anti Spam Warning! Next is a kick.");
            return 0;
        }
    }
    if(ServerInfo[AntiSwear] == 1 && PlayerInfo[playerid][Level] < ServerInfo[MaxAdminLevel])
    for(new s = 0; s < ForbiddenWordCount; s++)
    {
        new pos;
        while((pos = strfind(text,ForbiddenWords[s],true)) != -1) for(new i = pos, j = pos + strlen(ForbiddenWords[s]); i < j; i++) text[i] = '*';
    }
   
    if (Calling[playerid] > -1 && Answered[playerid] == 1)
    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(Calling[playerid], COLOR_YELLOW, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        print(string);
        format(string, sizeof(string), "%s: %s", sendername, text);
        print(string);
        return 0;
    }
    else
    {
        new to_others[MAX_CHATBUBBLE_LENGTH+1];
        format(to_others,MAX_CHATBUBBLE_LENGTH,"Says: %s",text);
        SetPlayerChatBubble(playerid,to_others,MESSAGE_COLOR,35.0,10000);
    }
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pName,sizeof(pName));
    format(string,sizeof(string),"%s[%i]:{FFFFFF} %s",pName,playerid,text);
    printf(string);
    SendClientMessageToAll( blue,string);

    return 0;
}
Reply
#6

im saying that will also color the name in my script each skin has different colors is there any way i can put id without disturbance of these colors

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 29 seconds.

Reply
#7

Did you try my code above?It works since you can easily change the color of the script by using {FFFFFF} between the name ID and the text.
Reply
#8

ok testing
Reply
#9

man still same problem im saying by default my names color is green by this skin and ther skin it is blue or red my names coour changes by skin but after this any skin i use color is blue only
Reply
#10

Because you send the message in blue.
pawn Код:
SendClientMessageToAll( blue,string);
Switch through the teams/skins and use the color you want depending on the teams.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)