Guest User

Untitled

a guest
Jul 15th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.22 KB | None | 0 0
  1. # check if there is anyone traveling
  2. $tcheck = $db->query("SELECT `time`,`userid`,`location`,`ttype` FROM `traveling` WHERE `time` >= 0");
  3. if($db->num_rows($tcheck))
  4. {
  5.     while($t = $db->fetch_row($tcheck))
  6.     {
  7.         if($t['time'])
  8.         {
  9.             $db->query("UPDATE `traveling` SET `time` = GREATEST(`time` - 1, 0)");
  10.             if(mt_rand(1,3) == 3)
  11.             {
  12.                 $insured = $db->query("SELECT `insured`,`money` FROM `users` WHERE `userid` = {$t['userid']}");
  13.                 $in = $db->fetch_row($insured);
  14.                 if($in['insured'])
  15.                 {
  16.                     $travelcost = $db->fetch_single($db->query("SELECT `travelcost` FROM `locations`
  17.                         WHERE `ttype` = {$t['ttype']} AND `cityid` = {$t['location']}"));
  18.                     if($t['ttype'] == 'Car')
  19.                     {
  20.                         switch(mt_rand(1,4))
  21.                         {
  22.                             case 1:
  23.                                 $msg = $db->escape("Your tire poped and your car spun out of control");
  24.                                 $time = mt_rand(1,5);
  25.                                 $money = $travelcost / 100 * 50 / 2;
  26.                                 $in['money'] += $money;
  27.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  28.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  29.                                 $db->query("INSERT INTO `mail` VALUES (NULL, 0, 0, {$t['userid']}, ".time().",
  30.                                 'Insurance Team', 'As you are insured we have returned half of your travel cost
  31.                                 which is ".money_formatter($money)."')");
  32.                                     $db->query("UPDATE `users` SET `new_mail` = `new_mail` + 1 WHERE `userid` = {$t['userid']}");
  33.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  34.                                 $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']}");
  35.                             break;
  36.                             case 2:
  37.                                 $msg = $db->escape("You fainted while driving");
  38.                                 $time = mt_rand(1,15);
  39.                                 $money = $travelcost / 100 * 50 / 2;
  40.                                 $in['money'] += $money;
  41.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  42.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  43.                                 $db->query("INSERT INTO `mail` VALUES (NULL, 0, 0, {$t['userid']}, ".time().",
  44.                                 'Insurance Team', 'As you are insured we have returned half of your travel cost
  45.                                 which is ".money_formatter($money)."')");
  46.                                     $db->query("UPDATE `users` SET `new_mail` = `new_mail` + 1 WHERE `userid` = {$t['userid']}");
  47.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  48.                                 $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']}");
  49.                             break;
  50.                             case 3:
  51.                                 $msg = $db->escape("A crazy driver ran you off the road");
  52.                                 $time = mt_rand(1,25);
  53.                                 $money = $travelcost / 100 * 50 / 2;
  54.                                 $in['money'] += $money;
  55.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  56.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  57.                                 $db->query("INSERT INTO `mail` VALUES (NULL, 0, 0, {$t['userid']}, ".time().",
  58.                                 'Insurance Team', 'As you are insured we have returned half of your travel cost
  59.                                 which is ".money_formatter($money)."')");
  60.                                     $db->query("UPDATE `users` SET `new_mail` = `new_mail` + 1 WHERE `userid` = {$t['userid']}");
  61.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  62.                                 $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']}");
  63.                             break;
  64.                             case 4;
  65.                                 $msg = $db->escape("Your car engine exploded");
  66.                                 $time = mt_rand(1,50);
  67.                                 $money = $travelcost / 100 * 50 / 2;
  68.                                 $in['money'] += $money;
  69.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  70.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  71.                                 $db->query("INSERT INTO `mail` VALUES (NULL, 0, 0, {$t['userid']}, ".time().",
  72.                                 'Insurance Team', 'As you are insured we have returned half of your travel cost
  73.                                 which is ".money_formatter($money)."')");
  74.                                     $db->query("UPDATE `users` SET `new_mail` = `new_mail` + 1 WHERE `userid` = {$t['userid']}");
  75.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  76.                                 $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']}");
  77.                             break;
  78.                         }  
  79.                     }
  80.                     else if($t['ttype'] == 'Boat')
  81.                     {
  82.                         switch(mt_rand(1,3))
  83.                         {
  84.                             case 1:
  85.                                 $msg = $db->escape("Your boat hit a rock and you bumped your head");
  86.                                 $time = mt_rand(1,5);
  87.                                 $money = $travelcost / 100 * 50 / 2;
  88.                                 $in['money'] += $money;
  89.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  90.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  91.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  92.                             break;
  93.                             case 2:
  94.                                 $msg = $db->escape("The boats engine stopped working and you tried to fix it and lost your hand");
  95.                                 $time = mt_rand(1,15);
  96.                                 $money = $travelcost / 100 * 50 / 2;
  97.                                 $in['money'] += $money;
  98.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  99.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  100.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  101.                             break;
  102.                             case 3:
  103.                                 $msg = $db->escape("The boats engine exploded");
  104.                                 $time = mt_rand(1,25);
  105.                                 $money = $travelcost / 100 * 50 / 2;
  106.                                 $in['money'] += $money;
  107.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  108.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  109.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  110.                             break;
  111.                         }  
  112.                     }
  113.                     else if($t['ttype'] == 'Bus')
  114.                     {
  115.                         switch(mt_rand(1,3))
  116.                         {
  117.                             case 1:
  118.                                 $msg = $db->escape("The bus swearved another car and tumbled over you were hurt in acident");
  119.                                 $time = mt_rand(1,5);
  120.                                 $money = $travelcost / 100 * 50 / 2;
  121.                                 $in['money'] += $money;
  122.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  123.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  124.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  125.                             break;
  126.                             case 2:
  127.                                 $msg = $db->escape("Gang of thugs pull a driveby on your bus");
  128.                                 $time = mt_rand(1,15);
  129.                                 $money = $travelcost / 100 * 50 / 2;
  130.                                 $in['money'] += $money;
  131.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  132.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  133.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  134.                             break;
  135.                             case 3:
  136.                                 $msg = $db->escape("The buses engine exploded");
  137.                                 $time = mt_rand(1,25);
  138.                                 $money = $travelcost / 100 * 50 / 2;
  139.                                 $in['money'] += $money;
  140.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  141.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  142.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  143.                             break;
  144.                         }
  145.                     }
  146.                     else
  147.                     {
  148.                         switch(mt_rand(1,2))
  149.                         {
  150.                             case 1:
  151.                                 $msg = $db->escape("Pilot fell aleep at wheel lucky the co was there and stoped a big acidident");
  152.                                 $time = mt_rand(1,5);
  153.                                 $money = $travelcost / 100 * 50 / 2;
  154.                                 $in['money'] += $money;
  155.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  156.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  157.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  158.                             break;
  159.                             case 2:
  160.                                 $msg = $db->escape("Planes Engines failed and crashed you were the only survior");
  161.                                 $time = mt_rand(1,45);
  162.                                 $money = $travelcost / 100 * 50 / 2;
  163.                                 $in['money'] += $money;
  164.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  165.                                     `hospreason` = '{$msg}',`money` = {$in['money']} WHERE `userid` = {$t['userid']}");
  166.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  167.                             break;
  168.                         }
  169.                     }
  170.                 }
  171.                 else
  172.                 {
  173.                     if($t['ttype'] == 'Car')
  174.                     {
  175.                         switch(mt_rand(1,4))
  176.                         {
  177.                             case 1:
  178.                                 $msg = $db->escape("Your tire poped and your car spun out of control");
  179.                                 $time = mt_rand(1,5);
  180.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  181.                                     `hospreason` = '{$msg}'WHERE `userid` = {$t['userid']}");
  182.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  183.                                 $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']}");
  184.                             break;
  185.                             case 2:
  186.                                 $msg = $db->escape("You fainted while driving");
  187.                                 $time = mt_rand(1,15);                             
  188.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  189.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  190.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  191.                                 $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']}");
  192.                             break;
  193.                             case 3:
  194.                                 $msg = $db->escape("A crazy driver ran you off the road");
  195.                                 $time = mt_rand(1,25);
  196.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  197.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  198.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  199.                                 $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']}");
  200.                             break;
  201.                             case 4;
  202.                                 $msg = $db->escape("Your car engine exploded");
  203.                                 $time = mt_rand(1,50);                         
  204.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  205.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");                             
  206.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  207.                                 $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']}");
  208.                             break;
  209.                         }  
  210.                     }
  211.                     else if($t['ttype'] == 'Boat')
  212.                     {
  213.                         switch(mt_rand(1,3))
  214.                         {
  215.                             case 1:
  216.                                 $msg = $db->escape("Your boat hit a rock and you bumped your head");
  217.                                 $time = mt_rand(1,5);
  218.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  219.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  220.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  221.                             break;
  222.                             case 2:
  223.                                 $msg = $db->escape("The boats engine stopped working and you tried to fix it and lost your hand");
  224.                                 $time = mt_rand(1,15);
  225.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  226.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  227.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  228.                             break;
  229.                             case 3:
  230.                                 $msg = $db->escape("The boats engine exploded");
  231.                                 $time = mt_rand(1,25);
  232.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  233.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  234.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  235.                             break;
  236.                         }  
  237.                     }
  238.                     else if($t['ttype'] == 'Bus')
  239.                     {
  240.                         switch(mt_rand(1,3))
  241.                         {
  242.                             case 1:
  243.                                 $msg = $db->escape("The bus swearved another car and tumbled over you were hurt in acident");
  244.                                 $time = mt_rand(1,5);
  245.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  246.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  247.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  248.                             break;
  249.                             case 2:
  250.                                 $msg = $db->escape("Gang of thugs pull a driveby on your bus");
  251.                                 $time = mt_rand(1,15);
  252.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  253.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  254.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  255.                             break;
  256.                             case 3:
  257.                                 $msg = $db->escape("The buses engine exploded");
  258.                                 $time = mt_rand(1,25);
  259.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  260.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  261.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  262.                             break;
  263.                         }
  264.                     }
  265.                     else
  266.                     {
  267.                         switch(mt_rand(1,2))
  268.                         {
  269.                             case 1:
  270.                                 $msg = $db->escape("Pilot fell aleep at wheel lucky the co was there and stoped a big acidident");
  271.                                 $time = mt_rand(1,5);
  272.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  273.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  274.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  275.                             break;
  276.                             case 2:
  277.                                 $msg = $db->escape("Planes Engines failed and crashed you were the only survior");
  278.                                 $time = mt_rand(1,45);
  279.                                 $db->query("UPDATE `users` SET `hospital` = {$time},
  280.                                     `hospreason` = '{$msg}' WHERE `userid` = {$t['userid']}");
  281.                                 event_add($t['userid'], "You had a acident while traveling.<br /> {$msg}.");
  282.                             break;
  283.                         }
  284.                     }
  285.                 }
  286.             }
  287.         }
  288.         else
  289.         {
  290.             $db->query("UPDATE `users` SET `location` = {$t['location']},`traveling` = 0 WHERE `userid` = {$t['userid']}");
  291.             $db->query("DELETE FROM `traveling` WHERE `userid` = {$t['userid']} AND `time` = 0");
  292.         }
  293.     }
  294. }
Advertisement
Add Comment
Please, Sign In to add comment