Advertisement
JaTochNietDan

Untitled

Jul 17th, 2011
1,539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2.  
  3. echo '
  4. <div class="content_box"><b>Random Spawn Array Generator - Generates a random spawn array from SavedPositions.txt!</b></div>
  5.     <form method="POST" name="editor">
  6.         <textarea name="code" cols="80" rows="30" class="paste_textarea">';
  7.        
  8. if(!empty($_POST['code']))
  9. {
  10.     $text = $_POST['code'];
  11.     $text = explode("\n",$text);
  12.     $incAngles = $_POST['incAngles'];
  13.     $counter = 0;
  14.     $string = "";
  15.    
  16.     for($i = 0; $i < sizeof($text); $i++)
  17.     {
  18.         $sText = explode(",",$text[$i]);
  19.        
  20.         if(empty($sText[1]) || empty($sText[2]) || empty($sText[3]) || empty($sText[4])) continue;
  21.        
  22.         if($incAngles == "on")
  23.             if($i != sizeof($text) - 1) $string .= "    {".$sText[1].",".$sText[2].",".$sText[3].",".$sText[4]."},\n";
  24.             else $string .=  "    {".$sText[1].",".$sText[2].",".$sText[3].",".$sText[4]."}\n";
  25.         else
  26.             if($i != sizeof($text) - 1) $string .=  "    {".$sText[1].",".$sText[2].",".$sText[3]."},\n";
  27.             else $string .=  "    {".$sText[1].",".$sText[2].",".$sText[3]."}\n";      
  28.  
  29.         $counter++;
  30.     }
  31.    
  32.     echo "new Float:".$_POST['format']."[".$counter."][".($incAngles == "on" ? "4" : "3")."] = {\n";
  33.    
  34.     echo $string;
  35.    
  36.     echo '};';
  37. }
  38.  
  39. echo '</textarea>  
  40.         <div class="form_frame">
  41.             <div class="form_left">
  42.                 Array name:
  43.             </div>
  44.             <div class="form_right">
  45.                 <input type="text" value="randomSpawns" name="format" size="20" class="post_input">
  46.             </div>
  47.             <div class="form_left">
  48.                 Include angles:
  49.             </div>
  50.             <div class="form_right">
  51.                 <input type="checkbox" name="incAngles">
  52.             </div>
  53.         </div>
  54.         <input type="submit" value="Split String" name="Submit">
  55.     </form>';
  56.    
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement