Guest User

www.pro-pawn.ru

a guest
Mar 5th, 2014
651
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     SA-MP "GetVehicleColor v2.1" Include
  3.     Copyright © 2011 RyDeR`
  4. */
  5. //www.pro-pawn.ru
  6. //кто слил на другой портал,тот сосал у бабуина
  7. #if defined _Included_GetVehicleColor
  8.     #endinput
  9. #endif
  10.  
  11. #define _Included_GetVehicleColor
  12.  
  13. #define PROPERTY_OFFSET(%0) \
  14.     ((((%0) * ((%0) << 1)) << 2) + 65536)
  15.  
  16. stock n_AddStaticVehicle(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2)
  17. {
  18.     if(color1 < 0 || color2 < 0)
  19.     {
  20.         color1 = random(127);
  21.         color2 = random(127);
  22.     }
  23.     modelID = AddStaticVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2);
  24.    
  25.     new
  26.         colorStr[24]
  27.     ;  
  28.     format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  29.     setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
  30.    
  31.     return modelID;
  32. }
  33.  
  34. stock n_AddStaticVehicleEx(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2, respawn_Delay)
  35. {
  36.     if(color1 < 0 || color2 < 0)
  37.     {
  38.         color1 = random(127);
  39.         color2 = random(127);
  40.     }
  41.     modelID = AddStaticVehicleEx(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay);
  42.    
  43.     new
  44.         colorStr[24]
  45.     ;  
  46.     format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  47.     setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
  48.    
  49.     return modelID;
  50. }
  51.  
  52. stock n_CreateVehicle(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2, respawn_Delay)
  53. {
  54.     if(color1 < 0 || color2 < 0)
  55.     {
  56.         color1 = random(127);
  57.         color2 = random(127);
  58.     }
  59.     modelID = CreateVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay);
  60.    
  61.     new
  62.         colorStr[24]
  63.     ;  
  64.     format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  65.     setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
  66.    
  67.     return modelID;
  68. }
  69.  
  70. stock n_DestroyVehicle(vehicleID)
  71. {
  72.     deleteproperty(_, "", PROPERTY_OFFSET(vehicleID));
  73.    
  74.     return DestroyVehicle(vehicleID);
  75. }
  76.  
  77. stock n_ChangeVehicleColor(vehicleID, color1, color2)
  78. {
  79.     new
  80.         colorStr[24]
  81.     ;  
  82.     format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  83.     setproperty(_, "", PROPERTY_OFFSET(vehicleID), colorStr);
  84.    
  85.     return ChangeVehicleColor(vehicleID, color1, color2);
  86. }
  87.  
  88. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  89. {
  90.     new
  91.         colorStr[24]
  92.     ;  
  93.     format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
  94.     setproperty(_, "", PROPERTY_OFFSET(vehicleid), colorStr);
  95.    
  96.     if(funcidx("n_OnVehicleRespray") != -1)
  97.     {
  98.         return CallLocalFunction("n_OnVehicleRespray", "iiii", playerid, vehicleid, color1, color2);
  99.     }
  100.     return 1;
  101. }
  102.  
  103. stock GetVehicleColor(vehicleID, &color1, &color2)
  104. {
  105.     vehicleID = PROPERTY_OFFSET(vehicleID);
  106.    
  107.     if(existproperty(_, "", vehicleID))
  108.     {
  109.         new
  110.             colorStr[24],
  111.             strPos
  112.         ;
  113.         getproperty(_, "", vehicleID, colorStr);
  114.         strunpack(colorStr, colorStr);
  115.        
  116.         if((strPos = strfind(colorStr, "-")) != -1)
  117.         {
  118.             color1 = strval(colorStr);
  119.             color2 = strval(colorStr[strPos + 1]);
  120.             return 1;
  121.         }
  122.     }
  123.     return 0;
  124. }
  125.  
  126. #define AddStaticVehicle n_AddStaticVehicle
  127. #define AddStaticVehicleEx n_AddStaticVehicleEx
  128. #define CreateVehicle n_CreateVehicle
  129. #define DestroyVehicle n_DestroyVehicle
  130. #define ChangeVehicleColor n_ChangeVehicleColor
  131.  
  132. #if defined _ALS_OnVehicleRespray
  133.     #undef OnVehicleRespray
  134. #else
  135.     #define _ALS_OnVehicleRespray
  136. #endif
  137.  
  138. #define OnVehicleRespray n_OnVehicleRespray
  139.  
  140. forward n_OnVehicleRespray(playerid, vehicleid, color1, color2);
RAW Paste Data Copied