SA-MP Forums Archive
how to make main chat local chat? - 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: how to make main chat local chat? (/showthread.php?tid=338383)



how to make main chat local chat? - TheDiscussionCafe - 29.04.2012

how can i make so when people type in someone in regular chat, it say like this:

Example:

John_Jim: test message

I want to say like this:

John_Jim Says: test message

i want the world "Says"


Re: how to make main chat local chat? - iRemix - 29.04.2012

pawn Код:
public OnPlayerText(playerid, text[])
{
    new gName[24], gMessage[250];
    GetPlayerName(playerid, gName, sizeof(gName));
    format(gMessage, sizeof(gMessage), "%s says: %s", gName, text);
    SendClientMessageToAll(0xFFFFFFFF, gMessage);
        return 0;
}
I guess you could try that, don't know if it will work or not.


Re: how to make main chat local chat? - Jonny5 - 29.04.2012

pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(textv2, sizeof (textv2), "%s Says: %s", name, text);
    SendClientMessageToAll(-1, textv2);
    return 0; // ignore the default text and send the custom one
}

edit:

ops too slow LOL

@ the post above

you got to return 0; to prevent it from sending the normal way but yes will work.


Re: how to make main chat local chat? - [KHK]Khalid - 29.04.2012

You may check this thread out. It's very useful in your case.


Re: how to make main chat local chat? - ReneG - 29.04.2012

This tutorial shows you how to do everything associated with roleplay chats.
https://sampforum.blast.hk/showthread.php?tid=336052


Re: how to make main chat local chat? - TheDiscussionCafe - 29.04.2012

hmm why i get both? when i say "hi" it say two times when i only type once. like this:

John_Jim Says: hi
John_Jim: hi



Re: how to make main chat local chat? - Littlehelper - 29.04.2012

Because you may not have "Return 0;" at the end of callback "OnPlayerText".
As stated above.
pawn Код:
return 0; // ignore the default text and send the custom one



Re: how to make main chat local chat? - TheDiscussionCafe - 29.04.2012

ok i am edit another script. i have this:

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text, "rcon", true) != -1)
    {
        return 0;
    }
    if(strfind(text, "login",true) != -1)
    {
        return 0;
    }
    new string[200]; new pname[24]; GetPlayerName(playerid, pname, 24);
    new pcol = GetPlayerColor(playerid);
    if(GetPVarInt(playerid, "Muted") == 1)
    {
        SendClientMessage(playerid, COLOR_ERROR, "You are muted. You cannot talk.");
        return 0;
    }
    if(GetPVarInt(playerid, "Spawned") == 1)
    {
        if(gTeam[playerid] == Team_Cop || gTeam[playerid] == Team_FBI)
        {
            format(string, 200, "12[CHAT] %s (%d) says: %s", pname, playerid, text);
        }
        if(gTeam[playerid] == Team_Army)
        {
            format(string, 200, "6[CHAT] %s (%d) says: %s", pname, playerid, text);
        }
        if(gTeam[playerid] == Team_Civi)
        {
            if(pcol == COLOR_RED)
            {
                format(string, 200, "4[CHAT] %s (%d) says: %s", pname, playerid, text);
            }
            if(pcol == COLOR_YELLOW)
            {
                format(string, 200, "8[CHAT] %s (%d) says: %s", pname, playerid, text);
            }
            if(pcol == COLOR_ORANGE)
            {
                format(string, 200, "7[CHAT] %s (%d) says: %s", pname, playerid, text);
            }
            if(pcol == COLOR_WHITE)
            {
                format(string, 200, "0[CHAT] %s (%d) says: %s", pname, playerid, text);
            }
        }
    }
    if(GetPVarInt(playerid, "Spawned") == 0)
    {
        format(string, sizeof(string), "[CHAT] %s (%d) says: %s", pname, playerid, text);
    }
    return 1;
}
i added the word "says" myself. how i not see that in game when i type? i dont work?


Re: how to make main chat local chat? - Jonny5 - 29.04.2012

change the bottom of your function to this
pawn Код:
SendClientMessageToAll(-1, string);
    return 0; // ignore the default text and send the custom one
}



Re: how to make main chat local chat? - ReneG - 29.04.2012

Why SendClientMessageToAll when he wants local chat.

To the OP, read the tutorial in my signature.