Quote:
Originally Posted by foxboi
Yeah code you sorta explain how you made that script>?
|
Sure, well I only call the function once, that is when the player chats.
PHP Code:
function onPlayerChats()
{
}
Now, you check what it is the player is saying. You can do this many of ways, I used the normal
PHP Code:
if (player.chat.starts("/box"))
{
}
As you only know what the player is going to start their chat with, you can't add anything else.
You'll then notice I used one line, to make the chat of the NPC change.
PHP Code:
this.chat = min(player.chat.substring(4).trim(), 2);
Well, this.chat works the same as
PHP Code:
message("Hi there");
So don't get lost on that part!
You're probably lost on the part after this though, being this:
PHP Code:
min(player.chat.substring(4).trim(), 2);
Well, I'll explain "min()" first.
PHP Code:
min(number1, number2);
Basically, it'll see which number [being that number1 or number2] is the lowest.
So, since we know that you only wanted to use two boxes, I know that the lowest highest number that you needed would be 2. Anything over that number will set it automatically to 2, do you see this? [If not, I shall explain again!]
You'll then see what I did to the players chat with this command
PHP Code:
player.chat.substring(4).trim()
What I am doing is cutting the first four letters from the players chat. ["/box"] being the four letters being cut each time, leaving only the number left. I added the ".trim()" part, to remove the unnecessary spaces that was left out. [" " <--Being an unnecessary space]
I hope this helped!