Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Slideing door (https://forums.graalonline.com/forums/showthread.php?t=10713)

wetferret1 08-29-2001 02:30 PM

Slideing door
 
Okay I need a "Kingdome door" When someone has a TAG and the say "Open gate" it slides open and when they say "Close Gate" It slides closed.

KJS 08-29-2001 04:08 PM

NPC Code:

if(playerchats){
if(strequals(#c,open doors)
opendoor();
elseif(strequals(#c,close doors)
closedoor();
}
function opendoor(){
for (this.moved=0;this.moved<5;this.moved++)
x--;
}
function closedoor(){
for (this.moved=0;this.moved<5;this.moved++)
x++;
}



well I guess it would probably make it a shorter code if I would have took what is in the functions and like put it in were it calls it but oh well to lazy to do that now (I am pretty sure htis iwll work for an npc server)..

this will make the npc move back and forth 5 tiles (left and right)

wetferret1 08-29-2001 06:23 PM

Will it work offline? And what about the Kingdome/guild TAG part?

KJS 08-29-2001 11:16 PM

NPC Code:

if(playerchats&&strequals(#g,GUILDNAME)){
if(strequals(#c,open door)&&this.open==0){
for (this.moved=0;this.moved<10;this.moved++){
x-=0.5;
sleep 0.1;
}
this.open=1;
}elseif(strequals(#c,close door)&&this.open==1){
for (this.moved=0;this.moved<10;this.moved++){
x+=0.5;
sleep 0.1;
}
this.open=0;
}
}



this one is a lot better then the other one lol (the other one it wouldn't smoothly go over it would just appear there lol so I added a sleep, took out the functions, and made it so they can only open the door if the door is closed)

yes it does work offline... (and pretty sure it works online all the functions look like they will work online)...

only thing you have to edit is the guild name in red

milotheman 08-29-2001 11:24 PM

wow KJL u r good scripter

Neoreno 08-29-2001 11:41 PM

Code
 
if(playerchats&&strequals(#g,GUILDNAME)){
if(strequals(#c,open door)&&this.open==0){
for (this.moved=0;this.moved<10;this.moved++){
x-=0.5;
sleep 0.1;
}
this.open=1;
}elseif(strequals(#c,close door)&&this.open==1){
for (this.moved=0;this.moved<10;this.moved++){
x+=0.5;
sleep 0.1;
}
this.open=0;
}
}

Will work!!:D

Falcor 08-30-2001 10:24 PM

NPC Code:

if(playerchats && strequals(#g,GUILDNAME)){
if(strequals(#c,open door)&&dooropen==0){
dooropen=2;
move -5,0,10,0;
sleep 10;
dooropen=1;
}else if(strequals(#c,close door)&&dooropen==1){
dooropen=2;
move 5,0,10,0;
sleep 10;
dooropen=0;
}
}



Why make life harder and lag more?

KJS 08-30-2001 11:00 PM

Quote:

Originally posted by Falcor
NPC Code:

if(playerchats && strequals(#g,GUILDNAME)){
if(strequals(#c,open door)&&dooropen==0){
dooropen=2;
move -5,0,10,0;
sleep 10;
dooropen=1;
}else if(strequals(#c,close door)&&dooropen==1){
dooropen=2;
move 5,0,10,0;
sleep 10;
dooropen=0;
}
}



Why make life harder and lag more?

humm wow I forgot about the move command lol...

Admins 08-30-2001 11:12 PM

Yes using the move command is better
Possible improvement: let the door fall down
fast when closed (instead of slowly closing)

A gani would even be better :-)

Admins 08-30-2001 11:13 PM

Also don't forget to make the link behind the
door using an npc instead of those yellow links,
because otherwise people could lag into the link

AlexH 08-31-2001 12:44 AM

there is only one problem with the move command
say you have it so when the player says open the door moves 4 tiles to the left then sleeps for 3 the moves back 4
if you say open again when the sleep is being used it will move over another 4 positions again
sosad :(

AlexH 08-31-2001 12:55 AM

ganis ok
but depending on the way you script it that could also be a problem
like if it was playing the gani and you said open the gani will start playing again from the start
but you could just set a flag then unset it a few secs later
like

if (playersays(open)&&!opening) {
setcharani *whateva,;
set opening;
sleep 5;
unset opening;
}

that should work without problems
but i know Kaimetsu wont like it cause he is anti-flags

KJS 08-31-2001 12:58 AM

it would be better just to use vars

like

this.opening=1;

and go like

this.opening==0

insted of

!opening

AlexH 08-31-2001 01:04 AM

very sorry
would it be better if i used timeout

AlexH 08-31-2001 01:09 AM

ok timeout it is
if (playersays(open)&&!opening) {
setcharani whateva,;
set opening;
timeout = 3;
}
if (timeout) {
unset opening
}

better?

AlexH 08-31-2001 01:14 AM

o yea
woops 4got bout that
and i got one question
what do you have against flags

LiquidIce00 08-31-2001 02:41 AM

make a gani of a door going up then do ur script a dontblock and then one of a door closing and do a blockagain
wont lag and will be good ;)

Falcor 08-31-2001 02:47 AM

Contreversy. Ganis may be better but they require you to Download it. Id rath script it with move then to make a gani file for it since its such a simple script =\

08-31-2001 02:50 AM

try this simple one...

NPC Code:

// sliding door by Ice Pick
if (playerenters && players[0].x == 9 && players[0].y == 25){
timereverywhere;
setgifpart ninjidoorleft.gif, 0, 33, 32, 32;
this.mode = 2;
this.open = 33;
timeout = 0.5;
this.start = 0;
}
else if (playerenters) {
setgif ninjidoorleft.gif;
timereverywhere;
this.open = 0;
this.mode = 0;
this.start = 1;
}

if (playertouchsme && (((this.mode == 1 || this.mode == 0) && this.open == 0) || (this.mode == 2 && this.wideopen != 1))) {
this.mode = 1;
play fire.wav;
timeout = 0.1;
this.start = 0;
}

if (timeout && this.start == 1) this.start = 0;
else if (timeout) {
if (this.mode == 1) this.open+=6;
if (this.mode == 2) {
this.open-=2;
this.wideopen = 0;
}
setgifpart ninjidoorleft.gif, 0, this.open, 32, 32;
blockagain;
if ((this.mode == 1 && this.open <= 32) || (this.mode == 2 && this.open >= 0)) timeout = 0.1;
else if (this.mode == 1){
dontblock;
timeout = 2;
this.mode = 2;
this.wideopen = 1;
}
else play arrowon.wav;
}


Falcor 08-31-2001 03:00 AM

Simple one. Hahaha that OLD door script. You never even botherd to rename the variables. You bring it apon yourself Ice Pick.

08-31-2001 03:02 AM

Shut the hell up!:grrr:

AlexH 08-31-2001 03:04 AM

Quote:

Originally posted by Falcor
Simple one. Hahaha that OLD door script. You never even botherd to rename the variables. You bring it apon yourself Ice Pick.
sosad
he will learn one day

Falcor 08-31-2001 03:06 AM

Ace's Scripting guide is a nice start

the rest is basiclaly done through countless trails and frequent errors.

AlexH 08-31-2001 03:26 AM

yes
practice makes perfect
and once your perfect you can show off
so really practice just makes show offs :)


All times are GMT +2. The time now is 03:52 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.