Guest User

Untitled

a guest
Aug 27th, 2021
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. /*
  2. SA-MP "GetVehicleColor v2.1" Include
  3. Copyright © 2011 RyDeR`
  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 < 0 || color2 < 0)
  18. {
  19. color1 = random(127);
  20. color2 = random(127);
  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)
  34. {
  35. if(color1 < 0 || color2 < 0)
  36. {
  37. color1 = random(127);
  38. color2 = random(127);
  39. }
  40. modelID = AddStaticVehicleEx(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay);
  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)
  52. {
  53. if(color1 < 0 || color2 < 0)
  54. {
  55. color1 = random(127);
  56. color2 = random(127);
  57. }
  58. modelID = CreateVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay);
  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. #define AddStaticVehicle n_AddStaticVehicle
  126. #define AddStaticVehicleEx n_AddStaticVehicleEx
  127. #define CreateVehicle n_CreateVehicle
  128. #define DestroyVehicle n_DestroyVehicle
  129. #define ChangeVehicleColor n_ChangeVehicleColor
  130.  
  131. #if defined _ALS_OnVehicleRespray
  132. #undef OnVehicleRespray
  133. #else
  134. #define _ALS_OnVehicleRespray
  135. #endif
  136.  
  137. #define OnVehicleRespray n_OnVehicleRespray
  138.  
  139. forward n_OnVehicleRespray(playerid, vehicleid, color1, color2);
Advertisement
Add Comment
Please, Sign In to add comment