Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help! Stock Market Script! (https://forums.graalonline.com/forums/showthread.php?t=19660)

Androk2k1 12-26-2001 11:53 PM

Help! Stock Market Script!
 
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;
}
}
}

Sennema 12-27-2001 12:03 AM

Re: Help! Stock Market Script!
 
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).

mhermher 12-27-2001 12:16 AM

Re: Re: Help! Stock Market Script!
 
Quote:

Originally posted by Sennema


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).

this.BUYamount=#t(2);
change that to
setstring this.BUYamount,#t(2);

Faheria_GP2 12-27-2001 12:59 AM

or use strtofloat

To the guy who posted the script: Learn to use the [.Code] Tags, I can barely read it without some sort of spacing structure

Faheria_GP2 12-27-2001 01:01 AM

Maybe I shoudl further explain it, Strings cannot be used as variables without strtofloat();

Tokenize produces strings, not variables, so anytime you want one to be treated as a variable, you will need to use strtofloat(#t(1)). Same thing goes with any string. TDK's control NPC has this problem.

Androk2k1 12-27-2001 02:35 AM

Yeah That was the whole problem it works now... =) Thx... anyhow whats the code thing soemone was talking about?

Androk2k1 12-27-2001 02:50 AM

HOLY it'z good...if you can buy alot it brings alot... some ppl might get lucky and buy stocks for ... 1 and sell for 2... 2 times as much! It nvere goes lower than 1...


All times are GMT +2. The time now is 02:13 PM.

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