View Single Post
  #12  
Old 01-03-2013, 06:03 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
This was my initial attempt at making fake stocks.
Instead of having to wait t'ill the real stock market is open.
PHP Code:
function onCreated(){
  
onTimeout();
  
this.stocks = {
    {
"Graalordinates", -212},
    {
"PlayerKillCo", -53},
    {
"UnixmadBreadFund", -710},
    {
"BrokeLenders", -613},
    {
"Gold", -123},
    {
"Silver", -0.512},
    {
"Oil", -2.615},
    {
"Facebook", -418},
    {
"Google", -314},
    {
"Yahoo", -211},
  };
}
function 
onTimeout(){
  for(
0this.stocks.size(); ++){
    
temp.stock this.stocks[i][0];
    
temp.min this.stocks[i][1];
    
temp.max this.stocks[i][2];
    
temp.amnt random(minmax);
    if(
this.stock_price.(@stock) < amnt){
      
this.stock_price.(@stock) += random(0.010.02);
    }
    if(
this.stock_price.(@stock) > amnt){
      
this.stock_price.(@stock) -= random(0.010.02);
    }
    
temp.min this.stock_price.(@stock) < 0;
    
this.stock_price.(@stock) = this.stock_price.(@stock[0]).substring(0, (min?5:4));
  }
  
settimer(5);

__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote