SA-MP Forums Archive
IsPlayerInRangeOfPoint ????? - 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: IsPlayerInRangeOfPoint ????? (/showthread.php?tid=318009)



IsPlayerInRangeOfPoint ????? - SumX - 13.02.2012

Hello,i have a segnaling sysmte,when a player is in a car and press Q or E , the script is sending a message that i am going in left or right...but the system is sending messages to all online on the server.I want it to send these messages only to people who are close to me...You understand.Thank you,here is the code:


pawn Code:
public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
    if ( newkeys == KEY_LOOK_RIGHT )
    {
        if ( IsPlayerInAnyVehicle ( playerid ) )
        {
            if (antisigspam[playerid] == 0)
            {
                format ( string, sizeof ( string ), "{E60000}* %s {FFC0CB}is going to the right.", pname( playerid ) );
                SendClientMessageToAll( COLOR_PINK, string );
                format ( string, sizeof ( string ), "*{FFC0CB}>>>>>>>>>>> {E60000}%s{FFC0CB} >>>>>>>>>>>", pname( playerid ) );
                SendClientMessageToAll( COLOR_PINK, string );
                antisigspam[playerid] = 1;
                SetTimerEx("antispamtimer", ANTISIGSPAM_TIME*1000, false, "d", playerid);
             }
             else
             {
                format( string, sizeof ( string ), "Please wait {FFC0CB}%d {E60000}secconds  before you signal again!", ANTISIGSPAM_TIME);
                SendClientMessage( playerid, COLOR_ULTRARED, string );
             }
        }
    }



Re: IsPlayerInRangeOfPoint ????? - niels44 - 13.02.2012

as fist you have senclientmessagetoall... so that means it sends the msg to all players online so change that to sendclientmessage


Re: IsPlayerInRangeOfPoint ????? - SumX - 13.02.2012

Yes,but sendclientmessage is sending a message only to me ,no? when i press Q and E,i want that people who are close to me to see the message


Re: IsPlayerInRangeOfPoint ????? - niels44 - 13.02.2012

yes then you have to define their id but i dont know excactly how... but someone else will know so anyone who knows this post reply here


Re: IsPlayerInRangeOfPoint ????? - SumX - 13.02.2012

Thank you anyway...waiting for replys)


Re: IsPlayerInRangeOfPoint ????? - Twisted_Insane - 13.02.2012

"SendClientMessage" would be enough!

Or you'd define a new id:

pawn Code:
new targetid;
Combinate it then with the message! Or what do you want?


Re: IsPlayerInRangeOfPoint ????? - Konstantinos - 13.02.2012

Use loop
pawn Code:
public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
    if ( newkeys == KEY_LOOK_RIGHT )
    {
        if ( IsPlayerInAnyVehicle ( playerid ) )
        {
            if (antisigspam[playerid] == 0)
            {
                new Float:pX, Float:pY, Float:pZ;
                GetPlayerPos( playerid, pX, pY, pZ );
                for( new i = 0; i < MAX_PLAYERS; i ++ )
                {
                    if( IsPlayerInRangeOfPoint( i, 7.0, pX, pY, pZ ) )
                    {
                        format ( string, sizeof ( string ), "{E60000}* %s {FFC0CB}is going to the right.", pname( playerid ) );
                        SendClientMessageToAll( COLOR_PINK, string );
                        format ( string, sizeof ( string ), "*{FFC0CB}>>>>>>>>>>> {E60000}%s{FFC0CB} >>>>>>>>>>>", pname( playerid ) );
                        SendClientMessage( i, COLOR_PINK, string ); // Sends the message to the players that are in range of 7 from your position!
                    }
                }
                antisigspam[playerid] = 1;
                SetTimerEx("antispamtimer", ANTISIGSPAM_TIME*1000, false, "d", playerid);
             }
             else
             {
                format( string, sizeof ( string ), "Please wait {FFC0CB}%d {E60000}secconds  before you signal again!", ANTISIGSPAM_TIME);
                SendClientMessage( playerid, COLOR_ULTRARED, string );
             }
        }
    }
    // Rest