SA-MP Forums Archive
How to mak vehicle only chat? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to mak vehicle only chat? (/showthread.php?tid=426512)



How to mak vehicle only chat? - ZackBoolaro - 29.03.2013

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.


Re: How to mak vehicle only chat? - Patrick - 29.03.2013

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


Re: How to mak vehicle only chat? - ZackBoolaro - 29.03.2013

Okay sure, thanks.


Re: How to mak vehicle only chat? - Patrick - 29.03.2013

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;
}