SA-MP Forums Archive
Double 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: Double chat (/showthread.php?tid=324212)



Double chat - falor - 08.03.2012

Hey guys,
I use Shrewd chat system but when i talk, my text appears in double !

How to fix it?

Код:
public OnPlayerText(playerid, text[])
{
    switch(ChatState{playerid})
	{
		case 0:
		{
			CostumFormat(SCSString,"%s: %s",GetPlayerNameEx(playerid),text);
			SCGeneral(playerid,SCSString,5,7,10,13,15,SWhite,SChat1,SChat2,SChat3,SChat4);
		}
		case 1:
		{
			CostumFormat(SCSString,"[Chuchotement]%s: %s",GetPlayerNameEx(playerid),text);
			SCGeneral(playerid,text,2,4,6,8,10,COLOR_GREY,SChat1,SChat2,SChat3,SChat4);
		}
		case 2:
		{
			CostumFormat(SCSString,"[Crie]%s: %s",GetPlayerNameEx(playerid),text);
			SCGeneral(playerid,text,15,20,25,30,35,SWhite,SChat1,SChat2,SChat3,SChat4);
		}
	}
	SCAnim(playerid,text,at);
	return 1;
}
Thanks


Re: Double chat - [XST]O_x - 08.03.2012

Add return 0; at the end of each 'case x:'.


Re : Double chat - falor - 08.03.2012

Thanks!


Re : Double chat - falor - 08.03.2012

Doesn't work!

"[Chuchotement]%s: %s" deasapears

If i type : "test"

I have "test"

Instead of " [Chuchotement] name : test"


Re: Double chat - MP2 - 08.03.2012

Change return 1 to return 0 at the bottom, don't put it in each case.


Re : Double chat - falor - 08.03.2012

It does the same thing, i posted because this didn't worked


Re: Double chat - ReneG - 08.03.2012

What MP2 said is entirely correct. Returning 1 sends the traditional samp chat. Wait, why would you make your own format function? You are not defining the string. This is how my OnPlayerText code looks. Try to change your stragedy in light of seeing mine.

pawn Код:
public OnPlayerText(playerid, text[])
{
    new pname[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    strreplace(pname,'_',' ');
    switch(pInfo[playerid][pAccent])
    {
        case 0:format(str, sizeof(str), "%s says: %s", pname, text);
        case 1:format(str, sizeof(str), "[American Accent] %s says: %s", pname, text);
        case 2:format(str, sizeof(str), "[Mexican Accent] %s says: %s", pname, text);
        case 3:format(str, sizeof(str), "[Russian Accent] %s says: %s", pname, text);
    }
    ProxDetector(30.0, playerid, str, COLOR_WHITE);
    new lstring[254];
    new File:chatlog=fopen(LOG,io_append);
    format(lstring,254,"[chat][local][%s]: %s\r\n",pname,text);
    fwrite(chatlog,lstring);
    fclose(chatlog);
    return 0;
}



Re : Double chat - falor - 09.03.2012

"strreplace(pname,'_',' ');"

Where does it comes from?

Because i got "error 017: undefined symbol "strreplace""

Thanks


Re: Re : Double chat - [XST]O_x - 10.03.2012

Quote:
Originally Posted by falor
Посмотреть сообщение
"strreplace(pname,'_',' ');"

Where does it comes from?

Because i got "error 017: undefined symbol "strreplace""

Thanks
Not so sure but try adding this:

pawn Код:
stock strreplace(src[], chartoreplace[], with[])
{
    for(new i = 0; i < strlen(src); i++)
    {
        if(!strcmp(src[i], chartoreplace))
        {
            format(src[i], 1, "%s", with);
        }
    }
    return src;
}
Usage will be:
pawn Код:
strreplace(string, "a", "b");
Will replace each 'a' with a 'b'.