19.06.2009, 21:15
i want to set up simple stock market, that gradually grow bigger, but can crash at anytime
i am a very begginer and would really appritiate it if someone would just quickly show me how i could do this
i know this code is wrong but it show basically what i am trying to get done, could you please help me with it
i am a very begginer and would really appritiate it if someone would just quickly show me how i could do this
i know this code is wrong but it show basically what i am trying to get done, could you please help me with it
pawn Code:
new StockPrice = 100; //starts at $100 a share
forward StockIncreaser();
pawn Code:
OnGameModeInIt()
{
SetTimer("StockIncreaser",5000,true);
}
pawn Code:
StockIncreaser()
{
StockPrice = StockPrice+random(50) || Test-random(20);
//every 5 seconds it go up or down randomly with a greater chance to grow bigger, so it slowly grow big over time
//if the last random worse then -19, very uncommon, it trigger stock to crash
if last random <= -19
{
StockPrice = StockPrice-random(200); //huge chance it be worse then -19 again, causing stock to crash to $0 share
//if it not worse then -19, go back to other random
}
if(StockPrice <=0)//then if it crash back to $0 a share, restart it all over
{
StockPrice = 50;
killTimer("StockIncreaser");
SetTimer("StockIncreaser",5000,true);
}
}