SA-MP Forums Archive
Need some help - 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: Need some help (/showthread.php?tid=649627)



Need some help - xLucy - 12.02.2018

I need this stock to send a nearby message to anyone APART from the player actually executing the command.

Код:
stock SendNearbyMessage(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	new Float:ix, Float:iy, Float:iz;
	new Float:cx, Float:cy, Float:cz;
	foreach(Player, i)
	{
 		if(gPlayerLoggin{i})
	    {
	        if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
	        {
				GetPlayerPos(i, ix, iy, iz);
				cx = (x - ix);
				cy = (y - iy);
				cz = (z - iz);
				if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
				{
				    SCM(i, col1, string);
				}
				else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
				{
				    SCM(i, col2, string);
				}
				else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
				{
				    SCM(i, col3, string);
				}
				else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
				{
				    SCM(i, col4, string);
				}
				else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
				{
				    SCM(i, col5, string);
				}
			}
	    }
	}
	return 1;
}



Re: Need some help - jasperschellekens - 12.02.2018

I have a radio system which uses something similar to what you want.
The person who executes the code will see a blue radio message, and the persons next to him will see it in a orange rp message.
I hope this helped you:

PHP код:
            for(new a=0;a<MAX_PLAYERS;a++)
            if(
PlayerInfo[a][LawDuty]>=1// This means if players are on law enforcement duty. you got to change this.
            
{
                
SendClientMessage(a,BLUE,str); // send message to the player who executes the script.
            
}
            new 
Float:xFloat:yFloat:zstring[100]; // self explenary
            
GetPlayerPos(playeridxyz); // same as above
            
for(new i=0i<GetMaxPlayers(); i++) // loop trough players
            
{
                if(
IsPlayerInRangeOfPoint(i20.00xyz)) // ifplayer is in range of the person who executed the script.
                
{
                    
format(string,sizeof(string),"%s(%i) (radio): %s",PlayerName(playerid),playerid,text);
                      if(
PlayerInfo[i][LawDuty]==0// when the person is not on Law Enforcement duty, he will get a orange rp message
                    
{
                        
SendClientMessage(iORANGEstring);
                    }
                }
            } 
Note: This will not completely work for you. edit it.


Re: Need some help - RogueDrifter - 12.02.2018

lol simply add
PHP код:
if( != playerid
on top after the loop and done!
I don't recommend this tho it's nice to see your message was sent/not sent to know if you're desynced or not and to avoid someone spamming the same message or asking ''DID YOU GET MY MESSAGE?" then that process repeating itself. Just leave it the way it is.