Graalians

Graalians (https://www.graalians.com/forums/index.php)
-   Creative Corner (https://www.graalians.com/forums/forumdisplay.php?f=17)
-   -   A little script help... (https://www.graalians.com/forums/showthread.php?t=10472)

Clown 09-21-2012 05:43 PM

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 :)

0PiX0 09-21-2012 05:48 PM

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

Clown 09-21-2012 05:55 PM

Quote:

Posted by 0PiX0 (Post 201697)
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
}
}

im dearly sorry i didnt mention this, im new to coding so i dont quite get the commands... especially the line "// if its enabled, repeat what player says"

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

0PiX0 09-21-2012 06:07 PM

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

Clown 09-21-2012 06:13 PM

Quote:

Posted by 0PiX0 (Post 201707)
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;
}
}

i kinda see what youre saying...but i dont know what to put in the enable and disable section. i want to make it so there are two commands: stop and speak
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

0PiX0 09-21-2012 06:32 PM

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*"

Clown 09-21-2012 07:32 PM

Quote:

Posted by 0PiX0 (Post 201712)
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*"


thanks so much :) heres your well deserved rep

callimuc 09-21-2012 08:24 PM

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.