How to make this go a certain range
#1

How can i make this message

pawn Код:
SendClientMessageToAll(COLOR_YELLOW, "Officer [name will go here eventually], Pull your car over to the side of the road");
Go a certain range, So not everyone can see it, Just within a certain range,

And how would i do it if i said, /megaphone [MESSAGE HERE] so like, /megaphone Pull Over

It would say,

Officer Torran, Pull Over,

Like that? Also within a certain range

Also i dont wanna know how to make it say my name, Just how to make it say whatever i type
Reply
#2

Try to use format and IsPlayerInRangeOfPoint. Good luck.
Reply
#3

Dont think that will work tbh
Reply
#4

Quote:
Originally Posted by JoeDaDude
Dont think that will work tbh
Indeed it will, you just need to know how to use it. Make a loop for all players (except the player who sent a message) and check if they're in range of point of the player who sent the message.
Reply
#5

pawn Код:
dcmd_megaphone(playerid, params[])
{
    new
        string[128],
        message[104];
       
    if(sscanf(params, "s", message))
    {
        SendClientMessage(playerid, COLOR, "Usage: /megaphone [message]");
    }
    else
    {
        format(string, sizeof(string), "Officer [%s]: %s!", GetPlayerName(playerid), message);
        SendClientMessage(playerid, COLOR, string);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            while(GetDistanceBetweenPlayers(playerid, i) < range) // change range for distance
            {
                SendClientMessage(i, COLOR, string);
            }
        }
    }
    return 1;
}
Reply
#6

How to know how far like 1.0 range is, and 2.0, ect
Reply
#7

Quote:
Originally Posted by JoeDaDude
How to know how far like 1.0 range is, and 2.0, ect
Same units when getting player pos, and btw, i changed something in that code.

You can also use IsPlayerInRangeOfPoint and GetPlayerPos.
Reply
#8

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(376) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(376) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(380) : error 017: undefined symbol "GetDistanceBetweenPlayers"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Also id appreciate it if someone could reply here too: http://forum.sa-mp.com/index.php?topic=147542.0
The latest reply, I need help on that also, Shouldnt be too hard to fix
Reply
#9

GetDistanceBetweenPlayers is a custom function, you'll need to search for it on this forum.
Reply
#10

Ok done and thats done,
Now left is 2 more errors

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(376) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(376) : warning 202: number of arguments does not match definition
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)