ON Player Text
#1

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.
Reply
#2

if(strlen(text)<=1) return 0;
Reply
#3

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.
Reply
#4

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

Huh? Post code.
Reply
#6

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

Код:
    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;
}
Reply
#8

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;
Reply
#9

It still bugged.
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)