Guest User

Untitled

a guest
Feb 4th, 2011
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.38 KB | None | 0 0
  1. /*
  2.     @Release:   GetVehicleColor
  3.     @Release Type:  Include
  4.     @Author:    RyDeR`
  5.     @Last Update:   04/01/2011 - 19:36
  6.     @Version:   1.2
  7. */
  8.  
  9. #if !defined SetSharingData
  10.     #define SetSharingData(%0,%1) \
  11.         setproperty(0, "", (%0), (%1))
  12. #endif
  13.  
  14. #if !defined GetSharingData
  15.     #define GetSharingData(%0,%1) \
  16.         getproperty(0, "", (%0), (%1))
  17. #endif
  18.  
  19. native _AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2)
  20.  
  21. = AddStaticVehicle;
  22. native _AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1,
  23.  
  24. color2, respawn_delay) = AddStaticVehicleEx;
  25. native _CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2, respawn_delay) =
  26.  
  27. CreateVehicle;
  28. native _DestroyVehicle(vehicleid) = DestroyVehicle;
  29. native _ChangeVehicleColor(vehicleid, color1, color2) = ChangeVehicleColor;
  30.  
  31. #define AddStaticVehicle \
  32.     __AddStaticVehicle
  33.  
  34. #define AddStaticVehicleEx \
  35.     __AddStaticVehicleEx
  36.  
  37. #define CreateVehicle \
  38.     __CreateVehicle
  39.  
  40. #define DestroyVehicle \
  41.     __DestroyVehicle
  42.  
  43. #define ChangeVehicleColor \
  44.     __ChangeVehicleColor
  45.  
  46. stock __AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2)
  47. {
  48.     new
  49.         vehicleID,
  50.         string[24]
  51.     ;
  52.     vehicleID = _AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle,
  53.  
  54. color1, color2);
  55.  
  56.     format(string, sizeof(string), "%d-%d", color1, color2);
  57.     SetSharingData(vehicleID, string);
  58.    
  59.     return vehicleID;
  60. }
  61.  
  62. stock __AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1,
  63.  
  64. color2, respawn_delay)
  65. {
  66.     new
  67.         vehicleID,
  68.         string[24]
  69.     ;
  70.     vehicleID = _AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle,
  71.  
  72. color1, color2, respawn_delay);
  73.  
  74.     format(string, sizeof(string), "%d-%d", color1, color2);
  75.     SetSharingData(vehicleID, string);
  76.  
  77.     return vehicleID;
  78. }
  79.  
  80. stock __CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2, respawn_delay)
  81. {
  82.     new
  83.         vehicleID,
  84.         string[24]
  85.     ;
  86.     vehicleID = _CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2,
  87.  
  88. respawn_delay);
  89.  
  90.     format(string, sizeof(string), "%d-%d", color1, color2);
  91.     SetSharingData(vehicleID, string);
  92.  
  93.     return vehicleID;
  94. }
  95.  
  96. stock __DestroyVehicle(vehicleid)
  97. {
  98.     SetSharingData(vehicleid, "0-0");
  99.     return _DestroyVehicle(vehicleid);
  100. }
  101.  
  102. stock __ChangeVehicleColor(vehicleid, color1, color2)
  103. {
  104.     new
  105.         string[24]
  106.     ;
  107.     format(string, sizeof(string), "%d-%d", color1, color2);
  108.     SetSharingData(vehicleid, string);
  109.    
  110.     return _ChangeVehicleColor(vehicleid, color1, color2);
  111. }
  112.  
  113. stock __OnVehicleRespray(playerid, vehicleid, color1, color2)
  114. {
  115.     #pragma unused \
  116.         playerid
  117.  
  118.     new
  119.         string[24]
  120.     ;
  121.     format(string, sizeof(string), "%d-%d", color1, color2);
  122.     SetSharingData(vehicleid, string);
  123.     return 1;
  124. }
  125.  
  126. stock GetVehicleColor(vehicleid, &color1, &color2)
  127. {
  128.     new
  129.         stringData[24],
  130.         stringColor[2][12],
  131.         i
  132.     ;
  133.     GetSharingData(vehicleid, stringData);
  134.    
  135.     if((i = strfind(stringData, "-", true)) != -1)
  136.     {
  137.         strmid(stringColor[0], stringData, 0, i);
  138.         strmid(stringColor[1], stringData, (i + 1), strlen(stringData));
  139.  
  140.         color1 = strval(stringColor[0]);
  141.         color2 = strval(stringColor[1]);
  142.         return 1;
  143.     }
  144.     return 0;
  145. }
Advertisement
Add Comment
Please, Sign In to add comment