how to send a message to players near?
#1

How can I make this command

Код:
if(strcmp(cmd, "/duty", true) == 0)
        {
	if(IsPlayerConnected(playerid))
 	{
		if(IsPlayerInRangeOfPoint(playerid,3,246.783996,63.900199,1003.640625))
		{
			
                        SetPlayerColor(playerid,0x0259EAAA);
			SetPlayerSkin(playerid,280);
			GivePlayerWeapon(playerid,22,300);
			GivePlayerWeapon(playerid,3,1);
			
			return 1;
		}
		else return SendClientMessage(playerid, 0x0259EAAA, "You Are Not In LSPD Entrance.");
  	}
    else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Online");
}
to send a message to players NEAR the person who typed /duty + they have to be TEAM_COP.... How?? please help
Reply
#2

pawn Код:
if(strcmp(cmd, "/duty", true) == 0)
        {
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid,3,246.783996,63.900199,1003.640625))
        {

            SetPlayerColor(playerid,0x0259EAAA);
            SetPlayerSkin(playerid,280);
            GivePlayerWeapon(playerid,22,300);
            GivePlayerWeapon(playerid,3,1);
            new Float:x, Float:y, Float:z, name[MAX_PLAYER_NAME], string[100];
            GetPlayerName(playerid, name, sizeof(name));
            GetPlayerPos(playerid, x, y, z);
            for(new i=0; i<GetMaxPlayers(); i++)
            {
                if(IsPlayerConnected(i) && GetPlayerTeam(i) == TEAM_POLICE)
                {
                    if(IsPlayerInRangeOfPoint(i, 20.00, x, y, z)) //change the 20.00 to the range you would like
                    {
                        format(string, sizeof(string), "*%s is now on duty.", name);
                        SendClientMessage(i, COLOR, string);
                    }
                }
            }
            return 1;
        }
        else return SendClientMessage(playerid, 0x0259EAAA, "You Are Not In LSPD Entrance.");
    }
    else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Online");
}
Reply
#3

Thanks
Reply
#4

I would just use "ProxDetector"
Incase you want to use it, here it is (Taken from my Mystic-RP):
pawn Код:
forward ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5);//Radi = Radius
public ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        //radi = 2.0; //Trigger Radius
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {

                GetPlayerPos(i, posx, posy, posz);
                tempposx = (oldposx -posx);
                tempposy = (oldposy -posy);
                tempposz = (oldposz -posz);
                //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
                if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                {
                    SendClientMessage(i, col1, str);
                }
                else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                {
                    SendClientMessage(i, col2, str);
                }
                else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                {
                    SendClientMessage(i, col3, str);
                }
                else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                {
                    SendClientMessage(i, col4, str);
                }
                else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                {
                    SendClientMessage(i, col5, str);
                }
            }
        }
    }//not connected
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)