ChainsBoy

Blinkers SA-MP

Jul 8th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.91 KB | None | 0 0
  1. #define INDICATORS_OFF (0) // Defining INDICATORS_OFF to 0. 0 being the player variable value for off however this is more friendly for us to understand.
  2. #define INDICATORS_LEFT (1) // Defining INDICATORS_LEFT to 1. 1 being the player variable value for left however this is more friendly for us to understand.
  3. #define INDICATORS_RIGHT (2) // Defining INDICATORS_RIGHT to 2. 2 being the player variable value for right however this is more friendly for us to understand.
  4.  
  5. new gIndicator1[MAX_PLAYERS][MAX_VEHICLES]; // Global object variable which gets assigned to a player id and vehicle id.
  6. new gIndicator2[MAX_PLAYERS][MAX_VEHICLES]; // Same as above.
  7.  
  8. new Float:IndiPos[][]  = {
  9.  
  10. //Mapped by ChainsBoy aka Lars
  11. // LandStalker 400
  12. { -0.974999, 2.025000, -0.075000, -0.899999, -2.250000, -0.075000, 0.974999, 2.025000, -0.075000, 0.974999, -2.250000, -0.075000 },
  13. // Bravura 401
  14. { -1.049999, 2.475000, 0.000000, -0.974999, -2.325000, 0.000000, 0.974999, 2.400000, 0.000000, 0.974999, -2.250000, 0.000000 },
  15. // Buffalo 402
  16. { -0.899999, 2.400000, -0.075000, -0.899999, -2.475000, 0.000000, 0.824999, -2.550000, -0.000000, 0.824999, 2.550000, -0.075000 },
  17. // Linerunner 403
  18. { -1.049999, 4.425000, -0.824999, -0.300000, -4.050001, -0.749999, 0.974999, 4.500000, -0.824999, 0.374999, -3.975001, -0.749999 },
  19. // Perenail 404
  20. { -0.7270, 2.1308, -0.0489, -0.8383, -2.7254, 0.0729, 0.7395, 2.1308, -0.0489, 0.8287, -2.7254, 0.0729 },
  21. // Sentinel 405
  22. { -0.9022, 2.3059, -0.0527, -0.8636, -2.6895, -0.0367, 0.8987, 2.3059, -0.0527, 0.8437, -2.6895, -0.0367 },
  23. // Dumper 406
  24. { -2.2322, 4.9625, -0.0476, -0.6632, -2.7090, -0.5157, 1.8983, 4.9675, -0.0459, 0.6598, -2.7090, -0.5082},
  25. // Firetruck 407
  26. { -0.7506, 4.1338, 0.0677, -1.0294, -3.4542, 0.0677, 0.7975, 4.1298, 0.0677, 1.0265, -3.4542, 0.0677},
  27. // Trashmaster 408
  28. { -0.9510, 4.8348, -0.1488, -0.8585, -4.0835, -0.4754, 0.9511, 4.8348, -0.1488, 0.8551, -4.0855, -0.4754},
  29. // Stretch 409
  30. { -0.8595, 3.5853, 0.0352, -0.9038, -3.8908, -0.0656, 0.8601, 3.5853, 0.0352, 0.9115, -3.8908, -0.0656},
  31. // Manana 410
  32. { -0.8052, 2.1498, 0.0397, -0.8408, -2.2167, 0.1030, 0.8051, 2.1498, 0.0397, 0.8413, -2.2167, 0.1030},
  33. // Infernus 411
  34. { -0.9298, 2.6942, -0.1782, -0.9247, -2.4527, 0.0607, 0.9309, 2.6942, -0.1985, 0.9044, -2.4547, 0.0607},
  35. // Voodoo 412
  36. { -0.6170, 2.7062, -0.0695, -0.9577, -3.5227, -0.1489, 0.6168, 2.7069, -0.0694, 0.9591, -3.5211, -0.1506},
  37. //Pony 413
  38. { -0.9280, 2.5719, -0.0993, -0.8872, -2.6251, 0.2943, 0.9294, 2.5719, -0.0993, 0.8985, -2.6251, 0.2943}
  39.  
  40. }; // 2 Dimensional array for the object mappings. Goes in this relative order: TOPLEFT, BACKLEFT, TOPRIGHT, BACKRIGHT.
  41.  
  42. public OnPlayerDisconnect(playerid, reason)
  43. {
  44.         DeletePVar(playerid, "IndicatorStatus"); // Removing the variable for that player slot.
  45.         for(new i; i<MAX_VEHICLES; i++) // Looping through the vehicle ids to unassign and destroy the object from that variable.
  46.         {
  47.                 DestroyObject(gIndicator1[playerid][i]);
  48.                 DestroyObject(gIndicator2[playerid][i]);
  49.         }
  50.         return 1;
  51. }
  52.  
  53. public OnPlayerDeath(playerid, killerid, reason)
  54. {
  55.         for(new i; i<MAX_VEHICLES; i++) // Looping through the vehicle ids to unassign and destroy the object from that variable.
  56.         {
  57.                 DestroyObject(gIndicator1[playerid][i]);
  58.                 DestroyObject(gIndicator2[playerid][i]);
  59.         }
  60.         return 1;
  61. }
  62.  
  63. public OnVehicleDeath(vehicleid, killerid)
  64. {      
  65.         for(new i; i<MAX_PLAYERS; i++) // Looping through the player ids to unassign and destroy the object from that variable.
  66.         {
  67.                 DestroyObject(gIndicator1[i][vehicleid]);
  68.                 DestroyObject(gIndicator2[i][vehicleid]);
  69.         }
  70.         return 1;
  71. }
  72.  
  73. public OnPlayerExitVehicle(playerid, vehicleid)
  74. {
  75.         DeletePVar(playerid, "IndicatorStatus"); // Removing the player variable from that id.
  76.         DestroyObject(gIndicator1[playerid][vehicleid]);
  77.         DestroyObject(gIndicator2[playerid][vehicleid]);
  78.         return 1;
  79. }
  80.  
  81. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  82. {
  83.         if(IsPlayerInAnyVehicle(playerid))
  84.         {
  85.                 new iStatus = GetPVarInt(playerid, "IndicatorStatus"); // Getting the player variable and storing it into a local one.
  86.                
  87.                 new vehid = GetPlayerVehicleID(playerid); // Getting the players vehicle id and storing it into a local variable.
  88.                
  89.                 new model = GetVehicleModel(vehid); // Getting the vehicle model and storing it into the model variable.
  90.                
  91.                 new arraynum = CarModelToArray(model); // Getting the array number of the vehicle.
  92.                
  93.                 if(newkeys & KEY_LOOK_LEFT)
  94.                 {
  95.                         if(iStatus == INDICATORS_OFF)
  96.                         {
  97.                                 // Turn indicators left...
  98.                                 SetPVarInt(playerid, "IndicatorStatus", 1); // Setting the variable of indicators left.
  99.                                 gIndicator1[playerid][vehid] = CreateObject(19294,0,0,-1000,0,0,0,100); // Creating the object and assigning it.
  100.                                 gIndicator2[playerid][vehid] = CreateObject(19294,0,0,-1000,0,0,0,100); // Creating the object and assigning it.
  101.                                
  102.                                 AttachObjectToVehicle(gIndicator1[playerid][vehid], GetPlayerVehicleID(playerid), IndiPos[arraynum][0], IndiPos[arraynum][1], IndiPos[arraynum][2], 0.0, 0.0, 0.0); // Attaching it
  103.                                 AttachObjectToVehicle(gIndicator2[playerid][vehid], GetPlayerVehicleID(playerid), IndiPos[arraynum][3], IndiPos[arraynum][4], IndiPos[arraynum][5], 0.0, 0.0, 0.0); // Attaching it
  104.                         }
  105.                         else if(iStatus == INDICATORS_RIGHT)
  106.                         {
  107.                                 // Turn indicators off...
  108.                                 SetPVarInt(playerid, "IndicatorStatus", 0);
  109.                                 DestroyObject(gIndicator1[playerid][vehid]);
  110.                                 DestroyObject(gIndicator2[playerid][vehid]);
  111.                         }
  112.                 }
  113.                 else if(newkeys & KEY_LOOK_RIGHT)
  114.                 {
  115.                         if(iStatus == INDICATORS_OFF)
  116.                         {
  117.                                 // Turn indicators right...
  118.                                 SetPVarInt(playerid, "IndicatorStatus", 2);
  119.                                
  120.                                 gIndicator1[playerid][vehid] = CreateObject(19294,0,0,-1000,0,0,0,100);
  121.                                 gIndicator2[playerid][vehid] = CreateObject(19294,0,0,-1000,0,0,0,100);
  122.                                
  123.                                 AttachObjectToVehicle(gIndicator1[playerid][vehid], GetPlayerVehicleID(playerid), IndiPos[arraynum][6], IndiPos[arraynum][7], IndiPos[arraynum][8], 0.0, 0.0, 0.0);
  124.                                 AttachObjectToVehicle(gIndicator2[playerid][vehid], GetPlayerVehicleID(playerid), IndiPos[arraynum][9], IndiPos[arraynum][10], IndiPos[arraynum][11], 0.0, 0.0, 0.0);
  125.                         }
  126.                         else if(iStatus == INDICATORS_LEFT)
  127.                         {
  128.                                 // Turn indicators off...
  129.                                 SetPVarInt(playerid, "IndicatorStatus", 0); // Setting the variable to 0.
  130.                                 DestroyObject(gIndicator1[playerid][vehid]); // Destroying the object
  131.                                 DestroyObject(gIndicator2[playerid][vehid]); // Destroying the object
  132.                         }
  133.                 }
  134.         }
  135.        
  136.         return 1;
  137. }
  138.  
  139. stock CarModelToArray(modelid) // Getting the array number of the vehicle from the modelid.
  140. {
  141.         new arraynum = modelid - 400; // modelid - 400. 400 being the starting number of the modelid's.
  142.         return arraynum; // Returning the value.
  143. }
Advertisement
Add Comment
Please, Sign In to add comment