Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CarSpawn script
- // By DanGTA
- // --- Num0 to bring up menu
- // --- Num1 to scroll through selections
- // --- Num2 to spawn the selected car
- // Email me at: deadlydan [at] gmail.com
- using System;
- using System.Windows.Forms;
- using GTA;
- public class CarSpawnScript : Script
- {
- Font Text = new Font ( );
- Boolean MenuVisible = false;
- Int32 CurrentItem = 0;
- String[] AvailableCars = {"SANCHEZ", "ZOMBIEB", "MINIVAN", "FAGGIO", "SABREGT", "INFERNUS", "PCJ", "PATRIOT",
- "STRETCH", "SULTAN", "JETMAX", "MAVERICK", "DINGHY", "SUPERGT", "PREMIER", "COMET"};
- protected override void Startup ( )
- {
- Interval = 250;
- Text.Alignment = TextAlignment.Left;
- Text.Color = Color.White;
- Text.Height = 0.3f;
- Text.EnforcedWidth = 0.2f;
- CurrentItem = 0;
- MenuVisible = false;
- }
- protected override void KeyDown ( Keys key )
- {
- switch ( key )
- {
- case Keys.NumPad0:
- MenuVisible = !MenuVisible;
- Game.PlayPhoneKeypadTone ( 0, false );
- break;
- case Keys.NumPad1:
- if ( MenuVisible )
- {
- if ( CurrentItem == AvailableCars.Length - 1 )
- CurrentItem = 0;
- else
- CurrentItem += 1;
- Game.PlayPhoneKeypadTone ( 1, false );
- }
- break;
- case Keys.NumPad2:
- if ( MenuVisible )
- {
- Vehicle VehiclePointer = World.CreateVehicle ( AvailableCars[CurrentItem], Player.Character.Position.Around ( 5.0f ) );
- Game.DisplayText ( "Created vehicle: " + AvailableCars[CurrentItem] );
- Game.PlayPhoneKeypadTone ( 2, false );
- MenuVisible = false;
- }
- break;
- }
- }
- protected override void PerFrameDrawing ( Graphics graphics )
- {
- if ( MenuVisible )
- {
- float width = RelativeWidth ( 224.0f );
- float height = RelativeHeight ( 32.0f * AvailableCars.Length );
- float x = RelativeWidth ( 896.0f );
- float y = RelativeHeight ( 752.0f ) - height;
- int i = 0;
- while ( i < AvailableCars.Length )
- {
- ColourText ( i );
- graphics.DrawText ( x, y + RelativeHeight ( 32.0f * i ), AvailableCars[i], Text );
- i++;
- }
- }
- }
- float RelativeWidth ( float x )
- {
- return ( x / 1024 );
- }
- float RelativeHeight ( float y )
- {
- return ( y / 768 );
- }
- void ColourText ( int i )
- {
- if ( i == CurrentItem )
- {
- Text.Color = System.Drawing.Color.Chocolate;
- }
- else
- {
- Model temp = new Model ( AvailableCars[i] );
- if ( temp.isCar )
- Text.Color = System.Drawing.Color.NavajoWhite;
- else if ( temp.isBike )
- Text.Color = System.Drawing.Color.Pink;
- else if ( temp.isBoat )
- Text.Color = System.Drawing.Color.LightGreen;
- else if ( temp.isHelicopter )
- Text.Color = System.Drawing.Color.LightSteelBlue;
- else
- Text.Color = Color.White;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement