Advertisement
Guest User

DanGTA

a guest
Feb 12th, 2009
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.44 KB | None | 0 0
  1. // CarSpawn script
  2. // By DanGTA
  3. // --- Num0 to bring up menu
  4. // --- Num1 to scroll through selections
  5. // --- Num2 to spawn the selected car
  6. // Email me at: deadlydan [at] gmail.com
  7.  
  8. using System;
  9. using System.Windows.Forms;
  10. using GTA;
  11.  
  12. public class CarSpawnScript : Script
  13. {
  14.     Font Text = new Font ( );
  15.     Boolean MenuVisible = false;
  16.     Int32 CurrentItem = 0;
  17.  
  18.     String[] AvailableCars = {"SANCHEZ", "ZOMBIEB", "MINIVAN", "FAGGIO", "SABREGT", "INFERNUS", "PCJ", "PATRIOT",
  19.                             "STRETCH", "SULTAN", "JETMAX", "MAVERICK", "DINGHY", "SUPERGT", "PREMIER", "COMET"};
  20.  
  21.     protected override void Startup ( )
  22.     {
  23.         Interval = 250;
  24.         Text.Alignment = TextAlignment.Left;
  25.         Text.Color = Color.White;
  26.         Text.Height = 0.3f;
  27.         Text.EnforcedWidth = 0.2f;
  28.  
  29.         CurrentItem = 0;
  30.         MenuVisible = false;
  31.     }
  32.  
  33.     protected override void KeyDown ( Keys key )
  34.     {
  35.         switch ( key )
  36.         {
  37.             case Keys.NumPad0:
  38.                 MenuVisible = !MenuVisible;
  39.                 Game.PlayPhoneKeypadTone ( 0, false );
  40.                 break;
  41.  
  42.             case Keys.NumPad1:
  43.                 if ( MenuVisible )
  44.                 {
  45.                     if ( CurrentItem == AvailableCars.Length - 1 )
  46.                         CurrentItem = 0;
  47.                     else
  48.                         CurrentItem += 1;
  49.  
  50.                     Game.PlayPhoneKeypadTone ( 1, false );
  51.                 }
  52.                 break;
  53.  
  54.             case Keys.NumPad2:
  55.                 if ( MenuVisible )
  56.                 {
  57.                     Vehicle VehiclePointer = World.CreateVehicle ( AvailableCars[CurrentItem], Player.Character.Position.Around ( 5.0f ) );
  58.                     Game.DisplayText ( "Created vehicle: " + AvailableCars[CurrentItem] );
  59.                     Game.PlayPhoneKeypadTone ( 2, false );
  60.                     MenuVisible = false;
  61.                 }
  62.                 break;
  63.         }
  64.     }
  65.  
  66.     protected override void PerFrameDrawing ( Graphics graphics )
  67.     {
  68.         if ( MenuVisible )
  69.         {
  70.             float width = RelativeWidth ( 224.0f );
  71.             float height = RelativeHeight ( 32.0f * AvailableCars.Length );
  72.             float x = RelativeWidth ( 896.0f );
  73.             float y = RelativeHeight ( 752.0f ) - height;
  74.  
  75.             int i = 0;
  76.             while ( i < AvailableCars.Length )
  77.             {
  78.                 ColourText ( i );
  79.                 graphics.DrawText ( x, y + RelativeHeight ( 32.0f * i ), AvailableCars[i], Text );
  80.                 i++;
  81.             }
  82.         }
  83.     }
  84.  
  85.     float RelativeWidth ( float x )
  86.     {
  87.         return ( x / 1024 );
  88.     }
  89.  
  90.     float RelativeHeight ( float y )
  91.     {
  92.         return ( y / 768 );
  93.     }
  94.  
  95.     void ColourText ( int i )
  96.     {
  97.         if ( i == CurrentItem )
  98.         {
  99.             Text.Color = System.Drawing.Color.Chocolate;
  100.         }
  101.         else
  102.         {
  103.             Model temp = new Model ( AvailableCars[i] );
  104.             if ( temp.isCar )
  105.                 Text.Color = System.Drawing.Color.NavajoWhite;
  106.             else if ( temp.isBike )
  107.                 Text.Color = System.Drawing.Color.Pink;
  108.             else if ( temp.isBoat )
  109.                 Text.Color = System.Drawing.Color.LightGreen;
  110.             else if ( temp.isHelicopter )
  111.                 Text.Color = System.Drawing.Color.LightSteelBlue;
  112.             else
  113.                 Text.Color = Color.White;
  114.         }
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement