onplayertext
#1

Hey all. How to make it work that if you type the nummer 1 in the chat you will get a message with "works"?
I have this. I just tried but it didn't work as expected.
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text == "1") return SendClientMessage(playerid,-1,"Works");
    return 1;
}
Reply
#2

pawn Код:
if(!strcmp(text,"1"))
{
SendClientMessage(playerid,-1,"Works");
}
EDIT: was missing a bracket, my bad fixed the code above.
Reply
#3

try if(text[0] == "1") return SendClientMessage(playerid,-1,"Works");
Reply
#4

pawn Код:
if (!strcmp(text, "fuck", true)) {

        SendClientMessage(playerid, -1, "Do not swear! Come again when you've learned that!");
        return 0;
    }
Reply
#5

thanks
Reply
#6

New problem.
Now I want to do the same thing with 4 numbers.
It doesn't work.
pawn Код:
public OnPlayerText(playerid, text[])
{

    if(Bit16_Get(g_ClassChoose, playerid) == 1)
    {
        if(!strcmp(text,"1||2||3||4"))
            {
            TextDrawHideForPlayer(playerid,Textdraw0);
            TextDrawHideForPlayer(playerid,Textdraw1);
            TextDrawHideForPlayer(playerid,Textdraw2);
            TextDrawHideForPlayer(playerid,Textdraw3);
            TextDrawHideForPlayer(playerid,Textdraw4);
            TextDrawHideForPlayer(playerid,Textdraw5);
            TextDrawHideForPlayer(playerid,Textdraw6);
        }
    }
    return 1;
}
Reply
#7

You have to do it with 1 number, then with another, then the third and so on. That's the easiest way i think :P
Reply
#8

pawn Код:
if(!strcmp(text,"1") || !strcmp(text,"2")  || !strcmp(text,"3") || !strcmp(text,"4") )
Reply
#9

Quote:
Originally Posted by cruteX_modshop
Посмотреть сообщение
You have to do it with 1 number, then with another, then the third and so on. That's the easiest way i think :P
No, there must be another way since this will make your script messed up.
Quote:
Originally Posted by iKeN
Посмотреть сообщение
pawn Код:
if(!strcmp(text,"1") || !strcmp(text,"2")  || !strcmp(text,"3") || !strcmp(text,"4") )
Already tried and it didn't work.
Reply
#10

Quote:
Originally Posted by iKeN
Посмотреть сообщение
pawn Код:
if(!strcmp(text,"1") || !strcmp(text,"2")  || !strcmp(text,"3") || !strcmp(text,"4") )
Wait, why are you closing it the first time? Don't think this will work..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)