Local Chat
#1

Hello, everybody.
For some reason when players chat, anybody is able to see what they are saying, no matter where they are.
I've gone over this time and time again and I see nothing wrong with it. I have no idea why this is happening.

Help, please? <3 Rep shall be given.

pawn Код:
public OnPlayerText(playerid, text[]) {
    #if defined DEBUG
        printf("[debug] OnPlayerText(%d, %s)", playerid, text);
    #endif

    if(playerVariables[playerid][pStatus] >= 1 && playerVariables[playerid][pMuted] == 0) {

        GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
        for(new i = 0; i < strlen(szPlayerName); i++) {
            if(szPlayerName[i] == '_')
                szPlayerName[i] = ' ';
        }

        if(playerVariables[playerid][pPhoneCall] != -1) {
            format(szMessage, sizeof(szMessage), "[Phone] \"%s\"", text);
            SetPlayerChatBubble(playerid, szMessage, COLOR_CHATBUBBLE, 10.0, 10000);
            if(!strcmp(playerVariables[playerid][pAccent], "None", true))
                format(szMessage, sizeof(szMessage), "[Phone] %s says: %s", szPlayerName, text);
            else
                format(szMessage, sizeof(szMessage), "[Phone] (%s Accent) %s says: %s", playerVariables[playerid][pAccent], szPlayerName, text);

            nearByMessage(playerid, COLOR_WHITE, szMessage);

            switch (playerVariables[playerid][pPhoneCall]) {
                case 911: {
                    if(!strcmp(text, "LSPD", true) || !strcmp(text, "police", true)) {
                        SendClientMessage(playerid, COLOR_WHITE, "[Phone] 911: You have reached the Los Santos Police emergency hotline; can you describe the crime?");
                        playerVariables[playerid][pPhoneCall] = 912;
                    }
                    else if(!strcmp(text, "LSFMD", true) || !strcmp(text, "medic", true) || !strcmp(text, "ambulance", true)) {
                        SendClientMessage(playerid, COLOR_WHITE, "[Phone] 911: This is the Los Santos Fire & Medic Department emergency hotline; describe the emergency, please.");
                        playerVariables[playerid][pPhoneCall] = 914;
                    }
                    else SendClientMessage(playerid, COLOR_WHITE, "[Phone] 911: Sorry, I didn't quite understand that... speak again?");
                }
                case 912: {
                    if(strlen(text) > 1) {
                        new
                            location[MAX_ZONE_NAME];

                        GetPlayer2DZone(playerid, location, MAX_ZONE_NAME);
                        format(szMessage, sizeof(szMessage), "Dispatch: %s has reported: '%s' (10-20 %s)", szPlayerName, text, location);
                        SendToGroup(1, COLOR_RADIOCHAT, szMessage);

                        SendClientMessage(playerid, COLOR_WHITE, "[Phone] 911: Thank you for reporting this incident; a patrol unit is now on its way.");

                        SendClientMessage(playerid, COLOR_WHITE, "Your call has been terminated by the other party.");

                        if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USECELLPHONE) {
                            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
                        }
                        playerVariables[playerid][pPhoneCall] = -1;
                    }
                }
                case 914: {
                    if(strlen(text) > 1) {
                        new
                            location[MAX_ZONE_NAME];

                        GetPlayer2DZone(playerid, location, MAX_ZONE_NAME);
                        format(szMessage, sizeof(szMessage), "Dispatch: %s has reported '%s' (10-20 %s)", szPlayerName, text, location);
                        SendToGroupType(4, COLOR_RED, szMessage);

                        SendClientMessage(playerid, COLOR_WHITE, "[Phone] 911: Thank you for reporting this incident; we are on our way.");

                        SendClientMessage(playerid, COLOR_WHITE, "Your call has been terminated by the other party.");

                        if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USECELLPHONE)
                            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);

                        playerVariables[playerid][pPhoneCall] = -1;
                    }
                }
                default: { // If they're calling a player, this code is executed.
                    SendClientMessage(playerVariables[playerid][pPhoneCall], COLOR_GREY, szMessage);
                    mysql_real_escape_string(szMessage, szMessage);
                    format(szLargeString, sizeof(szLargeString), "INSERT INTO chatLogs (value, playerinternalid) VALUES('%s', '%d')", szMessage, playerVariables[playerid][pInternalID]);
                    mysql_query(szLargeString);
                }
            }
        }

        else {
            if(IsPlayerInAnyVehicle(playerid)) {
                new veh = GetPlayerVehicleID(playerid);
                if(!IsABoat(veh) && !IsAMBike(veh) && !IsABike(veh) && !IsAPlane(veh)) {
                    if(!vehicleVariables[veh][vVehicleWindows]) {
                        if(!strcmp(playerVariables[playerid][pAccent], "None", true)) {
                            format(szMessage, sizeof(szMessage), "[Vehicle] {FFFFFF}%s says: %s", szPlayerName, text);
                        }
                        else {
                            format(szMessage, sizeof(szMessage), "[Vehicle] (%s Accent) {FFFFFF}%s says: %s", playerVariables[playerid][pAccent], szPlayerName, text);
                        }
                        mysql_real_escape_string(szMessage, szMessage);
                        format(szLargeString, sizeof(szLargeString), "INSERT INTO chatLogs (value, playerinternalid) VALUES('%s', '%d')", szMessage, playerVariables[playerid][pInternalID]);
                        mysql_query(szLargeString);
                        playerVariables[playerid][pSpamCount]++;
                        foreach(Player, i) {
                            if(GetPlayerVehicleID(i) == veh) {
                                SendClientMessage(i, COLOR_GREY, szMessage);
                            }
                        }
                        return 0; // you shouldn't remove that :)
                    }
                }
            }
           
            if(!strcmp(playerVariables[playerid][pAccent], "None", true)) {
                format(szMessage, sizeof(szMessage), "{FFFFFF}%s says: %s", szPlayerName, text);
            }
            else {
                format(szMessage, sizeof(szMessage), "(%s Accent) {FFFFFF}%s says: %s", playerVariables[playerid][pAccent], szPlayerName, text);
            }

            //if(playerVariables[playerid][pAdminDuty] >= 1) format(szMessage, sizeof(szMessage), "%s says: (( %s ))", szPlayerName, text);
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            foreach(Player, i) {
                if(IsPlayerInAnyVehicle(i)) {
                    new veh = GetPlayerVehicleID(i);
                    if(!IsABoat(veh) && !IsAMBike(veh) && !IsABike(veh) && !IsAPlane(veh)) {
                        if(vehicleVariables[veh][vVehicleWindows])
                            SendClientMessage(i, COLOR_GREY, szMessage);
                    }
                    else {
                        if(IsPlayerInRangeOfPoint(playerid, 12.0, pos[0], pos[1], pos[2]))
                            SendClientMessage(i, COLOR_GREY, szMessage);
                    }
                }
                else {
                    if(IsPlayerInRangeOfPoint(playerid, 12.0, pos[0], pos[1], pos[2]))
                        SendClientMessage(i, COLOR_GREY, szMessage);
                }
            }
            mysql_real_escape_string(szMessage, szMessage);
            format(szLargeString, sizeof(szLargeString), "INSERT INTO chatLogs (value, playerinternalid) VALUES('%s', '%d')", szMessage, playerVariables[playerid][pInternalID]);
            mysql_query(szLargeString);
            format(szMessage, sizeof(szMessage), "\"%s\"", text);
            SetPlayerChatBubble(playerid, szMessage, COLOR_CHATBUBBLE, 10.0, 10000);
        }

        playerVariables[playerid][pSpamCount]++;
    }
    return 0;
}
As far as I know, the problem is in this bit:

pawn Код:
//if(playerVariables[playerid][pAdminDuty] >= 1) format(szMessage, sizeof(szMessage), "%s says: (( %s ))", szPlayerName, text);
            new Float:pos[3];
            GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
            foreach(Player, i) {
                if(IsPlayerInAnyVehicle(i)) {
                    new veh = GetPlayerVehicleID(i);
                    if(!IsABoat(veh) && !IsAMBike(veh) && !IsABike(veh) && !IsAPlane(veh)) {
                        if(vehicleVariables[veh][vVehicleWindows])
                            SendClientMessage(i, COLOR_GREY, szMessage);
                    }
                    else {
                        if(IsPlayerInRangeOfPoint(playerid, 12.0, pos[0], pos[1], pos[2]))
                            SendClientMessage(i, COLOR_GREY, szMessage);
                    }
                }
                else {
                    if(IsPlayerInRangeOfPoint(playerid, 12.0, pos[0], pos[1], pos[2]))
                        SendClientMessage(i, COLOR_GREY, szMessage);
                }
            }
Reply
#2

What color are they sent in, grey or white?
Reply
#3

Quote:
Originally Posted by maramizo
Посмотреть сообщение
What color are they sent in, grey or white?
I'll hop in-game and check. Hold on.
Reply
#4

The accent appears grey, and after that is white, as it is set by the {FFFFFF}.
I commented out the section that I said was most likely causing it;
I could not say anything at all so I know for a fact that it is in there, somewhere.
Reply
#5

Bump.
Reply
#6

pawn Код:
else {
                        if(IsPlayerInRangeOfPoint(i, 12.0, pos[0], pos[1], pos[2]))
                            SendClientMessage(i, COLOR_GREY, szMessage);
                    }
                }
                else {
                    if(IsPlayerInRangeOfPoint(i, 12.0, pos[0], pos[1], pos[2]))
                        SendClientMessage(i, COLOR_GREY, szMessage);
                }
replaced
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 12.0, pos[0], pos[1], pos[2]))
with
pawn Код:
if(IsPlayerInRangeOfPoint(i, 12.0, pos[0], pos[1], pos[2]))
Your current code checks if the player using the chat is anywhere near his own position, you should check the reciever's distance to the player using the chat instead
Reply
#7

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
pawn Код:
else {
                        if(IsPlayerInRangeOfPoint(i, 12.0, pos[0], pos[1], pos[2]))
                            SendClientMessage(i, COLOR_GREY, szMessage);
                    }
                }
                else {
                    if(IsPlayerInRangeOfPoint(i, 12.0, pos[0], pos[1], pos[2]))
                        SendClientMessage(i, COLOR_GREY, szMessage);
                }
replaced
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 12.0, pos[0], pos[1], pos[2]))
with
pawn Код:
if(IsPlayerInRangeOfPoint(i, 12.0, pos[0], pos[1], pos[2]))
That would just make it submit to the person who typed it though, would it not? I have it looping through the players to check if they are near them, and if they are, it sends them the message that playerid wrote.

Edit: I think I see what you did, I'll try it. Hold on.

Edit 2: Worked. Fixed it. Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)