Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Shop say2 confusion (https://forums.graalonline.com/forums/showthread.php?t=24725)

relenakat 02-28-2002 05:14 AM

Shop say2 confusion
 
Grrr I figured this error out once in another script but now I can't figure out why it won't show the second say2 and skips to the third one!!!:grrr:
NPC Code:

if(playertouchsme){
this.t = 0;
this.bombs = 0;
this.arrows = 0;
this.hearts = 0;
sleep .1;
say2 .;
}
if (keydown(3)&&playerendsreading&&this.t==1) {
this.bombs = this.bombs+5;
say2 >Bombs #v(this.bombs) #b
Arrows #v(this.arrows) #b
Hearts #v(this.hearts);
this.t=0;
}
if (keydown(2)&&playerendsreading){
if(this.t==0) {
say2 >Bombs #v(this.bombs) #b
Arrows #v(this.arrows) #b
Hearts #v(this.hearts);
this.t = 1;
}
if(this.t==1) {
say2 Bombs #v(this.bombs) #b
>Arrows #v(this.arrows) #b
Hearts #v(this.hearts);
this.t = 2;
}
if(this.t==2) {
say2 Bombs #v(this.bombs) #b
Arrows #v(this.arrows) #b
>Hearts #v(this.hearts);
this.t = 0;
}
}
if(keydown(5)&&playerendsreading){
say2 Have a nice day!;
this.t = 0;
}


Phenom1K 02-28-2002 07:50 AM

Because it sets the other this. variable automatically.

Python523 02-28-2002 07:54 AM

Put a sleep right before setting the this.var

relenakat 02-28-2002 09:02 AM

:D Thanks I think that might be the problem.

relenakat 02-28-2002 10:07 AM

Ok...I did that but now it doesn't go down :(
NPC Code:

}
if(playertouchsme){
this.t = 0;
this.bombs = 0;
this.arrows = 0;
this.hearts = 0;
say2 A to cancel and S to buy;
}
if (keydown(3)&&playerendsreading&&this.t==0) {
this.bombs = this.bombs+5;
say2 >Bombs #v(this.bombs) #b
Arrows #v(this.arrows) #b
Hearts #v(this.hearts);
}
if (keydown(2)&&playerendsreading&&this.t==0){
say2 >Bombs #v(this.bombs) #b
Arrows #v(this.arrows) #b
Hearts #v(this.hearts);
sleep .5;
this.t = 1;
}
if(keydown(2)&&playerendsreading&&this.t==1) {
say2 Bombs #v(this.bombs) #b
>Arrows #v(this.arrows) #b
Hearts #v(this.hearts);
sleep .5;
this.t = 2;
}
if(keydown(2)&&playerendsreading&&this.t==2) {
say2 Bombs #v(this.bombs) #b
Arrows #v(this.arrows) #b
>Hearts #v(this.hearts);
sleep .5;
this.t = 0;
}
if(keydown(5)&&playerendsreading){
say2 Have a nice day!;
this.t = 0;
}


Python523 02-28-2002 10:32 AM

Say2 is a really bad way of doing that, I just made this a few minuets ago, learn from this, add the buying stuff yourself
*thinks hes going to get flamed for posting this =/*
// NPC made by Jagen
if (playertouchsme) {
this.select=1;
this.bombs=0;
this.hearts=0;
this.arrows=0;
disabledefmovement;
timeout=.05;
}
if (timeout&&this.select==1)
{
showimg 500,@-----> Hearts: #v(this.hearts),screenwidth-200,120;
showimg 501,@Bombs: #v(this.bombs),screenwidth-200,150;
showimg 502,@Arrows: #v(this.arrows),screenwidth-200,180;
changeimgvis 500,4;
changeimgvis 501,4;
changeimgvis 502,4;
timeout=.05;
}
if (timeout&&this.select==2)
{
showimg 500,@Hearts: #v(this.hearts),screenwidth-200,120;
showimg 501,@-----> Bombs: #v(this.bombs),screenwidth-200,150;
showimg 502,@Arrows: #v(this.arrows),screenwidth-200,180;
changeimgvis 500,4;
changeimgvis 501,4;
changeimgvis 502,4;
timeout=.05;
}
if (timeout&&this.select==3)
{
showimg 500,@Hearts: #v(this.hearts),screenwidth-200,120;
showimg 501,@Bombs: #v(this.bombs),screenwidth-200,150;
showimg 502,@-----> Arrows: #v(this.arrows),screenwidth-200,180;
changeimgvis 500,4;
changeimgvis 501,4;
changeimgvis 502,4;
timeout=.05;
}

if (timeout&&this.select==4)
{
this.select=1;
timeout=.05;
}
if (timeout&&this.select==0)
{
this.select=3;
timeout=.05;}
if (timeout&&keydown(0))
{sleep .5;
this.select-=1;
timeout=.05;
}
if (timeout&&keydown(2))
{sleep .5;
this.select+=1;
timeout=.05;
}
if (timeout&&keydown(3)&&this.select==1)
{sleep .5;
this.hearts++;
timeout=.05;
}

if (timeout&&keydown(3)&&this.select==2)
{sleep .5;
this.bombs++;
timeout=.05;
}
if (timeout&&keydown(3)&&this.select==3)
{sleep .5;
this.arrows++;
timeout=.05;
}
if (timeout&&keydown(1)&&this.select==1)
{sleep .5;
this.hearts--;
timeout=.05;
}

if (timeout&&keydown(1)&&this.select==2)
{sleep .5;
this.bombs--;
timeout=.05;
}
if (timeout&&keydown(1)&&this.select==3)
{sleep .5;
this.arrows--;
timeout=.05;
}


if (timeout)
{timeout=.05;}

relenakat 02-28-2002 12:23 PM

Thanks the thing is why I use say2 is because I'm more used to it no offense :D

neomaximus2k 02-28-2002 02:37 PM

Quote:

Originally posted by relenakat
Thanks the thing is why I use say2 is because I'm more used to it no offense :D
I agree Say2 is only really good for NPC's talking on a level or within a weapon when you fire it, the erst i would use showimg for as well just because i am aukward muwhahhaha

TDO2000 02-28-2002 05:42 PM

NPC Code:

if (playerenters || created) {
timereverywhere;
tokenize "Number1""Number2""Number3""Number4""Number5";
this.maxposes = tokenscount;
this.active=0;
this.pos=0;
this.oldkey=(-1);
}
if (playertouchsme) {
setani idle,;
this.active=1;
timeout=.05;
}
if (timeout) {
if (this.active==1) {
freezeplayer .05;
draw();
cursor();
timeout=.05;
}
else hideimgs();
}

function draw() {
for (i=0;i<this.maxposes;i++) {
showimg i,@#t(i),screenwidth/2-100,screenheight/2-(this.maxposes*15)+(i*15);
changeimgvis i,4;
if (this.pos==i) changeimgcolors i,1,0,0,0;
else changeimgcolors i,1,1,1,0;
}
}

function cursor() {
if (!keydown(this.oldkey)) this.oldkey=(-1);
for (i=0;i<4;i++) {
if(keydown(i) && i in {0,2} && !this.oldkey==i) {
if (i==0 && this.pos > 0) this.pos--;
if (i==2 && this.pos < this.maxposes-1) this.pos++;
this.oldkey=i;
}
}
if (keydown(4)) select();
if (keydown(5)) this.active=0;
}

function select() {
//Doing what the pos says
if (this.pos==0) setplayerprop #c,Number 1;
if (this.pos==1) setplayerprop #c,Number 2;
if (this.pos==2) setplayerprop #c,Number 3;
if (this.pos==3) setplayerprop #c,Number 4;
if (this.pos==4) setplayerprop #c,Number 5;
}

function hideimgs() {
for (i=0;i<this.maxposes;i++) hideimg i;
}



^-- should be easy to edit it ^_^
for new poses in the menu just add them in the tokenize-part
to do something with them just add it in the
if (this.pos==<number>) code;
part


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

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