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



OnPlayerText - Socan - 14.11.2012

So this is my code for OnPlayerText and whenever I do a text in game it works but it also sends the defualt code undernearth, script;

Код:
public OnPlayerText(playerid, text[])
{
		new textv2[128], name[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, name, sizeof (name));
        if(PlayerMuted[playerid] == 1) {
                GameTextForPlayer(playerid,"~n~~r~ERROR:~n~~y~You are muted!", 1000, 1);
                return 0;
        }
        else
        {
			format(textv2, sizeof (textv2), "%s[%d]: %s", name, playerid, text);
			SendPlayerMessageToAll(playerid, textv2);
			return 1;
		}
  		return 1;
}



Re: OnPlayerText - [HK]Ryder[AN] - 14.11.2012

Just do this
pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    if(PlayerMuted[playerid] == 1) {
    GameTextForPlayer(playerid,"~n~~r~ERROR:~n~~y~You are muted!", 1000, 1);
    return 0;
}
return 1;
}



Re: OnPlayerText - Socan - 14.11.2012

What about this? I still get the same sort of problem, the words just come AFTER your name not UNDER, like this;

Код:
 
Now - Socan: Socan[0]:Test

Before -Socan:Socan[0]:Test
          Socan:Test
Heres the code so far;
Код:
public OnPlayerText(playerid, text[])
{
		new textv2[128], name[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, name, sizeof (name));
        if(PlayerMuted[playerid] == 1) {
                GameTextForPlayer(playerid,"~n~~r~ERROR:~n~~y~You are muted!", 1000, 1);
                return 0;
        }
       
      	format(textv2, sizeof (textv2), "%s[%d]: %s", name, playerid, text);
		SendPlayerMessageToAll(playerid, textv2);

		return 0;

  		
}



Re: OnPlayerText - [HK]Ryder[AN] - 14.11.2012

use my code
pawn Код:
public OnPlayerText(playerid, text[])
{
        new textv2[128], name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof (name));
                if(PlayerMuted[playerid] == 1)
                 {
                           GameTextForPlayer(playerid,"~n~~r~ERROR:~n~~y~You are muted!", 1000, 1);
                            return 0;
                 }
       
                format(textv2, sizeof (textv2), "[%d]: %s", name, playerid, text);
        SendPlayerMessageToAll(playerid, textv2);

        return 0;

       
}
return 1;
}



Re: OnPlayerText - Socan - 14.11.2012

This?

Код:
public OnPlayerText(playerid, text[])
{
	new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    if(PlayerMuted[playerid] == 1)
    {
  		GameTextForPlayer(playerid,"~n~~r~ERROR:~n~~y~You are muted!", 1000, 1);
  		return 0;
    }
	else
	{
 		format(textv2, sizeof (textv2), "[%d]: %s", name, playerid, text);
 		SendPlayerMessageToAll(playerid, textv2);
		return 0;
	}
	return 1;
}
Im getting this errors;
Код:
C:\Users\School\Desktop\Team DeathMatch\gamemodes\afp.pwn(242) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.



Re: OnPlayerText - Emmet_ - 14.11.2012

pawn Код:
public OnPlayerText(playerid, text[])
{
    new textv2[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    if(PlayerMuted[playerid] == 1)
    {
        GameTextForPlayer(playerid,"~n~~r~ERROR:~n~~y~You are muted!", 1000, 1);
        return 0;
    }
    format(textv2, sizeof (textv2), "[%d]: %s", name, playerid, text);
    SendPlayerMessageToAll(playerid, textv2);
    return 0;
}



Re: OnPlayerText - Plovix - 14.11.2012

Try this:

PHP код:
public OnPlayerText(playeridtext[])
{
        new 
textv2[128], name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof (name));
        if(
PlayerMuted[playerid] == 1) {
                
GameTextForPlayer(playerid,"~n~~r~ERROR:~n~~y~You are muted!"10001);
                return 
0;
        }else{
            
format(textv2sizeof (textv2), "%s[%d]: %s"nameplayeridtext);
            
SendPlayerMessageToAll(playeridtextv2);
            return 
0;
       }
          return 
0;