Advertisement
srdjan

Vehicle window's tint

Aug 29th, 2011
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.10 KB | None | 0 0
  1. /*  TINT system made by Srdjan
  2.     Today's date 28/08/2011   */
  3.  
  4. #include <a_samp>
  5.  
  6. #define COLOR_YELLOW 0xFFFF00AA                   // Took this random color from another GM of mine. Change as you wish
  7.  
  8. new Tinted [MAX_VEHICLES] = 0;                    // OnFilterScriptInit vehicles won't be tinted
  9. new Text3D: vehicle3dtext [MAX_VEHICLES];         // 3D text that will be above window tinted vehicle
  10. new PlVehID[MAX_VEHICLES];                        // Used in OnPlayerStateChange to check from which vehicle player's exiting
  11.  
  12. forward TintWindows ();                           // Forwarded this function for the timer
  13.  
  14. public OnFilterScriptInit ()
  15. {
  16.     printf (" Filterscript Tint system ");
  17.     printf (" made by Srdjan loaded  ");
  18.    
  19.     SetTimer ("TintWindows", 1500, 1);
  20.    
  21.     for (new i = 1; i <= MAX_VEHICLES; i++)
  22.     {
  23.         vehicle3dtext[i] = Create3DTextLabel (" ", COLOR_YELLOW, 0.0, 0.0, -50.0, 300.0, 0, 1);  // Creating 3dtext labels for every potential vehicle
  24.     }
  25.    
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerCommandText(playerid, cmdtext[])
  30. {
  31.     if (!strcmp (cmdtext, "/buytint"))
  32.     {
  33.         if (IsPlayerInAnyVehicle (playerid))
  34.         {
  35.             new vehid = GetPlayerVehicleID (playerid);
  36.             if (GetPlayerVehicleSeat (playerid) != 0)
  37.             {
  38.                 SendClientMessage (playerid, COLOR_YELLOW, "You need to be the driver to use this command.");
  39.             }
  40.             else
  41.             {
  42.                 if (Tinted[vehid])
  43.                 {
  44.                     SendClientMessage (playerid, COLOR_YELLOW, "Your windows are tinted already.");
  45.                 }
  46.                 else
  47.                 {
  48.                     Tinted[vehid] = 1;
  49.                     Update3DTextLabelText (vehicle3dtext[vehid], COLOR_YELLOW, "Vehicle's windows are tinted");
  50.                     SendClientMessage (playerid, COLOR_YELLOW, "Your windows have been tinted.");
  51.                 }
  52.             }
  53.         }
  54.         else
  55.         {
  56.             SendClientMessage (playerid, COLOR_YELLOW, "You need to be in the vehicle to use this command.");
  57.         }
  58.         return 1;
  59.     }
  60.     return 0;
  61. }
  62.  
  63.  
  64. public TintWindows ()
  65. {
  66.     for (new id = 1; id <= MAX_VEHICLES; id++)         // Going through every vehicle
  67.     {
  68.         if (Tinted[id])                                // Making sure their windows are tinted
  69.         {
  70.             Attach3DTextLabelToVehicle (vehicle3dtext[id], id, 0.0, 0.0, 1.2);   // If they are, 3dtext label will apear above the car
  71.             for (new i = 0; i < MAX_PLAYERS; i++)      // Going through every player
  72.             {
  73.                 if (IsPlayerInVehicle (i, id))         // Making sure he is sitting in the vehicle
  74.                 {
  75.                     for (new j = 0; j < MAX_PLAYERS; j++) // Another loop
  76.                     {
  77.                         if (!IsPlayerInVehicle (j, id))   // Making sure the other person is not in the vehicle
  78.                         {
  79.                             ShowPlayerNameTagForPlayer (j, i, 0);  // The person out of the vehicle won't be able to see the nametag of the one inside
  80.                         }
  81.                         else
  82.                         {
  83.                             ShowPlayerNameTagForPlayer (j, i, 1);
  84.                         }
  85.                     }
  86.                 }
  87.             }
  88.         }
  89.     }
  90.     return 1;
  91. }
  92.  
  93. public OnVehicleDeath (vehicleid)
  94. {
  95.     if (Tinted [vehicleid])
  96.     {
  97.         Update3DTextLabelText (vehicle3dtext[vehicleid], COLOR_YELLOW, " ");             // Changing the 3dtext label accordingly
  98.         Attach3DTextLabelToVehicle (vehicle3dtext[vehicleid], vehicleid, 0.0, 0.0, 1.2);
  99.         Tinted[vehicleid] = 0; // When the car's destroyed, that veh ID won't have windows tinted
  100.     }
  101.     return 1;
  102. }
  103.  
  104. public OnPlayerStateChange (playerid, newstate, oldstate)
  105. {
  106.     if ((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER))  // When player enters vehicle
  107.     {
  108.         PlVehID[playerid] = GetPlayerVehicleID (playerid);  // Writing the vehicle ID for further usage
  109.     }
  110.     if ((newstate == PLAYER_STATE_ONFOOT) && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER))  // When player exits vehicle
  111.     {
  112.         if (Tinted[PlVehID[playerid]])      // If the vehicle's windows were tinted (not necessary, but I've added)
  113.         {
  114.             for (new i=0; i < MAX_PLAYERS; i++)
  115.             {
  116.                 ShowPlayerNameTagForPlayer (i, playerid, 1);   // It will show the players name tag to everyone
  117.             }
  118.         }
  119.     }
  120.     return 1;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement