Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-26-2001, 11:53 PM
Androk2k1 Androk2k1 is offline
Banned
Androk2k1's Avatar
Join Date: Dec 2001
Posts: 1,336
Androk2k1 is on a distinguished road
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;
}
}
}
Reply With Quote
  #2  
Old 12-27-2001, 12:03 AM
Sennema Sennema is offline
Registered User
Join Date: Nov 2001
Location: Ontario, Canada
Posts: 132
Sennema is on a distinguished road
Send a message via ICQ to Sennema Send a message via AIM to Sennema
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).
__________________
~Draemus Windblade


Just over 90% of all messages have no point or meaning.

"In order to preserve ourselves we seek out and eliminate anything that may do use harm. In doing so, we destroy things that, though possibly hazzardous, may be important to survival. So you see, in trying to save ourselves, we ultimately bring about our own destruction"


Luminar
Reply With Quote
  #3  
Old 12-27-2001, 12:16 AM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
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);
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #4  
Old 12-27-2001, 12:59 AM
Faheria_GP2 Faheria_GP2 is offline
Banned
Faheria_GP2's Avatar
Join Date: Oct 2001
Posts: 1,177
Faheria_GP2 is on a distinguished road
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
Reply With Quote
  #5  
Old 12-27-2001, 01:01 AM
Faheria_GP2 Faheria_GP2 is offline
Banned
Faheria_GP2's Avatar
Join Date: Oct 2001
Posts: 1,177
Faheria_GP2 is on a distinguished road
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.
Reply With Quote
  #6  
Old 12-27-2001, 02:35 AM
Androk2k1 Androk2k1 is offline
Banned
Androk2k1's Avatar
Join Date: Dec 2001
Posts: 1,336
Androk2k1 is on a distinguished road
Yeah That was the whole problem it works now... =) Thx... anyhow whats the code thing soemone was talking about?
Reply With Quote
  #7  
Old 12-27-2001, 02:50 AM
Androk2k1 Androk2k1 is offline
Banned
Androk2k1's Avatar
Join Date: Dec 2001
Posts: 1,336
Androk2k1 is on a distinguished road
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...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:25 AM.


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