#1

So I was wondering if someone could explain to me about how to make a ranged chat like /s for shout. I don't want the whole script ready that it's just copy paste. I want someone to explain in details the parts of the script that I can make my own.
Reply
#2

In your command, first get the position of playerid.
pawn Код:
GetPlayerPos(playerid, X, Y, Z)
Then use a loop.
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
In that loop do a check with IsPlayerInRangeOfPoint.
pawn Код:
if(IsPlayerInRangeOfPoint(i, 10.0, X, Y, Z)
If that is true, send the message, if not, return false. Altough I recommend you to use foreach.
Reply
#3

Thanks I'll try it I'll write if I get any problems
Reply
#4

Hey can you post the whole script so that I can study it?
Reply
#5

http://forum.sa-mp.com/index.php?topic=116240.0
I am using that command system and sscanf, which can be found here: https://sampwiki.blast.hk/wiki/Sscanf

pawn Код:
COMMAND:s(playerid, params[])
{
    new
        msg[ 128 ];
    if (sscanf(params, "s", msg)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /s [message]");
    else
    {
        new
            pName[ MAX_PLAYER_NAME ],
            string[ 155 ],
            Float: X,
            Float: Y,
            Float: Z;
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerName(playerid, pName, sizeof( pName ) );
        format(string, sizeof(string), "%s: %s", pName, msg );
        for( new i = 0; i < MAX_PLAYERS; i++ )
        {      
            if(IsPlayerInRangeOfPoint(i, 10.0, X, Y, Z )
            {
                SendClientMessage(i, 0xFFFF00AA, string );
            }
        }
    }
    return 1;
}
Change the 10.0 here: if(IsPlayerInRangeOfPoint(i, 10.0, X, Y, Z ) to whatever you want to be the distance a player can be away from the player who is typing the command.
Reply
#6

ok thanks ill try
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)