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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerText (/showthread.php?tid=193336)



OnPlayerText - knackworst - 25.11.2010

Hi, can someone explain me 'bout OnPlayerText,

what I want is this:

when a player types Justin bieber
there comes, error: this server is not gay!

I don't know how to use this callback... is it the same as OnPlayerCommandText with sctrcmp?


Re: OnPlayerText - Fj0rtizFredde - 25.11.2010

You could check the wiki for more info
But yes you can use strcmp but then it will only check if the player types "Justin Beiber". If you use strfind it would check if the text has any "Justin Bieber" in it.
Example with strcmp:
pawn Код:
if(strcmp(text, "Justin Biber", true) == 0)
{
    //Do stuff here!
    return 0;
}

//With strfind:
if (strfind(text, "Justin Bieber") != -1)
{
    //Do stuff here!
    return 0;
}



Re: OnPlayerText - The_Moddler - 25.11.2010

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text, "Justin bieber", true) != -1)
    {
        return SendClientMessage(playerid, 0xFF0000FF, "This server is not gay!");
    }
}



Re: OnPlayerText - RyDeR` - 25.11.2010

Here you go:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text, "Justin Bieber", true) != -1)
    {
        return SendClientMessage(playerid, 0xFF0000FF, "ERROR: This server is not gay!"), 0;
    }
    return 1;
}
EDIT: Too late


Re: OnPlayerText - knackworst - 25.11.2010

:O thanks buddies!
never got helped so far xD


PS: To mister winnie the Poo, what's diffrence between both of your examples? does it have a diffrend effect? the sctrcmp and strfind?


Re: OnPlayerText - Fj0rtizFredde - 25.11.2010

Quote:
Originally Posted by knackworst
Посмотреть сообщение
:O thanks buddies!
never got helped so far xD


PS: To mister winnie the Poo, what's diffrence between both of your examples? does it have a diffrend effect? the sctrcmp and strfind?
If you use strcmp it will only work if the player types "Justin Bieber" and nothing more. If you use strfind it will work when the text has Justin Bieber in it, like: "Hello. Im Justin Bieber lover<3" hope you understand what I mean


Re: OnPlayerText - Larsey123IsMe - 25.11.2010

It is also possible to set the player health to 1 when he say Justin Bieber?


Re: OnPlayerText - The_Moddler - 25.11.2010

You can, just add SetPlayerHealth and add a return 0.


Re: OnPlayerText - XoSarahMoX - 25.11.2010

Yeah I think this would work but not sure :P

Код:
public OnPlayerText(playerid, text[])
{
if(strfind(text, "Justin bieber", true) != -1)
{
SetPlayerHealth(playerid, 1);
return SendClientMessage(playerid, 0xFF0000FF, "This server is not gay!");
}
return 1;
}



Re: OnPlayerText - The_Moddler - 25.11.2010

Yep, it would work like that too.


Re: OnPlayerText - Larsey123IsMe - 25.11.2010

First i want to say Thanks, then

If you change
pawn Код:
return SendClientMessage(playerid, 0xFF0000FF, "This server is not gay!");
to
pawn Код:
return SendClientMessage(playerid, 0xFF0000FF, "This server is not gay!"), 0;
Then it works better :P


Re: OnPlayerText - WillyP - 25.11.2010

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text, "Justin Bieber", true) != -1)
    {
        return SendClientMessage(playerid, 0xFF0000FF, "You suck dick"), 0;
    }
    return 1;
}