Advertisement
KubiPL

[SA-MP] Vehicle blinks v1.1

Nov 8th, 2014
2,120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 23.16 KB | None | 0 0
  1. /*      =====================================================
  2.         Vehicle blinks (v 1.1) SYSTEM by Kubi (PL).
  3.         Thanks to Patryk for help with half vehicles offsets.
  4.         Created for mrucznik-rp.pl, published on 16.07.2014
  5.         Using one timer (1000ms) for trailer check.
  6.         Lights aren't shows when weather ID is under 2, you
  7.         must know that there is built-in lights object limit
  8.         in the game engine.
  9.     Full info at (http://forum.sa-mp.com/showthread.php?p=3123054)
  10.  
  11.         Please, don't remove credits.
  12.         =====================================================
  13. */
  14.  
  15. #include <a_samp>
  16. #include <streamer>
  17.  
  18. //===========================================================
  19. /*
  20.                             CONFIG
  21. */
  22.  
  23. #define BLINK_DISABLE_ON_EXIT_VEHICLE   1   // 0 - 1 = IF 1, blinks will be disabled when player exits his car with enabled, but still work for emergency blinks.
  24. #define BLINK_ALLOW_EMERGENCY           1   // 0 - 1, allow player to enable emergency lights.
  25. //===========================================================
  26.  
  27. #define PRESSED(%0) \
  28.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  29.  
  30. #define BLINK_TURN_ANGLE 55.0
  31.  
  32. new Blink[MAX_VEHICLES][4];
  33. new BlinkSide[MAX_VEHICLES];
  34. new Float:BlinkR[MAX_VEHICLES];
  35. new BlinkTrailer[MAX_VEHICLES];
  36. new TrailerVehicle[MAX_VEHICLES];
  37.  
  38. forward B_OnTrailerDetached(trailerid, fromvehicleid);
  39. forward B_OnTrailerAttached(trailerid, tovehicleid);
  40. forward B_TrailerCheck();
  41. forward B_DisableBlinks(vehicleid); //For external call in GM when you want to destroy vehicle. CallRemoteFunction("B_DisableBlinks", "i", vehicleid);
  42.  
  43. enum eBO {
  44.     bM, Float:bX, Float:bY, Float:bZ, Float:brX, Float:brY, Float:brZ
  45. };
  46.  
  47. new BlinkOffset[][eBO] = {
  48.     {400, -0.9001, 2.0490, -0.0965, -0.9605, -2.2404, -0.0965},
  49.     {401, -0.9686, 2.5393, 0.0235, -0.9970, -2.2863, 0.0235},
  50.     {402, -0.8788, 2.5160, -0.0565, -0.9208, -2.5936, 0.0435},
  51.     {403, -1.3897, 3.6007, -0.2194, -1.1904, -0.9415, 1.8389},
  52.     {404, -0.7236, 2.1715, -0.0365, -0.7906, -2.7052, 0.0635},
  53.     {405, -0.9127, 2.2766, -0.0565, -0.8723, -2.6526, -0.0565},
  54.     {406, -2.2165, 4.9242, -0.0332, -2.0785, -5.2054, 0.5468},
  55.     {407, -0.9887, 4.0622, -0.0913, -1.0141, -3.4034, -0.0913},
  56.     {408, -0.9659, 4.7615, -0.2513, -0.8430, -3.9722, -0.5113},
  57.     {409, -0.7859, 3.5522, -0.0313, -0.8027, -3.8228, -0.0313},
  58.     {410, -0.825, 2.105, 0.0635, -0.8723, -2.1926, 0.1235},
  59.     {411, -0.9405, 2.6710, -0.1825, -0.9636, -2.4525, 0.0825},
  60.     {412, -0.8965, 2.6478, -0.0575, -0.9592, -3.4870, -0.1575},
  61.     {413, -0.8669, 2.5464, -0.0913, -0.8209, -2.5829, 0.0687},
  62.     {414, -0.8069, 2.7473, 0.0087, -0.9058, -3.2050, 0.1094},
  63.     {415, -0.8738, 2.4866, -0.2357, -0.7792, -2.3501, 0.0450},
  64.     {416, -0.8469, 2.9073, 0.0087, -1.0352, -3.5937, 1.4522},
  65.     {417, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  66.     {418, -0.9511, 2.3820, -0.2357, -1.0081, -2.4904, -0.1557},
  67.     {419, -1.0742, 2.3978, -0.1757, -0.8127, -2.8620, -0.1557},
  68.     {420, -1.0142, 2.2978, -0.0157, -0.9637, -2.6744, 0.0043},
  69.     {421, -0.9013, 2.5343, -0.1357, -0.5921, -2.9228, -0.1957},
  70.     {422, -0.7813, 2.1543, -0.2657, -0.8985, -2.4349, -0.1057},
  71.     {423, -0.7817, 2.2093, -0.0313, -0.8340, -2.1794, 0.0596},
  72.     {424, -0.7350, 1.4505, 0.1087, -0.7062, -1.4778, 0.2996},
  73.     {425, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  74.     {426, -1.0006, 2.3164, -0.0100, -0.9627, -2.6930, -0.0100},
  75.     {427, -0.8728, 2.5856, 0.1887, -0.9831, -3.8383, -0.3495},
  76.     {428, -0.8728, 2.5856, -0.2103, -0.9045, -2.8871, 1.2466},
  77.     {429, -0.7942, 2.2846, -0.2500, -0.8397, -2.3849, -0.0070},
  78.     {430, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  79.     {431, -0.9771, 5.8479, 0.3497, -1.0300, -5.7043, -0.1041},
  80.     {432, -1.7168, 4.0330, 0.4497, -1.5830, -4.3414, 0.7039},
  81.     {433, -1.2619, 3.7708, -0.2163, -1.2966, -4.6534, -0.1051},
  82.     {434, 0.0, 0.0, 0.0, -0.4811, -1.9838, -0.0670},
  83.     {435, 0.0000, 0.0000, 0.0000, -1.0697, -3.9690, -1.1053}, //trailer
  84.     {436, -0.8495, 2.2519, -0.0070, -0.8948, -2.4838, 0.1130},
  85.     {437, -1.1156, 5.5395, -0.2163, -0.9856, -5.3099, 1.6458},
  86.     {438, -1.1128, 2.3675, -0.2870, -1.0992, -2.4601, -0.2870},
  87.     {439, -0.8381, 2.3101, -0.1470, -0.8221, -2.6534, -0.1070},
  88.     {440, -0.8270, 2.5573, -0.3173, -0.8676, -2.5376, -0.0149},
  89.     {441, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  90.     {442, -1.0354, 2.8278, -0.1870, -1.0226, -3.0877, -0.1270},
  91.     {443, -1.0610, 5.7528, -0.9573, -1.2388, -7.1392, -0.8250},
  92.     {444, -0.9880, 2.7188, 0.6140, -1.0722, -3.0184, 0.7248},
  93.     {445, -0.9590, 2.3460, -0.0840, -0.9773, -2.8049, -0.0840},
  94.     {446, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  95.     {447, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  96.     {448,  -0.1992, -0.9229, -0.1270},
  97.     {449, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  98.     {450,  0.0000, 0.0000, 0.0000, -1.0697, -3.9690, -1.1053}, //trailer
  99.     {451, -0.9826, 1.9642, -0.1399, -0.8894, -2.3991, -0.0199},
  100.     {452, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  101.     {453, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  102.     {454, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  103.     {455, 0.0000, 0.0000, 0.0000, -1.3866, -4.5162, -0.7399},
  104.     {456, 0.0000, 0.0000, 0.0000, -1.3045, -4.6123, 0.4601},
  105.     {457, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  106.     {458, -0.9513, 2.4197, -0.1399, -0.9703, -2.7779, 0.0201},
  107.     {459, -0.8214, 2.5716, -0.1274, -0.8760, -2.5775, 0.1127},
  108.     {460, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  109.     {461, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  110.     {462, 0.0000, 0.0000, 0.0000, -0.2054, -0.9359, -0.1399},
  111.     {463, -0.2276, 0.7185, 0.3201, -0.1952, -1.0037, 0.1601},
  112.     {464, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  113.     {465, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  114.     {466, 0.0000, 0.0000, 0.0000, -1.0201, -2.7994, 0.0401},
  115.     {467, 0.0000, 0.0000, 0.0000, -0.9401, -3.0594, 0.1601},
  116.     {468, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  117.     {469, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  118.     {470, -1.0259, 2.1382, 0.2001, -1.0433, -2.5463, 0.1201},
  119.     {471, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  120.     {472, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  121.     {473, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  122.     {474, 0.0000, 0.0000, 0.0000, -0.9833, -2.7663, -0.0599},
  123.     {475, -0.8681, 2.4086, -0.3399, -0.8632, -2.7629, -0.2399},
  124.     {476, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  125.     {477, -0.8081, 2.6686, -0.1999, -0.9945, -2.6987, 0.0801},
  126.     {478, -1.0938, 2.0255, 0.1001, -1.0579, -2.5378, -0.2799},
  127.     {479, -0.9671, 2.4844, 0.0201, -0.9578, -2.7556, 0.0601},
  128.     {480, -0.5897, 2.2607, -0.4399, -0.9183, -2.3388, -0.1399},
  129.     {481, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  130.     {482, -0.8841, 2.4094, -0.3399, -0.8685, -2.5676, 0.0201},
  131.     {483, -0.7770, 2.6235, -0.0199, -0.6709, -2.7712, -0.1999},
  132.     {484,  0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  133.     {485, -0.6104, 1.7180, 0.2201, -0.7074, -1.3681, 0.1201},
  134.     {486, 0.0000, 0.0000, 0.0000, -0.5919, -3.2353, 0.9601},
  135.     {487, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  136.     {488, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  137.     {489, -1.1024, 2.5796, 0.0401, -1.1261, -2.6473, 0.1601},
  138.     {490, -1.0971, 3.1462, 0.0401, -1.1327, -3.1055, 0.1601},
  139.     {491, -0.8495, 2.5284, -0.0799, -0.8870, -2.7776, 0.0001},
  140.     {492, -0.7905, 2.4656, -0.0599, -0.9075, -2.8130, 0.0001},
  141.     {493, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  142.     {494, -0.8513, 2.3630, -0.2199, -0.8275, -2.8485, 0.1401},
  143.     {495, -1.0909, 2.3818, 0.0001, -1.1540, -2.1156, -0.0399},
  144.     {496, -0.9219, 2.1787, 0.0401, -0.7095, -2.1087, 0.0801},
  145.     {497, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000},
  146.     {498, -0.8915, 3.0670, 0.2201, -0.9740, -3.0460, 0.3601},
  147.     {499, -0.7725, 2.4576, -0.1999, -1.1318, -3.4186, 0.1401},
  148.     {500, -0.9152, 1.9097, -0.0355, -0.7552, -1.9266, -0.0355},
  149.     {501, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  150.     {502, -0.8723, 2.5986, -0.1770, 0.0, 0.0, 0.0},
  151.     {503, -0.8579, 2.3582, -0.0213, 0.0, 0.0, 0.0},
  152.     {504, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  153.     {505, -1.1068, 2.5744, 0.0086, -1.1365, -2.6250, 0.1679},
  154.     {506, -0.7672, 2.2106, -0.3185, -0.9113, -2.3474, -0.0273},
  155.     {507, -1.1143, 2.6057, -0.0456, -1.1410, -2.9714, -0.0456},
  156.     {508, -0.7012, 3.0199, -0.6678, -1.3807, -3.3356, 1.2628},
  157.     {509, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  158.     {510, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  159.     {511, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  160.     {512, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  161.     {513, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  162.     {514, -1.2341, 4.2204, 0.0806, 0.0, 0.0, 0.0},
  163.     {515, -1.4241, 4.4811, -0.7354, -1.2973, -4.8274, -0.8974},
  164.     {516, -0.9512, 2.7208, -0.0543, -0.9926, -2.7809, -0.0348},
  165.     {517, -0.9401, 2.7868, -0.0726, -1.0208, -2.7461, -0.1324},
  166.     {518, -0.9166, 2.6548, -0.0487, -1.0124, -2.8219, -0.0487}, //fake
  167.     {519, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  168.     {520, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  169.     {521, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  170.     {522, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  171.     {523, -0.2607, 0.6038, 0.2881, -0.1973, -0.9958, 0.0638},
  172.     {524, -0.9279, 3.6538, -0.0473, -1.3003, -3.9309, -1.0661}, //fake back
  173.     {525, -0.8576, 2.9431, 0.1425, -1.0428, -2.9851, -0.1486}, //fake back
  174.     {526, -0.9421, 2.3087, -0.1128, -0.9559, -2.2882, -0.0411},
  175.     {527, -0.9351, 2.4078, -0.0242, -0.9825, -2.2344, 0.0844},
  176.     {528, -0.8783, 2.5102, -0.1526, -0.8133, -2.5965, -0.3237}, //fake back
  177.     {529, -1.0177, 2.5256, 0.0698, -1.0505, -2.5713, 0.2047},
  178.     {530, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  179.     {531, -0.4216, 1.5030, -0.1191, -0.5225, -1.0517, 0.4484}, //fake
  180.     {532, -4.0331, 3.9619, -0.9118, -1.5976, -0.3739, 0.4484}, //fake!
  181.     {533, -0.9410, 2.3774, 0.0985, -0.9852, -2.4663, -0.0020},
  182.     {534, -1.0159, 2.9278, -0.1698, -0.8236, -2.7548, -0.0574},
  183.     {535, -0.8265, 2.5014, -0.2084, -0.9267, -2.6058, -0.1784},
  184.     {536, -0.8577, 2.3943, -0.1248, -0.8736, -3.0999, -0.0900},
  185.     {537, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  186.     {538, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  187.     {539, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  188.     {540, -0.9827, 2.5810, -0.1248, -1.0597, -2.7121, -0.0842},
  189.     {541, -0.6055, 2.3378, -0.2108, -0.7826, -2.1992, 0.0913},
  190.     {542, -0.9712, 2.6252, -0.0064, -0.8281, -2.9729, -0.0577},
  191.     {543, -0.8414, 2.2904, 0.0719, -0.9831, -2.6214, -0.0116}, //fake front
  192.     {544, -0.7346, 3.5720, 0.0200, -0.8597, -3.2242, -0.5918},
  193.     {545, -0.4372, 1.6776, -0.0400, -0.7955, -2.0453, -0.2888},
  194.     {546, -1.1294, 1.0702, 0.0719, -1.0580, -2.6948, 0.0719},
  195.     {547, -0.9582, 2.5222, 0.0271, -0.9937, -2.5915, 0.0719},
  196.     {548, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  197.     {549, -0.9264, 2.4914, 0.0271, -0.9070, -2.5802, 0.0271},
  198.     {550, -1.0477, 2.5642, -0.1807, -1.0302, -2.6549, -0.1297},
  199.     {551, -0.9334, 2.6344, -0.0448, -0.9785, -3.0524, 0.0366},
  200.     {552, -0.8757, 3.0634, 0.3600, -0.9933, -2.9119, 0.4752},
  201.     {553, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  202.     {554, -0.9409, 2.5345, 0.0600, -1.1112, -2.8095, 0.0651},
  203.     {555, -0.9236, 1.1282, -0.0462, 0.0, 0.0, 0.0},
  204.     {556, -0.9686, 2.5396, 0.5800, -1.1128, -2.8895, 0.7691},
  205.     {557, -0.9886, 2.4796, 0.7000, -1.0904, -2.7699, 0.6871},
  206.     {558, -0.9452, 2.0854, 0.0836, -0.9187, -2.4047, 0.3185},
  207.     {559, -0.9037, 2.4333, -0.0168, -0.8819, -2.2910, 0.1482},
  208.     {560, -0.9347, 2.5097, -0.2644, -0.9639, -2.2337, 0.1259},
  209.     {561, -0.9157, 2.5754, -0.0857, -0.9317, -2.5444, -0.0191},
  210.     {562, -0.9299, 2.3759, 0.0201, -0.8575, -2.2773, 0.1659},
  211.     {563, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  212.     {564, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  213.     {565, -0.8503, 2.0545, 0.0346, -0.9249, -1.9224, 0.0816},
  214.     {566, -0.9539, 2.7226, 0.0346, -0.9506, -2.9199, 0.0346},
  215.     {567, -0.9942, 2.9212, -0.1543, -1.0077, -2.9164, -0.1543},
  216.     {568, -0.2962, 2.0729, -0.0171, -0.2384, -1.2180, 0.0720},
  217.     {569, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  218.     {570, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  219.     {571, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  220.     {572, -0.3095, 0.7291, -0.0971, -0.4318, -0.8940, -0.0510},
  221.     {573, -0.7949, 3.0624, -0.3371, -0.8727, -3.0917, -0.4540},
  222.     {574, -0.4348, 1.6912, -0.2171, -0.4277, -1.1358, -0.2069},
  223.     {575, -0.9483, 2.3252, 0.1334, -0.9173, -2.7359, -0.0291},
  224.     {576, -0.9948, 2.4505, 0.1883, -0.9983, -3.1357, -0.0291},
  225.     {577, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  226.     {578, -1.0478, 4.3687, -0.1800, -1.1188, -5.3472, -0.5099},
  227.     {579, -1.0598, 2.3634, 0.1013, -1.0873, -2.7596, 0.1013},
  228.     {580, -0.7970, 2.6313, -0.2429, -1.0776, -2.8302, 0.1013},
  229.     {581, 0.0, 0.0, 0.0, -0.1975, -1.0375, 0.3448},
  230.     {582, -0.8583, 2.4404, -0.0571, -0.9214, -3.3625, 0.0521},
  231.     {583, -0.5225, 1.3799, 0.2429, -0.5486, -1.5684, 0.2462},
  232.     {584, 0.0, 0.0, 0.0, -1.0452, -4.3338, -0.7298}, //trailer
  233.     {585, -1.0068, 2.7905, 0.0907, -0.9760, -3.0160, 0.2088},
  234.     {586, -0.2872, 0.5383, 0.2009, -0.1703, -1.3533, 0.2784},
  235.     {587, -1.0236, 2.1415, -0.2834, -1.0832, -2.4851, 0.1047},
  236.     {588, -1.0116, 3.3590, 0.1029, -1.0679, -3.9639, -0.3029},
  237.     {589, -0.8107, 2.3905, 0.1834, -0.9605, -2.2799, 0.3761},
  238.     {590, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  239.     {591, 0.0, 0.0, 0.0, -1.0590, -3.9902, -1.0809}, //trailer
  240.     {592, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  241.     {593, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  242.     {594, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  243.     {595, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  244.     {596, -1.0419, 2.2929, -0.0255, -1.0332, -2.6951, 0.0005},
  245.     {597, -1.0419, 2.2929, -0.0255, -1.0332, -2.6951, 0.0005},
  246.     {598, -1.0423, 2.3495, 0.0600, -1.0326, -2.6930, 0.0600},
  247.     {599, -1.0837, 2.5663, 0.0301, -1.1267, -2.6290, 0.1451},
  248.     {600, -0.8782, 2.6525, -0.0344, -1.0586, -2.6696, 0.0596},
  249.     {601, -0.8094, 3.0084, 0.5429, -0.9321, -3.0808, 0.9071},
  250.     {602, -1.0297, 2.0487, -0.0543, -0.8907, -2.5334, -0.3228},
  251.     {603, -0.9069, 2.6672, -0.1335, -0.8647, -2.5991, -0.1335},
  252.     {604, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  253.     {605, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  254.     {606, 0.0, 0.0, 0.0, -0.5702, -1.5842, 0.7956}, //trailer
  255.     {607, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  256.     {608, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  257.     {609, -0.8972, 3.0244, 0.2629, -0.9349, -2.9809, 0.2791},
  258.     {610, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
  259.     {611, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
  260.     //END GTA CARS
  261. };
  262.  
  263. public OnFilterScriptInit() {
  264.     for(new i=0;i<MAX_VEHICLES;i++)
  265.     {
  266.         Blink[i][0] = -1;
  267.         Blink[i][1] = -1;
  268.         Blink[i][2] = -1;
  269.         Blink[i][3] = -1;
  270.     }
  271.     SetTimer("B_TrailerCheck", 1000, 1);
  272.     print("VEHICLE BLINK SYSTEM - loaded");
  273.     print("This server is using - Vehicle blink system by Kubi -");
  274.     return 1;
  275. }
  276.  
  277. public OnFilterScriptExit() {
  278.     for(new i=0;i<MAX_VEHICLES;i++) DisableCarBlinking(i);
  279.     print("VEHICLE BLINK SYSTEM - unloaded");
  280.     return 1;
  281. }
  282.  
  283. public OnPlayerConnect(playerid)
  284. {
  285.     return 1;
  286. }
  287.  
  288. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  289. {
  290.     new veh = GetPlayerVehicleID(playerid);
  291.     if(veh != 0)
  292.     {
  293.         if(GetPlayerVehicleSeat(playerid) == 0)
  294.         {
  295.             #if BLINK_ALLOW_EMERGENCY == 1
  296.             if(PRESSED(KEY_LOOK_BEHIND))
  297.             {
  298.                 if(!IsCarBlinking(veh)) SetCarBlinking(veh, 2), SetPVarInt(playerid, "blink-car", veh);
  299.                 else DisableCarBlinking(veh);
  300.             }
  301.             #endif
  302.             if(PRESSED(KEY_LOOK_LEFT))
  303.             {
  304.                 if(!IsCarBlinking(veh)) SetCarBlinking(veh, 0), SetPVarInt(playerid, "blink-car", veh);
  305.                 else DisableCarBlinking(veh);
  306.             }
  307.             else if(PRESSED(KEY_LOOK_RIGHT))
  308.             {
  309.                 if(!IsCarBlinking(veh)) SetCarBlinking(veh, 1), SetPVarInt(playerid, "blink-car", veh);
  310.                 else DisableCarBlinking(veh);
  311.             }
  312.  
  313.             if(IsCarBlinking(veh))
  314.             {
  315.                 new Float:a, Float:b = BlinkR[veh];
  316.                 GetVehicleZAngle(veh, a);
  317.  
  318.                 if(BlinkSide[veh] == 0)
  319.                 {
  320.                     b+=BLINK_TURN_ANGLE;
  321.                     if(b > 360.0) b -=360.0;
  322.                     if(a < b-180) a = a+360;
  323.                     if(b < a-180) b = b+360;
  324.  
  325.                     if(a > b) DisableCarBlinking(veh);
  326.                 }
  327.                 else if(BlinkSide[veh] == 1)
  328.                 {
  329.                     b-=BLINK_TURN_ANGLE;
  330.                     if(b < 0.0) b = 360.0 + b;
  331.                     if(a < b-180) a = a+360;
  332.                     if(b < a-180) b = b+360;
  333.  
  334.                     if(a < b) DisableCarBlinking(veh);
  335.                 }
  336.             }
  337.         }
  338.     }
  339.     return 1;
  340. }
  341.  
  342. public OnPlayerStateChange(playerid, newstate, oldstate)
  343. {
  344.     if(oldstate == PLAYER_STATE_DRIVER)
  345.     {
  346.         #if BLINK_DISABLE_ON_EXIT_VEHICLE == 0
  347.         return 1;
  348.         #else
  349.         if(BlinkSide[GetPVarInt(playerid, "blink-car")] != 2) DisableCarBlinking(GetPVarInt(playerid, "blink-car"));
  350.         #endif
  351.     }
  352.     return 1;
  353. }
  354.  
  355. public OnVehicleSpawn(vehicleid)
  356. {
  357.     if(B_IsTrailer(vehicleid))
  358.     {
  359.         new veh;
  360.         if((veh = TrailerVehicle[vehicleid]) != 0)
  361.         {
  362.             if(IsCarBlinking(veh))
  363.             {
  364.                 DestroyDynamicObject(Blink[veh][1]);
  365.                 DestroyDynamicObject(Blink[veh][3]);
  366.                 Blink[veh][1] = -1;
  367.                 Blink[veh][3] = -1;
  368.             }
  369.         }
  370.     }
  371.     else DisableCarBlinking(vehicleid);
  372.     return 1;
  373. }
  374.  
  375. public OnVehicleDeath(vehicleid, killerid)
  376. {
  377.     if(B_IsTrailer(vehicleid))
  378.     {
  379.         new veh;
  380.         if((veh = TrailerVehicle[vehicleid]) != 0)
  381.         {
  382.             if(IsCarBlinking(veh))
  383.             {
  384.                 DestroyDynamicObject(Blink[veh][1]);
  385.                 DestroyDynamicObject(Blink[veh][3]);
  386.                 Blink[veh][1] = -1;
  387.                 Blink[veh][3] = -1;
  388.             }
  389.         }
  390.     }
  391.     else DisableCarBlinking(vehicleid);
  392.     return 1;
  393. }
  394.  
  395. stock SetCarBlinking(veh, side, bool:skip=false) //0 - left 1 - right 2 - emergy
  396. {
  397.     if(IsCarBlinking(veh) && !skip) return DisableCarBlinking(veh);
  398.     new model=GetVehicleModel(veh),obj[4];
  399.     new id = model-400, trailer;
  400.  
  401.     if(!skip) BlinkSide[veh] = side;
  402.  
  403.     GetVehicleZAngle(veh, BlinkR[veh]);
  404.  
  405.     if(id > -1)
  406.     {
  407.         if(BlinkOffset[id][bX] != 0.0)
  408.         {
  409.             if(side == 0)
  410.             {
  411.                 obj[0] = CreateDynamicObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); //blink yellow  front
  412.                 Blink[veh][0] = obj[0];
  413.             }
  414.             else
  415.             {
  416.                 obj[2] = CreateDynamicObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  417.                 Blink[veh][2] = obj[2];
  418.             }
  419.         }
  420.         if((trailer = GetVehicleTrailer(veh)) != 0)
  421.         {
  422.             if(B_IsTrailer(trailer))
  423.             {
  424.                 if(side == 0)
  425.                 {
  426.                     obj[1] = CreateDynamicObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); //blink yellow back truck only trailer
  427.                     Blink[veh][1] = obj[1];
  428.                 }
  429.                 else
  430.                 {
  431.                     obj[3] = CreateDynamicObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  432.                     Blink[veh][3] = obj[3];
  433.                 }
  434.             }
  435.         }
  436.         else
  437.         {
  438.             if(BlinkOffset[id][brX] != 0.0)
  439.             {
  440.                 if(side == 0)
  441.                 {
  442.                     obj[1] = CreateDynamicObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); //blink yellow back truck only trailer
  443.                     Blink[veh][1] = obj[1];
  444.                 }
  445.                 else
  446.                 {
  447.                     obj[3] = CreateDynamicObject(19294, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  448.                     Blink[veh][3] = obj[3];
  449.                 }
  450.             }
  451.         }
  452.  
  453.         if(side == 0) //left
  454.         {
  455.             if(obj[0] != 0) AttachDynamicObjectToVehicle(obj[0], veh, BlinkOffset[id][bX],BlinkOffset[id][bY],BlinkOffset[id][bZ], 0.0, 0.0, 0.0);
  456.             if(trailer != 0)
  457.             {
  458.                 id = GetVehicleModel(trailer)-400;
  459.                 AttachDynamicObjectToVehicle(obj[1], trailer, BlinkOffset[id][brX],BlinkOffset[id][brY],BlinkOffset[id][brZ], 0.0, 0.0, 0.0);
  460.             }
  461.             else
  462.             {
  463.                 if(obj[1] != 0) AttachDynamicObjectToVehicle(obj[1], veh, BlinkOffset[id][brX],BlinkOffset[id][brY],BlinkOffset[id][brZ], 0.0, 0.0, 0.0);
  464.             }
  465.         }
  466.         else if(side == 1) //right
  467.         {
  468.             if(obj[2] != 0) AttachDynamicObjectToVehicle(obj[2], veh, -BlinkOffset[id][bX],BlinkOffset[id][bY],BlinkOffset[id][bZ], 0.0, 0.0, 0.0);
  469.             if(trailer != 0)
  470.             {
  471.                 id = GetVehicleModel(trailer)-400;
  472.                 AttachDynamicObjectToVehicle(obj[3], trailer, -BlinkOffset[id][brX],BlinkOffset[id][brY],BlinkOffset[id][brZ], 0.0, 0.0, 0.0);
  473.             }
  474.             else
  475.             {
  476.                 if(obj[3] != 0) AttachDynamicObjectToVehicle(obj[3], veh, -BlinkOffset[id][brX],BlinkOffset[id][brY],BlinkOffset[id][brZ], 0.0, 0.0, 0.0);
  477.             }
  478.         }
  479.         else if(side == 2)  //emergency
  480.         {
  481.             SetCarBlinking(veh, 0, true);
  482.             SetCarBlinking(veh, 1, true);
  483.         }
  484.     }
  485.     return 1;
  486. }
  487.  
  488. public B_DisableBlinks(vehicleid)
  489. {
  490.     for(new i=0;i<4;i++)
  491.     {
  492.         if(Blink[vehicleid][i] != -1) DestroyDynamicObject(Blink[vehicleid][i]);
  493.         Blink[vehicleid][i] = -1;
  494.     }
  495.     return 1;
  496. }
  497.  
  498. stock DisableCarBlinking(veh)
  499. {
  500.     if(!IsCarBlinking(veh)) return 1;
  501.     B_DisableBlinks(veh);
  502.     return 1;
  503. }
  504.  
  505. stock IsCarBlinking(vehicleid)
  506. {
  507.     if((BlinkSide[vehicleid] == 0 && Blink[vehicleid][0] == -1 && Blink[vehicleid][1] == -1) || (BlinkSide[vehicleid] == 1 && Blink[vehicleid][2] == -1 && Blink[vehicleid][3] == -1)) return 0;
  508.     else if(Blink[vehicleid][0] == -1 && Blink[vehicleid][1] == -1 && Blink[vehicleid][2] == -1 && Blink[vehicleid][3] == -1) return 0;
  509.     return 1;
  510. }
  511.  
  512. stock B_IsTrailer(vehicleid)
  513. {
  514.     switch(GetVehicleModel(vehicleid))
  515.     {
  516.         case 435, 450, 584, 591, 606: return 1;
  517.     }
  518.     return 0;
  519. }
  520.  
  521. public B_OnTrailerDetached(trailerid, fromvehicleid)
  522. {
  523.     if(IsCarBlinking(fromvehicleid))
  524.     {
  525.         DisableCarBlinking(fromvehicleid);
  526.         SetCarBlinking(fromvehicleid, BlinkSide[fromvehicleid]);
  527.     }
  528.     TrailerVehicle[trailerid] = 0;
  529. }
  530.  
  531. public B_OnTrailerAttached(trailerid, tovehicleid)
  532. {
  533.     if(IsCarBlinking(tovehicleid))
  534.     {
  535.         DisableCarBlinking(tovehicleid);
  536.         SetCarBlinking(tovehicleid, BlinkSide[tovehicleid]);
  537.     }
  538.     TrailerVehicle[trailerid] = tovehicleid;
  539. }
  540.  
  541. public B_TrailerCheck()
  542. {
  543.     new trailer;
  544.     for(new i=0;i<MAX_VEHICLES;i++)
  545.     {
  546.         if((trailer = GetVehicleTrailer(i)) != 0)
  547.         {
  548.             if(BlinkTrailer[i] == 0)
  549.             {
  550.                 BlinkTrailer[i]=trailer;
  551.                 B_OnTrailerAttached(trailer, i);
  552.             }
  553.         }
  554.         else if(BlinkTrailer[i] != 0)
  555.         {
  556.             B_OnTrailerDetached(BlinkTrailer[i], i);
  557.             BlinkTrailer[i] = 0;
  558.         }
  559.     }
  560. }
  561.  
  562. public OnPlayerEditObject( playerid, playerobject, objectid, response,Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ )
  563. {
  564.     return 1;
  565. }
  566.  
  567. public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
  568. {
  569.  
  570. }
  571.  
  572. //END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement