Text dont show when passenger
#1

I made it so if you want to sit as passenger in a Shamal you will spawn inside the Shamal interior.
That works like it should.
But since the pilot and passengers then couldnt comunicate I tried to make it so it will send a message to the pilot/passenger if the shamal you're in has the same vehicle ID. It works for the pilot but not for the passengers.. Like you can see on the pics below..
As you can see it says 'Pilot: Tyler_Acres Says: test' That message is being sent to the passengers too.


But when I'm passenger and try to talk I dont get the message 'Passenger Tyler_Acres Says: test' I only get the normal message(which i shouldnt..)


And here is the code under OnPlayerText.
pawn Код:
new vehicle = GetPlayerVehicleID(playerid);
                if(GetVehicleModel(vehicle) == 519)
                {
                    for( new i = 0; i != MAX_PLAYERS; i++ )
                    {
                        if(GetPlayerVehicleID(i) == vehicle)
                        {
                            if(IsShmlPil[i] == vehicle)
                            {
                                if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 0)
                                {
                                    format(string, sizeof(string), "{157DEC}(IC){FFFFFF} %s Says: %s", sendername, text);
                                    SetPlayerChatBubble(playerid, string, COLOR_WHITE, 8.5, 8000);
                                    ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                                    format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (Local): %s",d1,m1,y1,h1,mi1,s1, sendername, text);
                                    format(string, sizeof(string), "Pilot: %s Says: %s", sendername, text);
                                    SCM(i,  0xD7DFF3AA, string);
                                    ChatLog(string);
                                }
                                else if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 1)
                                {
                                    format(string, sizeof(string), "{157DEC}(IC){FFFFFF} Stranger Says: %s", text);
                                    SetPlayerChatBubble(playerid, string, COLOR_WHITE, 8.5, 8000);
                                    ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                                    format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (Local Masked): %s",d1,m1,y1,h1,mi1,s1, sendername, text);
                                    format(string, sizeof(string), "Pilot: Stranger Says: %s", text);
                                    SCM(i,  0xD7DFF3AA, string);
                                    ChatLog(string);
                                }
                                else if(PlayerInfo[playerid][pAdminDuty] == 1 && PlayerInfo[playerid][pMaskuse] == 0)
                                {
                                    format(string, sizeof(string), "{157DEC}(A){FFFFFF} Admin Says: %s", text);
                                    SetPlayerChatBubble(playerid, string, COLOR_NICERED, 8.5, 8000);
                                    ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                                    format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (Local Admin): %s",d1,m1,y1,h1,mi1,s1, sendername, text);
                                    format(string, sizeof(string), "Pilot: Admin %s Says: %s",sendername, text);
                                    SCM(i,  0xD7DFF3AA, string);
                                    ChatLog(string);
                                }
                            }
                            else if(IsInShml[i] == vehicle)
                            {
                                if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 0)
                                {
                                    format(string, sizeof(string), "Passenger %s Says: %s", sendername, text);
                                    SCM(i,  0xD7DFF3AA, string);
                                    ChatLog(string);
                                }
                                else if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 1)
                                {
                                    format(string, sizeof(string), "Passenger Stranger Says: %s", text);
                                    SCM(i,  0xD7DFF3AA, string);
                                    ChatLog(string);
                                }
                                else if(PlayerInfo[playerid][pAdminDuty] == 1 && PlayerInfo[playerid][pMaskuse] == 0)
                                {
                                    format(string, sizeof(string), "Passenger Admin %s Says: %s",sendername, text);
                                    SCM(i,  0xD7DFF3AA, string);
                                    ChatLog(string);
                                }
                            }
                        }
                    }
EDIT: IsInShml is for passengers and IsShmlPil is for the pilot. Both are set when you enter a vehicle
Reply
#2

By looking at your code, being a passanger on the shamal means you're on foot and not in any vehicle (technically); While you're inside the shamal as a passanger you are in an interior and not in a vehicle, GetPlayerVehicleID and GetVehicleModel will return null values.

What you're doing is checking if the player is in any vehicle

pawn Код:
new vehicle = GetPlayerVehicleID(playerid);
And for passengers that will return null, while it wont for the pilot since he's actually driving the shamal.

I recommend making separated checks for both the pilot and the passanger.
Reply
#3

Could you show me an example?
Reply
#4

pawn Код:
public OnPlayerText(playerid, text[])
{
    new sendername[24];
    GetPlayerName(playerid, sendername 24);

    if(IsShmlPil[playerid] != 0) //or whatever the default is
    {
        for(new i = 0; i < MAX_PLAYERS; i ++)
        {//loop thru all players
            if(!IsPlayerConnected(i))
                continue;

            if(IsInShml[i] != IsShmlPil[playerid])
                continue;
            //exclude those who are disconnected OR not a passanger in the pilot's shamal

            if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 0)
            {
                format(string, sizeof(string), "{157DEC}(IC){FFFFFF} %s Says: %s", sendername, text);
                SetPlayerChatBubble(playerid, string, COLOR_WHITE, 8.5, 8000);
                format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (Local): %s",d1,m1,y1,h1,mi1,s1, sendername, text);
                ChatLog(string);
                format(string, sizeof(string), "Pilot: %s Says: %s", sendername, text);
                SCM(i,  0xD7DFF3AA, string);
            }
            else if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 1)
            {
                format(string, sizeof(string), "{157DEC}(IC){FFFFFF} Stranger Says: %s", text);
                SetPlayerChatBubble(playerid, string, COLOR_WHITE, 8.5, 8000);
                format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (Local Masked): %s",d1,m1,y1,h1,mi1,s1, sendername, text);
                ChatLog(string);
                format(string, sizeof(string), "Pilot: Stranger Says: %s", text);
                SCM(i,  0xD7DFF3AA, string);
            }
            else if(PlayerInfo[playerid][pAdminDuty] == 1 && PlayerInfo[playerid][pMaskuse] == 0)
            {
                format(string, sizeof(string), "{157DEC}(A){FFFFFF} Admin Says: %s", text);
                SetPlayerChatBubble(playerid, string, COLOR_NICERED, 8.5, 8000);
                format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (Local Admin): %s",d1,m1,y1,h1,mi1,s1, sendername, text);
                ChatLog(string);
                format(string, sizeof(string), "Pilot: Admin %s Says: %s",sendername, text);
                SCM(i,  0xD7DFF3AA, string);
            }
        }
    }
    if(IsInShml[playerid] != 0) // or whatever the default is
    {//the following code should run if the player IS in any shamal AS passanger.
        for(new i = 0; i < MAX_PLAYERS; i ++)
        {//loop thru all players
            if(!IsPlayerConnected(i))
                continue;

            if(IsInShml[i] != IsInShml[playerid] && IsShmlPilot[i] != IsInShml[playerid])
                continue;

            //exclude disconnected and/or those who are NOT in the small or IS NOT the shamal pilot.

            if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 0)
            {
                format(string, sizeof(string), "Passenger %s Says: %s", sendername, text);
                SCM(i,  0xD7DFF3AA, string);
                ChatLog(string);
            }
            else if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 1)
            {
                format(string, sizeof(string), "Passenger Stranger Says: %s", text);
                SCM(i,  0xD7DFF3AA, string);
                ChatLog(string);
            }
            else if(PlayerInfo[playerid][pAdminDuty] == 1 && PlayerInfo[playerid][pMaskuse] == 0)
            {
                format(string, sizeof(string), "Passenger Admin %s Says: %s",sendername, text);
                SCM(i,  0xD7DFF3AA, string);
                ChatLog(string);
            }
        }
    }
    return 0;
}

GetVehicleModel/ID would be useless here since those who are passangers (of the shamal) ARE NOT in any vehicle, you have to use your custom defined variables instead. This works like this because the shamal does not allow passangers and while you're inside a shamal interior, you're not in a vehicle id according the game.

If the player is a pilot, then check which players are in the pilot's shamal and send the message as pilot.
If the player is IN a shamal, then check which players are also inside that shamal including the pilot and send the message as passanger.

Also logging would not work properly, I fixed them; you have to change the order of functions.
Reply
#5

Thanks
Reply
#6

Now it dont show for anyone. Not even pilot

EDIT: Nvm.. Just me that wasnt thinking..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)