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=300055)



onplayertext - bartje01 - 28.11.2011

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



Re: onplayertext - moadi - 28.11.2011

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


Re: onplayertext - AstonDA-G - 28.11.2011

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


Re: onplayertext - NessaHD - 28.11.2011

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

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



Re: onplayertext - bartje01 - 28.11.2011

thanks


Re: onplayertext - bartje01 - 28.11.2011

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



Re: onplayertext - NessaHD - 28.11.2011

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


Respuesta: onplayertext - iKeN - 28.11.2011

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



Re: onplayertext - bartje01 - 28.11.2011

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.


Re: Respuesta: onplayertext - NessaHD - 28.11.2011

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..