Quote:
Originally posted by Androk2k1
OK I am having problems with NPC taking money from the player. Here's a script:
--- Script ---
// NPC made by Androk
// Stocks
// Variables:
// this.ANTamount - Amount of ANT stock.
// this.function - Function that is happening
// (0 - Nothing, 1 - stock name, 2 - amount of stock).
// this.BUYamount - Temparary amount of stocks to buy.
if (playerenters) {
toweapons Stocks;
}
if (playerchats) {
tokenize #c;
if (strequals(#t(0),buy)) {
this.BUYamount=#t(2);
if (strequals(#t(1),ANT)&&playerrupees>server.ANTpric e*this.BUYamount-1) {
playerrupees-=server.ANTprice*this.BUYamount;
this.ANTamount+=this.BUYamount;
}
}
}
|
I just skimmed through it a bit, but the problem seems to be that your playing around with tokens that haven't been set yet.
ex:
NPC Code:
if(strequals(#t(0),buy)) {
this.BUYamount=#t(2);
Change the strequals to something else, like startswith or something. But I'm not sure. It's 12:00 and I just woke up after going to bed at 1:00.
Your also gonna have to check the length of the string (strelen I think it is).