Advertisement
Guest User

GetVehicleColor SA-MP

a guest
May 4th, 2015
1,601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. /*
  2. SA-MP "GetVehicleColor 0.3.7" Include by Ryder
  3. Update version by DarkLouis`
  4. */
  5.  
  6. #if defined _Included_GetVehicleColor
  7. #endinput
  8. #endif
  9.  
  10. #define _Included_GetVehicleColor
  11.  
  12. #define PROPERTY_OFFSET(%0) \
  13. ((((%0) * ((%0) << 1)) << 2) + 65536)
  14.  
  15. stock n_AddStaticVehicle(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2)
  16. {
  17. if(color1 < -1 || color2 < -1)
  18. {
  19. color1 = random(255);
  20. color2 = random(255);
  21. }
  22. modelID = AddStaticVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2);
  23.  
  24. new
  25. colorStr[24]
  26. ;
  27. format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  28. setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
  29.  
  30. return modelID;
  31. }
  32.  
  33. stock n_AddStaticVehicleEx(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2, respawn_Delay, sirena = 0)
  34. {
  35. if(color1 < -1 || color2 < -1)
  36. {
  37. color1 = random(255);
  38. color2 = random(255);
  39. }
  40. modelID = AddStaticVehicleEx(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay, sirena);
  41.  
  42. new
  43. colorStr[24]
  44. ;
  45. format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  46. setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
  47.  
  48. return modelID;
  49. }
  50.  
  51. stock n_CreateVehicle(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2, respawn_Delay, sirena = 0)
  52. {
  53. if(color1 < -1 || color2 < -1)
  54. {
  55. color1 = random(255);
  56. color2 = random(255);
  57. }
  58. modelID = CreateVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay, sirena);
  59.  
  60. new
  61. colorStr[24]
  62. ;
  63. format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  64. setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
  65.  
  66. return modelID;
  67. }
  68.  
  69. stock n_DestroyVehicle(vehicleID)
  70. {
  71. deleteproperty(_, "", PROPERTY_OFFSET(vehicleID));
  72.  
  73. return DestroyVehicle(vehicleID);
  74. }
  75.  
  76. stock n_ChangeVehicleColor(vehicleID, color1, color2)
  77. {
  78. new
  79. colorStr[24]
  80. ;
  81. format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  82. setproperty(_, "", PROPERTY_OFFSET(vehicleID), colorStr);
  83.  
  84. return ChangeVehicleColor(vehicleID, color1, color2);
  85. }
  86.  
  87. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  88. {
  89. new
  90. colorStr[24]
  91. ;
  92. format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  93. setproperty(_, "", PROPERTY_OFFSET(vehicleid), colorStr);
  94.  
  95. if(funcidx("n_OnVehicleRespray") != -1)
  96. {
  97. return CallLocalFunction("n_OnVehicleRespray", "iiii", playerid, vehicleid, color1, color2);
  98. }
  99. return 1;
  100. }
  101.  
  102. stock GetVehicleColor(vehicleID, &color1, &color2)
  103. {
  104. vehicleID = PROPERTY_OFFSET(vehicleID);
  105.  
  106. if(existproperty(_, "", vehicleID))
  107. {
  108. new
  109. colorStr[24],
  110. strPos
  111. ;
  112. getproperty(_, "", vehicleID, colorStr);
  113. strunpack(colorStr, colorStr);
  114.  
  115. if((strPos = strfind(colorStr, "-")) != -1)
  116. {
  117. color1 = strval(colorStr);
  118. color2 = strval(colorStr[strPos + 1]);
  119. return 1;
  120. }
  121. }
  122. return 0;
  123. }
  124.  
  125. #if defined _ALS_CreateVehicle
  126. #undef CreateVehicle
  127. #else
  128. #define _ALS_CreateVehicle
  129. #endif
  130.  
  131. #if defined _ALS_AddStaticVehicle
  132. #undef AddStaticVehicle
  133. #else
  134. #define _ALS_AddStaticVehicle
  135. #endif
  136.  
  137. #if defined _ALS_AddStaticVehicleEx
  138. #undef AddStaticVehicleEx
  139. #else
  140. #define _ALS_AddStaticVehicleEx
  141. #endif
  142.  
  143. #if defined _ALS_DestroyVehicle
  144. #undef DestroyVehicle
  145. #else
  146. #define _ALS_DestroyVehicle
  147. #endif
  148.  
  149. #define AddStaticVehicle n_AddStaticVehicle
  150. #define AddStaticVehicleEx n_AddStaticVehicleEx
  151. #define CreateVehicle n_CreateVehicle
  152. #define DestroyVehicle n_DestroyVehicle
  153. #define ChangeVehicleColor n_ChangeVehicleColor
  154.  
  155. #if defined _ALS_OnVehicleRespray
  156. #undef OnVehicleRespray
  157. #else
  158. #define _ALS_OnVehicleRespray
  159. #endif
  160.  
  161. #define OnVehicleRespray n_OnVehicleRespray
  162.  
  163. forward n_OnVehicleRespray(playerid, vehicleid, color1, color2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement