How to mak vehicle only chat?
#1

The title says it all, i've got an idea for my roleplay server but I can't really think of a way to do it. Like i want whenever I chat with someone in my vehicle if my windows are closed no one will be able to see the chat even if he is infront of my vehicle. But if I do /car windows or /veh windows it would say that i'm rolling my windows down and people would be able to see the chat if they are near my vehicle. I know that parts of this should be on "OnPlayerText" with ProxDetector, but I can't really think of how should I do it. That's why i'm posting a scripting help thread.
Reply
#2

you could use a variable and created function for that. ill be writing an example just give me 3-4 minutes and
Reply
#3

Okay sure, thanks.
Reply
#4

here you go

pawn Код:
new bool:Window[MAX_PLAYERS];
public OnPlayerText(playerid, text[])
{
    if(Window[playerid])//means open
    {
        new string[128];
        new pName[24];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(string,sizeof(string),"%s says: %s",);
        CloseMessage(playerid, -1, string);
    }
    else if(!Window[playerid])
    {
        //do nothing
        printf("%s Window's is closed no one can hear him!",pName);
    }
    return 0;
}

//Set this to your car window command
//if open Window[playerid] =true;
//if close Window[playerid] =false;

stock CloseMessage(playerid, colour, string[])//thanks iGetty for this function
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GetPlayerPos(playerid, PlayerX, PlayerY, PlayerZ);
            if(IsPlayerInRangeOfPoint(i, 10, PlayerX, PlayerY, PlayerZ))
            {
                SendClientMessage(i, colour, string);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)