not sure of how to do this with the npcserver but maybe, any parts that require a global variable I will denote with //global
NPC Code:
//NPC made by Solareon
//Basic Stock Market Script
if (created) {
//initialize market values from npcserver
//local
//this should be programmed to happen once and only once
basefishprice=1
basefishrate=15
basepearlprice=1
basepearlrate=1
basefarmprice=1
basefarmrate=1
}
//global
//this counts how many of each item is currently in the market
//npcserver(blah) denotes that a variable needs to be fetched
//from the npcserver
if (fetchnew) {
fishtradein=npcserver(fishtoday)
fishactive=npcserver(fishcurrent)
pearltradein=npcserver(pearltoday)
pearlactive=npcserver(pearlactive)
farmtradein=npcserver(farmtoday)
farmactive=npcserver(farmcurrent)
}
//local
if (startmarket) {
//get a random number (I don't feel up to looking in commands.rtf
//for the exact thing)
//random number makes the market impossible to manipulate
random=random(1-10)
calculate=basefishprice*(fishactive/basefishrate)
fishprice=fishtradein*random+calculate
}
//the example of the market starting is only for fish but the others
//are pretty much the same
//also change calculate to reflect the different markets and their
//rates. if you intend on usign the same method
if (playerchats(buy fish)) {
playerfishstock+=10
players[0].rupees=players[0].rupees-(fishprice*10)
//global
fishstockbuy+=10
}
//the above allows the player to buy the fish stock in increments
//of ten, if a person wanted to make this so he can buy varing
//numbers of stock (I don't like that tokenize and removing string
//thing) that would be great
if (playerchats(sell fish)) {
playerfishstock-=10
players[0].rupees=players[0].rupees+(fishprice*10)
//global
fishstockbuy-=10
}
//the following still needs to be impelmented, I would do it but I
//don't have the time. a way for the stock bought(sp) to affect
//the market price, rather than havign to fetch new variables
//each time. also the stock price to affect the prices of the goods
//traded or sold. Also the market scripting for pearls and farming,
//mining and bird catching may be added but I don't know much
//about either or on how to do them. also a way to change the
//price of the particular stock by the amount of things in the
//market or the stock bought
//how the script works
//created, it starts all the variables up.
//fetchnew (set the flag and it fires or make it a function) gets the
//values to calculate the market prices
//startmarket (set as flag or make a function) starts up the
//market and sets the prices for stock
//everything else is self explanitory
if anyone can use the above example coding to make a workign stock market that would be awesome, the above was possible with my limited scripting abilities. rmemeber we still need images too and a levle for the stock trading.
ENJOY!