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?