SA-MP Forums Archive
OnPlayerText help - 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 help (/showthread.php?tid=239058)



OnPlayerText help - Jason_Blink - 12.03.2011

Hi there! My question is that is there a way of making the script to wait until the player types in a message? As i know the function OnPlayerText handles the messages but i need to wait until the player answers a specific question so i need to wait until OnPlayerText is called by the server to handle his answer.


Re: OnPlayerText help - alpha500delta - 12.03.2011

Do you mean something like this?

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text,"Your text here", true) != -1)
    {
            //Do your stuff here
        return 0;
    }
    return 1;
}



Re: OnPlayerText help - Jason_Blink - 13.03.2011

No. I made a register command which looks like this:

reg(playerid, params[])
{
...
}

It is called from OnPlayerCommandText whenever a player uses /register. But this register commands puts some questions to the player (like gender, age, etc.) and i need to get somehow what the player types inside the "T" chat which will be taken as an answer by this register command. But how do i do that without having to write that part of my script inside the actual OnPlayerText function? I only need to get what he types in. Is there a way of doing that ?


Re: OnPlayerText help - iggy1 - 13.03.2011

Not without using OnPlayerText You would want to do something like this.
pawn Код:
COMMAND:reg(playerid, params[])
{
    SetPVarInt(playerid, "registering", 1);//when player is registered delete this var
    //...
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(GetPVarInt(playerid, "registering") == 1)
    {
        if(text[0] == 'f' && text[1] == '\0')
        {
            // 'f' was entered when player was registering
           
            //do stuff
            return 0;//return 0 so text isn't sent
        }
    }
    return 1;
}



Re: OnPlayerText help - Jason_Blink - 14.03.2011

The problem is that i cant do my stuff under OnPlayerText. My stuff is already done under that register function and its done like this: those questions are written inside a file and are read by that "register" function using a "for" loop. This way i can modify the questions and their number (i can put some more questions later on) without having to modify too much things within the script. My problem is, as i mentioned in my question, that i have to "pause" that "for" loop and make it WAIT until the player types in his answer, after that, the script compares this answer with the correct one and if they match than the loop continues. So i'm asking again: Is there a way to pause the repeating "for" loop and make it wait until the player types in its answer?