![]() |
A little script help...
So I've been trying to make a parrot script where the image of this parrot repeats whatever you say, which is easy (this.chat=player.chat) however, I need to be able to disable this script by the command of a player, this is what I came up with so far:
function onPlayerChats() { if (player.chat == "stop") { this.chat = "*Squawk*Bye!*Squawk*"; sleep(1); hide; } else if (player.chat == "talk") { this.chat = "*Squawk*Hello!*Squawk*"; show; sleep(1); this.chat = ""; } } Rep for anyone who helps me the most :) |
use a this. var as a boolean to toggle it on and off.
function onCreated() { this.enabled = true; } function onPlayerChats() { if (player.chat == "your toggle command") { // enable or disable here this.enabled = !this.enabled; } elseif (this.enabled) { // if its enabled, repeat what player says } } |
Quote:
this is what i picked up: function onCreated() { this.enabled = true; } function onPlayerChats() { if (player.chat == "stop") { enable; this.enabled = !this.enabled; } elseif (this.enabled) { // if its enabled, repeat what player says } } |
anyything in a line past two forward slashes is just a comment, and does not affect the script.
// this is a comment so, take a look at the following script. when it is "created" it sets this.enabled to true. When a player says "birdie!" this.enabled is set to the negation of itself. That setting of the negation is what causes the the toggling between the parrot repeating mode 'On' and 'Off'. Whenever the player says something that is not "birdie!", it checks if this.enabled is true. If that checks out, it repeats what the player says. function onCreated() { this.enabled = true; } function onPlayerChats() { if (player.chat == "birdie!") { // enable or disable here this.enabled = !this.enabled; } elseif (this.enabled) { // if its enabled, repeat what player says this.chat = player.chat; } } |
Quote:
and i dont know where in the script it represents this... sorry if you have put it all in i just have not learned this far into gs2 |
ok, i misunderstood part of what you were wanting.
function onCreated() { this.enabled = true; } function onPlayerChats() { if (player.chat == "enable") { this.enabled = true; } elseif (player.chat == "disable") { this.enabled = false; } elseif (this.enabled) { // if its enabled, repeat what player says this.chat = "*squawk*" @ player.chat @ "*squawk*"; } } does that make more sense? :) the @ operator is a concatination thing. so this is like putting "*squawk*" at the beginning and end of whatever the player says: "*squawk*" @ player.chat @ "*squawk*" |
Quote:
thanks so much :) heres your well deserved rep |
post it >here< the next time, thanks. this is not related to iera in any way
|
| All times are GMT. The time now is 01:35 AM. |
Powered by vBulletin/Copyright ©2000 - 2026, vBulletin Solutions Inc.