How to send a global message?
#1

I got a command, I use /l Sup dudes - if I am alone in the range of 10 metres I get message, but if others are there I don't get the message, what is the problem? Command:

pawn Код:
if(strcmp(cmd, "/l", true) == 0 || strcmp(cmd, "/local", true) == 0)
    {
        new message[256], Float:x, Float:y, Float:z;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        message = strrest(cmdtext, idx);
        if(!strlen(message))
        {
            SendClientMessage(playerid, COLOR_PINK,"USAGE: /l(ocal) [message]");
            return 1;
        }
        for(new i=0; i <= GetMaxPlayers(); i++)
        {
            GetPlayerPos(playerid, x, y, z);
            if(PlayerToPoint(10.0, playerid, x, y, z))
            {
                format(string, sizeof(string),"%s(%d) says: %s", sendername, playerid, message);
                SendClientMessage(i, COLOR_PURPLE, string);
                return 1;
            }
        }
        }
        return 1;
    }
Reply
#2

pawn Код:
if(strcmp(cmd, "/l", true) == 0 || strcmp(cmd, "/local", true) == 0)
    {
        new message[256], Float:x, Float:y, Float:z;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        message = strrest(cmdtext, idx);
        if(!strlen(message))
        {
            SendClientMessage(playerid, COLOR_PINK,"USAGE: /l(ocal) [message]");
            return 1;
        }
        for(new i=0; i <= GetMaxPlayers(); i++)
        {
            GetPlayerPos(playerid, x, y, z);
            if(PlayerToPoint(10.0, playerid, x, y, z))
            {
                format(string, sizeof(string),"%s(%d) says: %s", sendername, playerid, message);
                SendClientMessageToAll(COLOR_PURPLE, string);
                return 1;
            }
        }
        }
        return 1;
    }
Reply
#3

pawn Код:
GetPlayerPos(playerid, x, y, z);
        for(new i=0; i <= GetMaxPlayers(); i++)
        {
            if(PlayerToPoint(10.0, i, x, y, z))
            {
                format(string, sizeof(string),"%s(%d) says: %s", sendername, playerid, message);
                SendClientMessage(i, COLOR_PURPLE, string);
                return 1;
            }
        }
Reply
#4

Quote:
Originally Posted by cofy1
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/l", true) == 0 || strcmp(cmd, "/local", true) == 0)
    {
        new message[256], Float:x, Float:y, Float:z;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        message = strrest(cmdtext, idx);
        if(!strlen(message))
        {
            SendClientMessage(playerid, COLOR_PINK,"USAGE: /l(ocal) [message]");
            return 1;
        }
        for(new i=0; i <= GetMaxPlayers(); i++)
        {
            GetPlayerPos(playerid, x, y, z);
            if(PlayerToPoint(10.0, playerid, x, y, z))
            {
                format(string, sizeof(string),"%s(%d) says: %s", sendername, playerid, message);
                SendClientMessageToAll(COLOR_PURPLE, string);
                return 1;
            }
        }
        }
        return 1;
    }
I want it global, not for the whole server :P
Reply
#5

Also the one from Hidduh doesn't work, they don't get message neither do I
Reply
#6

Global means everyone. Anyway, here:

pawn Код:
if(!strcmp("/l", cmd))
{
    new inputmessage[128], message[128], name[MAX_PLAYER_NAME], Float:X, Float:Y, Float:Z;
    inputmessage = strrest(cmdtext, idx);
    if(!strlen(inputmessage)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /l [message]");
    if(strlen(inputmessage) > 128) return SendClientMessage(playerid, COLOR_RED, "ERROR: Message too long, try again.");
    GetPlayerName(playerid, name, sizeof(name));
    format(message, sizeof(message), "%s(%d) says: %s", name, playerid, inputmessage);
    GetPlayerPos(playerid, X, Y, Z);
    for(new i; i <= MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) {
            SendClientMessage(i, COLOR_PURPLE, message);
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by Conroy
Посмотреть сообщение
Global means everyone. Anyway, here:

pawn Код:
if(!strcmp("/l", cmd))
{
    new inputmessage[128], message[128], name[MAX_PLAYER_NAME], Float:X, Float:Y, Float:Z;
    inputmessage = strrest(cmdtext, idx);
    if(!strlen(inputmessage)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /l [message]");
    if(strlen(inputmessage) > 128) return SendClientMessage(playerid, COLOR_RED, "ERROR: Message too long, try again.");
    GetPlayerName(playerid, name, sizeof(name));
    format(message, sizeof(message), "%s(%d) says: %s", name, playerid, inputmessage);
    GetPlayerPos(playerid, X, Y, Z);
    for(new i; i <= MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 20, X, Y, Z)) {
            SendClientMessage(i, COLOR_PURPLE, message);
        }
    }
    return 1;
}
Oh lol, anyway I ment at a certain location
Reply
#8

pawn Код:
if(!strcmp("/l", cmd))
{
    new inputmessage[128], message[128], name[MAX_PLAYER_NAME];
    inputmessage = strrest(cmdtext, idx);
    if(!strlen(inputmessage)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /l [message]");
    if(strlen(inputmessage) > 128) return SendClientMessage(playerid, COLOR_RED, "ERROR: Message too long, try again.");
    GetPlayerName(playerid, name, sizeof(name));
    format(message, sizeof(message), "%s(%d) says: %s", name, playerid, inputmessage);
    for(new i; i <= MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i, 20, /*X coord, Y coord, Z coord*/)) {
            SendClientMessage(i, COLOR_PURPLE, message);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)