Advertisement
Larceny

nLibrary

Jun 17th, 2011
1,746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.86 KB | None | 0 0
  1. /*                 
  2.                     ********************************
  3.                         nLibrary - Neon Library
  4.                     ********************************
  5. Description:
  6.     Allows you to attach neons to the selected vehicle.
  7. Version:
  8.     1.5
  9. Developer:
  10.     Luke "Shelby" Godoy.
  11. ChangeLOG:
  12.     20/10/2011:
  13.         Small fixes.
  14.     20/06/2011:
  15.         Buzzer can be used with neons.
  16.     19/06/2011:
  17.         Buzzer(neon) available for attachment.
  18.     18/06/2011:
  19.         Improvement in the speed of the functions 'GetVehicleNeonColor' & 'IsVehicleUsingNeon'
  20.         Thanks to: ScripterTroll.
  21.         Changes in native 'IsVehicleUsingNeon'.
  22.     17/06/2011:
  23.         First version.
  24. Thanks To:
  25.     CiNyC - Insanity Vehicle Attachment Editor
  26. Natives:
  27.     native AttachNeonToVehicle(vehicleid, neonid);
  28.     native RemoveNeonFromVehicle(vehicleid);
  29.     native IsVehicleUsingNeon(vehicleid);
  30.     native GetVehicleNeonColor(vehicleid);
  31.     native IsVehicleUsingBuzzer(vehicleid);
  32.     native RemoveBuzzerFromVehicle(vehicleid);
  33. */
  34.  
  35. #include <a_samp>
  36. #if defined _nLibrary_included
  37.     #endinput
  38. #endif
  39.  
  40. #define _nLibrary_included
  41. #define NEON_BLUE                               (0)
  42. #define NEON_PINK                               (1)
  43. #define NEON_YELLOW                             (2)
  44. #define NEON_GREEN                              (3)
  45. #define NEON_RED                                (4)
  46. #define NEON_WHITE                              (5)
  47. #define NEON_POLICE                             (6)
  48.  
  49. #define GetVehicleNeonColor(%0) NEON_COR[%0]
  50. #define IsVehicleUsingNeon(%0) IsValidObject(NEON_ONE[%0])
  51. #define IsVehicleUsingBuzzer(%0) IsValidObject(NEON_THR[%0])
  52. #define RemoveBuzzerFromVehicle(%0); DestroyObject(NEON_THR[%0]); \
  53. NEON_THR[%0] = INVALID_OBJECT_ID;
  54.  
  55. new NEON_ONE[MAX_VEHICLES] = {INVALID_OBJECT_ID, ...};
  56. new NEON_TWO[MAX_VEHICLES] = {INVALID_OBJECT_ID, ...};
  57. new NEON_THR[MAX_VEHICLES] = {INVALID_OBJECT_ID, ...};
  58. new NEON_COR[MAX_VEHICLES][10];
  59.  
  60. stock Bike(vehicleid)
  61. {  
  62.     new model = GetVehicleModel(vehicleid);
  63.     if(model == 522 || model == 462 || model == 521 || model == 461 || model == 463 || model == 581 || model == 448 || model == 586 || model == 523 || model == 468 || model == 471 || model == 509 || model == 510 || model == 481) return 1;
  64.     return 0;
  65. }
  66.  
  67. stock AttachNeonToVehicle(vehicleid, neonid /*, playerid = INVALID_PLAYER_ID*/ )
  68. {
  69.     switch(neonid)
  70.     {
  71.         case NEON_BLUE:
  72.         {
  73.             DestroyObject(NEON_ONE[vehicleid]); DestroyObject(NEON_TWO[vehicleid]);
  74.             if(Bike(vehicleid)){NEON_ONE[vehicleid] = CreateObject(18648,0,0,0,0,0,0); AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, 0.0, 0.0, -0.70, 0.0, 0.0, 0.0); NEON_TWO[vehicleid] = INVALID_OBJECT_ID; return 1;}
  75.             NEON_ONE[vehicleid] = CreateObject(18648,0,0,0,0,0,0); NEON_TWO[vehicleid] = CreateObject(18648,0,0,0,0,0,0);
  76.             AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  77.             AttachObjectToVehicle(NEON_TWO[vehicleid], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  78.             NEON_COR[vehicleid] = "Blue";
  79.             return 1;
  80.         }
  81.         case NEON_PINK:
  82.         {
  83.             DestroyObject(NEON_ONE[vehicleid]); DestroyObject(NEON_TWO[vehicleid]);
  84.             if(Bike(vehicleid)){NEON_ONE[vehicleid] = CreateObject(18651,0,0,0,0,0,0); AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, 0.0, 0.0, -0.70, 0.0, 0.0, 0.0); NEON_TWO[vehicleid] = INVALID_OBJECT_ID; return 1;}
  85.             NEON_ONE[vehicleid] = CreateObject(18651,0,0,0,0,0,0); NEON_TWO[vehicleid] = CreateObject(18651,0,0,0,0,0,0);
  86.             AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  87.             AttachObjectToVehicle(NEON_TWO[vehicleid], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  88.             NEON_COR[vehicleid] = "Pink";
  89.             return 1;
  90.         }
  91.         case NEON_YELLOW:
  92.         {
  93.             DestroyObject(NEON_ONE[vehicleid]); DestroyObject(NEON_TWO[vehicleid]);
  94.             if(Bike(vehicleid)){NEON_ONE[vehicleid] = CreateObject(18650,0,0,0,0,0,0); AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, 0.0, 0.0, -0.70, 0.0, 0.0, 0.0); NEON_TWO[vehicleid] = INVALID_OBJECT_ID; return 1;}
  95.             NEON_ONE[vehicleid] = CreateObject(18650,0,0,0,0,0,0); NEON_TWO[vehicleid] = CreateObject(18650,0,0,0,0,0,0);
  96.             AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  97.             AttachObjectToVehicle(NEON_TWO[vehicleid], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  98.             NEON_COR[vehicleid] = "Yellow";
  99.             return 1;
  100.         }
  101.         case NEON_GREEN:
  102.         {
  103.             DestroyObject(NEON_ONE[vehicleid]); DestroyObject(NEON_TWO[vehicleid]);
  104.             if(Bike(vehicleid)){NEON_ONE[vehicleid] = CreateObject(18649,0,0,0,0,0,0); AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, 0.0, 0.0, -0.70, 0.0, 0.0, 0.0); NEON_TWO[vehicleid] = INVALID_OBJECT_ID; return 1;}
  105.             NEON_ONE[vehicleid] = CreateObject(18649,0,0,0,0,0,0); NEON_TWO[vehicleid] = CreateObject(18649,0,0,0,0,0,0);
  106.             AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  107.             AttachObjectToVehicle(NEON_TWO[vehicleid], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  108.             NEON_COR[vehicleid] = "Green";
  109.             return 1;
  110.         }
  111.         case NEON_RED:
  112.         {
  113.             DestroyObject(NEON_ONE[vehicleid]); DestroyObject(NEON_TWO[vehicleid]);
  114.             if(Bike(vehicleid)){NEON_ONE[vehicleid] = CreateObject(18647,0,0,0,0,0,0); AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, 0.0, 0.0, -0.70, 0.0, 0.0, 0.0); NEON_TWO[vehicleid] = INVALID_OBJECT_ID; return 1;}
  115.             NEON_ONE[vehicleid] = CreateObject(18647,0,0,0,0,0,0); NEON_TWO[vehicleid] = CreateObject(18647,0,0,0,0,0,0);
  116.             AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  117.             AttachObjectToVehicle(NEON_TWO[vehicleid], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  118.             NEON_COR[vehicleid] = "Red";
  119.             return 1;
  120.         }
  121.         case NEON_WHITE:
  122.         {
  123.             DestroyObject(NEON_ONE[vehicleid]); DestroyObject(NEON_TWO[vehicleid]);
  124.             if(Bike(vehicleid)){NEON_ONE[vehicleid] = CreateObject(18652,0,0,0,0,0,0); AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, 0.0, 0.0, -0.70, 0.0, 0.0, 0.0); NEON_TWO[vehicleid] = INVALID_OBJECT_ID; return 1;}
  125.             NEON_ONE[vehicleid] = CreateObject(18652,0,0,0,0,0,0); NEON_TWO[vehicleid] = CreateObject(18652,0,0,0,0,0,0);
  126.             AttachObjectToVehicle(NEON_ONE[vehicleid], vehicleid, -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  127.             AttachObjectToVehicle(NEON_TWO[vehicleid], vehicleid, 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
  128.             NEON_COR[vehicleid] = "White";
  129.             return 1;
  130.         }
  131.         case NEON_POLICE:
  132.         {
  133.             if(Bike(vehicleid)){NEON_THR[vehicleid] = CreateObject(18646,0,0,0,0,0,0); AttachObjectToVehicle(NEON_THR[vehicleid], vehicleid, 0.014999, 0.724999, 0.669999, 0.0, 0.0, 0.0); return 1;}
  134.             NEON_THR[vehicleid] = CreateObject(18646,0,0,0,0,0,0);
  135.             AttachObjectToVehicle(NEON_THR[vehicleid], vehicleid, -0.5, -0.2, 0.8, 2.0, 2.0, 3.0);
  136.             return 1;
  137.         }
  138.         default:
  139.         {
  140.             /*if(playerid != INVALID_PLAYER_ID) SendClientMessage(playerid, 0xA9C4E4FF, "Cor do neon inválida.");*/
  141.             print("ERROR: Invalid neon color.");
  142.         }
  143.     }
  144.     return 1;
  145. }
  146.  
  147. stock RemoveNeonFromVehicle(vehicleid)
  148. {
  149.     DestroyObject(NEON_ONE[vehicleid]);
  150.     DestroyObject(NEON_TWO[vehicleid]);
  151.     NEON_ONE[vehicleid] = INVALID_OBJECT_ID;
  152.     NEON_TWO[vehicleid] = INVALID_OBJECT_ID;
  153.     NEON_COR[vehicleid] = "None";
  154.     return 1;
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement