Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help me with script, etc. (https://forums.graalonline.com/forums/showthread.php?t=15143)

freddyfox 10-21-2001 10:13 PM

Help me with script, etc.
 
Here's my basic menu item buying script. And yes, I DO realize how long it is:

NPC Code:

if(playertouchsme){
disabledefmovement;
this.buymode = 1;
this.startbuy = 1;
timeout = 0.05;
}
if(timeout&&this.buymode=1){
if(this.buymode = 1&&this.startbuy = 1){
playersprite = 0;
showimg 200,standardsword.gif,30,40;
showimg 201,standardsword.gif,30,45;
showimg 202,standardsword.gif,30,50;
this.select = 1;
this.startbuy = 0;
}
if(keydown(0)){
this.select --;
}
if(keydown(2)){
this.select ++;
}
if(this.select = 1){
message Short Bronze Blade / 200 GP;
showimg 203,cursor.gif,35,35+5*this.select;
sleep 0.1;
}
if(this.select = 2){
message Long Bronze Blade / 700 GP;
showimg 203,cursor.gif,35,35+5*this.select;
sleep 0.1;
}
if(this.select = 3){
message Bronze Longsword / 3549 GP ;
showimg 203,cursor.gif,35,35+5*this.select;
sleep 0.1;
}
if(this.select = 4){
this.select --;
}
timeout = 0.05;
}
if(this.select = -1){
this.select ++;
}

//--BUYING--

if(keydown(4)&&this.select=1){
if(playerrupees >= 200){
play success.wav;
message Thank you!;
playerrupees -= 200;
setsword broadgoldsword.gif,1;
timeout = 0.5;
}
}
if(keydown(4)&&this.select=2){
if(playerrupees >= 700){
play success.wav;
message Thank you!;
playerrupees -= 700;
setsword broadgoldsword.gif,2;
timeout = 0.5;
}
}
if(keydown(4)&&this.select=3){
if(playerrupees >= 3549){
play success.wav;
message Thank you!;
playerrupees -= 3549;
setsword broadgoldsword.gif,3;
timeout = 0.5;
}
}

//---Not Enough Rupees---

if(keydown(4)&&this.select=1){
if(playerrupees <= 199){
play error.wav;
message Not enough money!;
timeout = 0.5;
}
}
if(keydown(4)&&this.select=2){
if(playerrupees <= 699){
play error.wav;
message Not enough money!;
timeout = 0.5;
}
}
if(keydown(4)&&this.select=3){
if(playerrupees <= 3548){
play error.wav;
message Not enough money!;
timeout = 0.5;
}
}
if(keydown(5)&&this.buymode=1){
message ;
this.buymode = 0
enabledefmovement;
hideimg 200;
hideimg 201;
hideimg 202;
hideimg 203;
hideimg 204;
}
if(this.buymode=0){
enabledefmovement;
}




Okay, looks fine and stuff. Only problem is, if I have two merchants with this script in the same level, the script malfunctions and ceases to freeze the player.

How can I remedy this?

Xaviar 10-21-2001 11:42 PM

Re: Help me with script, etc.
 
Quote:

Originally posted by freddyfox

if(this.buymode=0){
enabledefmovement;
}

Didn't really look that hard, but if I'm not mistaken, it's this sucker thats doing it.

Hulk Hogan 10-21-2001 11:46 PM

maybe add a

if (playerchats && stequals(#c,Buy from merchat 1)) {
set buyingfrommerchat1;
}

and then at the begining of your script add this to the
"if (playertcouchsme)"

if (playertouchsme && buyingfrommerchat1) {

and then just add an "unset buyingfrommerchat1" at the end?

and then change it for each merchat or npc to buyingfrommerchat2 or whatever flag you want to use?

Jerom 10-21-2001 11:50 PM

Quote:

Originally posted by Hulk Hogan
maybe add a

if (playerchats && stequals(#c,Buy from merchat 1)) {
set buyingfrommerchat1;
}

and then at the begining of your script add this to the
"if (playertcouchsme)"

if (playertouchsme && buyingfrommerchat1) {

and then just add an "unset buyingfrommerchat1" at the end?

and then change it for each merchat or npc to buyingfrommerchat2 or whatever flag you want to use?

Would require the merchants to wear numbers above their heads as well as giving them IDs, and it would be best to use tokenize with that.

Hulk Hogan 10-21-2001 11:53 PM

Quote:

Originally posted by Jerom

Would require the merchants to wear numbers above their heads as well as giving them IDs, and it would be best to use tokenize with that.

i just starting to learn to script :)
i know very little.....


maybe just add a name to the merchants then?
and a sign that says you have say the merchants name to buy from them??

i dont know about tokenize yet so maybe Jerom is right? I wouldn't know though ;)

Jerom 10-21-2001 11:55 PM

Quote:

Originally posted by Hulk Hogan


i just starting to learn to script :)
i know very little.....


maybe just add a name to the merchants then?
and a sign that says you have say the merchants name to buy from them??

i dont know about tokenize yet so maybe Jerom is right? I wouldn't know though ;)

I'm just trying to give a more flexible feel to the NPCs.
And I'm still learning how to script too(isawk).

TDO2000 10-21-2001 11:58 PM

I think Xavier is right:

if(keydown(5)&&this.buymode=1){
message ;
this.buymode = 0
enabledefmovement;
hideimg 200;
hideimg 201;
hideimg 202;
hideimg 203;
hideimg 204;
}
if(this.buymode=0){
enabledefmovement;
}

take the last one because if u buy from the second merchant this buymode of the first one is 0 so u can move but number 2 siabled so you collaps :)

u have used enabledefmovent before so it should be enough...

Xaviar 10-22-2001 01:46 AM

Quote:

Originally posted by TDO2000
I think Xavier is right:

if(keydown(5)&&this.buymode=1){
message ;
this.buymode = 0
enabledefmovement;
hideimg 200;
hideimg 201;
hideimg 202;
hideimg 203;
hideimg 204;
}
if(this.buymode=0){
enabledefmovement;
}

take the last one because if u buy from the second merchant this buymode of the first one is 0 so u can move but number 2 siabled so you collaps :)

u have used enabledefmovent before so it should be enough...

First of all, thanks for agreeing with me, but its Xaviar.
Second of all, I don't know if I was the only person that had trouble following the wording and bad spelling of that, so here's my interpretation(sp?):
Delete the if (this.buymode==0) {enabledefmovement;}..You don't need it

TDO2000 10-22-2001 02:03 AM

Hmmm to many thoughts (my english teacher has the same problems) ;)

freddyfox 10-22-2001 04:22 AM

Quote:

Originally posted by TDO2000
u have used enabledefmovent before so it should be enough...
It works, but now for some reason, the enabledefmovement doesn't go off and the player can't move, even when he's pressed the S key.

SSRobgeta 10-22-2001 05:04 AM

Amazing

Er1c 10-22-2001 06:23 AM

dont use disable/enable movement in that script, instead just put a freezeplayer timeoutsecs; in the timeout loop, with timeoutsecs = to the length of the timeout

and make sure that when the player is not in the menu mode the timeout is not looping

royce 10-22-2001 08:39 AM

name the first guy 'fingerme joe' and the second plain old 'bob mackey'


All times are GMT +2. The time now is 01:06 AM.

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