How to make message to all *public chat*
#1

Hi,

I'm fairly new to this, I'm using a Runix's CnR, I wasn't wasn't working way I wanted, so i played alittle with it, got a abit of understanding, but I want to know how do i make it so If someone types "Hello" or anything for that matter, to goes so everyone sees it, like a public chat...

Heres the code being used, if its wrong, please don't flame, I wouldn't have been able to tell anyway :P

{
if(text[0] == '@' && AccountInfo[playerid][aLevel] > 0)
{
new string[256], name[60], message[350];
GetPlayerName(playerid, name, 60);
strmid(string, text, 1, strlen(text), 256);
format(message, 350, "%s: %s", name, string);
for(new i;i<MAX_PLAYERS;i++)
{
if(AccountInfo[i][aLevel] > 0)
{
SendPlayerMessageToAll(playerid, message);
}
}
return 0;
}

I tried adding the "SendPlayerMessageToAll", hoping it would fix it lol, i was wrong the server was designed so messages would only appear to people near by, but I much prefer the public chat
Reply
#2

pawn Код:
if(text[0] == '@' && AccountInfo[playerid][aLevel] > 0)
{
    new string[256], name[60], message[350];
    GetPlayerName(playerid, name, 60);
    strmid(string, text, 1, strlen(text), 256);
    format(message, 350, "%s: %s", name, string);
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(AccountInfo[i][aLevel] > 0)
        {
            SendClientMessage(i,0xFF0000FF, message);
        }
    }
    return 0;
}
Reply
#3

That is what It was originally, which doesn't work

when I say something, it goes >> message

but doesnt say name and only i can see it..
Reply
#4

Show us your OnPlayerText (If I understand you, you're talking about chat)
Reply
#5

public OnPlayerText(playerid, text[])
{
if(text[0] == '@' && AccountInfo[playerid][aLevel] > 0)
{
new string[256], name[60], message[350];
GetPlayerName(playerid, name, 60);
strmid(string, text, 1, strlen(text), 256);
format(message, 350, "%s: %s", name, string);
for(new i;i<MAX_PLAYERS;i++)
{
if(AccountInfo[i][aLevel] > 0)
{
SendClientMessage(i,0xFF0000FF, message);
}
}
return 0;
}
Reply
#6

pawn Код:
SendClientMessage(i,0xFF0000FF, message); // This is sent just to the person typing.
to
pawn Код:
SendClientMessageToAll(0xFF0000FF, message); // This is sent to everyone.
Reply
#7

Still isn't working.. messages still show up like >> [message] and no name attached and I loaded SAMP on anotther comp but still can't see text others say...
Reply
#8

Alright, change this line:
pawn Код:
format(message, 350, "%s: %s", name, string);
to

pawn Код:
format(message, 350, "%s: %s", name, text);
edit:

pawn Код:
name[50]; > name[MAX_PLAYER_NAME];
pawn Код:
GetPlayerName(playerid, name, 60); > GetPlayerName(playerid, name, sizeof(name));
Reply
#9

pawn Код:
name[50]; > name[MAX_PLAYER_NAME];
- where is this code located, i don't see it
Reply
#10

Actually you can just leave the callback empty with returning 1.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)