Removing a few lines
#1

Код:
public OnPlayerText(playerid, text[])
{
    if (!IsPlayerConnected( playerid )) return 0; // Check for undisconnected bug.
    new
        i,
        c;
    while ((c = text[i++])) if (c < 0x20 || c > 0x7E) return 0; // Check for illegal characters.
    
    if(PlayerInfo[playerid][ pMuted ]==1) {
       SendClientMessage(playerid, COLOR_RED, "You're muted!");
	   return 0;
	}
    
    if(LastText[playerid][0] != 0 && strcmp(LastText[playerid], text, false) == 0) {
        SendClientMessage(playerid, COLOR_RED, "[Failed] Do not repeat yourself."); // If successful, SendClientMessage() returns 1, so if you use return SendClientMessage, it will still send the player's text.
        return 0; // Blocking the text from being sent.
    }

    for(new j; j < sizeof(LastText[]); j++)
        LastText[playerid][j] = 0; // Wiping the array, so that messages shorter than the last message will not have the end of the last message on them.

    format(LastText[playerid], sizeof(LastText[]), text);


    if (text[0] == '!')
    {
		new string[256], name[24];
		GetPlayerName(playerid, name, 24);
		format(string, 256, "[TEAMCHAT] %s: %s", name, text[1]);
		for (new a=0; a<SLOTS; a++) {
			if (IsPlayerConnected(a)) {
				if (GetPlayerTeam(a) == GetPlayerTeam(playerid)) {
                    add_log( string );
				    SendClientMessage(a, AZTECAS_COLOR, string);
				}
			}
		}
		return 0;
	}

    return 1; // Sending the text if it was not the same as the player's last message.
}
I need to remove the

Код:
    if (text[0] == '!')
    {
		new string[256], name[24];
		GetPlayerName(playerid, name, 24);
		format(string, 256, "[TEAMCHAT] %s: %s", name, text[1]);
		for (new a=0; a<SLOTS; a++) {
			if (IsPlayerConnected(a)) {
				if (GetPlayerTeam(a) == GetPlayerTeam(playerid)) {
                    add_log( string );
				    SendClientMessage(a, AZTECAS_COLOR, string);
I tried to remove it but I got a few warnings about invalid declaration or whatever, so I just put it all back.

I'm not that good with aligning the return 1; and the brackets and alla that, so if someone can remove the TEAMCHAT and do it for me, it would be greatly appreciated. Thanks
Reply
#2

Код:
public OnPlayerText(playerid, text[])
{
    if (!IsPlayerConnected( playerid )) return 0; // Check for undisconnected bug.
    new
        i,
        c;
    while ((c = text[i++])) if (c < 0x20 || c > 0x7E) return 0; // Check for illegal characters.
    
    if(PlayerInfo[playerid][ pMuted ]==1) {
       SendClientMessage(playerid, COLOR_RED, "You're muted!");
	   return 0;
	}
    
    if(LastText[playerid][0] != 0 && strcmp(LastText[playerid], text, false) == 0) {
        SendClientMessage(playerid, COLOR_RED, "[Failed] Do not repeat yourself."); // If successful, SendClientMessage() returns 1, so if you use return SendClientMessage, it will still send the player's text.
        return 0; // Blocking the text from being sent.
    }

    for(new j; j < sizeof(LastText[]); j++)
        LastText[playerid][j] = 0; // Wiping the array, so that messages shorter than the last message will not have the end of the last message on them.

    format(LastText[playerid], sizeof(LastText[]), text);

    return 1; // Sending the text if it was not the same as the player's last message.
}
Reply
#3

if (!IsPlayerConnected( playerid )) return 0; // Check for undisconnected bug.

That made me laugh, obviously the player is connected if they typed the command duh....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)