SA-MP Forums Archive
ON Player Text - 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: ON Player Text (/showthread.php?tid=604111)



ON Player Text - Harty - 31.03.2016

How can i block the message ( return 0; ) onplayertext, if the player doesn't write any letter or number or symbols, but write only 'space or spaces'?

Example:

Kalcor (6):
( Text missing so return 0; )

Thanks.


Re: ON Player Text - czerwony03 - 31.03.2016

if(strlen(text)<=1) return 0;


Re: ON Player Text - SickAttack - 31.03.2016

One way is with sscanf.

pawn Код:
new message[128];
if(sscanf(text, "s[128]", message)) return 0;
It also removes initial spaces when the text is sent.

Edit: czerwony03's code won't work for this case.


Re: ON Player Text - Harty - 31.03.2016

It doesn't work, when i send a message it doesn't send.


Re: ON Player Text - SickAttack - 31.03.2016

Huh? Post code.


Re: ON Player Text - iKevin - 31.03.2016

I didn't understand what you want done. Can you explain it?


Re: ON Player Text - Harty - 31.03.2016

Код:
    new sTexts[128];
    if(sscanf(text, "s[128]", sTexts)) return 0;

if(IsPlayerConnected(playerid)){
     new sText[300];
     format(sText, sizeof(sText), "%s (%d): {FFFFFF}%s", GetName(playerid), playerid, ColouredText(text[0]));
	 SendClientMessageToAll(GetPlayerColor(playerid), sText);
     return 0;
}



Re: ON Player Text - introzen - 31.03.2016

Quote:
Originally Posted by Harty
Посмотреть сообщение
Код:
    new sTexts[128];
    if(sscanf(text, "s[128]", sTexts)) return 0;

if(IsPlayerConnected(playerid)){
     new sText[300];
     format(sText, sizeof(sText), "%s (%d): {FFFFFF}%s", GetName(playerid), playerid, ColouredText(text[0]));
	 SendClientMessageToAll(GetPlayerColor(playerid), sText);
     return 0;
}
Код:
    new sTexts[128];
    if(sscanf(text, "s[128]", sTexts)) return 0;

if(IsPlayerConnected(playerid)){
     new sText[128];
     format(sText, sizeof(sText), "%s (%d): {FFFFFF}%s", GetName(playerid), playerid, sTexts);
	 SendClientMessageToAll(GetPlayerColor(playerid), sText);
     
}
return 0;



Re: ON Player Text - Harty - 31.03.2016

It still bugged.


Re: ON Player Text - SickAttack - 31.03.2016

pawn Код:
#include <sscanf2>

public OnPlayerConnect(playerid)
{
    SetPlayerColor(playerid, 0xE88511FF);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    new message[128];
    if(!sscanf(text, "s[128]", message))
    {
        new string[144], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);

        format(string, sizeof(string), "%s (%d): {FFFFFF}%s", name, playerid, message);
        SendClientMessageToAll(GetPlayerColor(playerid), string);
    }
    return 0;
}