GetVehicleColor.inc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. #if !defined SetSharingData
  9. #define SetSharingData(%0,%1) \
  10. setproperty(0, "", (%0), (%1))
  11. #endif
  12. #if !defined GetSharingData
  13. #define GetSharingData(%0,%1) \
  14. getproperty(0, "", (%0), (%1))
  15. #endif
  16. native _AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2)
  17. = AddStaticVehicle;
  18. native _AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1,
  19. color2, respawn_delay) = AddStaticVehicleEx;
  20. native _CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2, respawn_delay) =
  21. CreateVehicle;
  22. native _DestroyVehicle(vehicleid) = DestroyVehicle;
  23. native _ChangeVehicleColor(vehicleid, color1, color2) = ChangeVehicleColor;
  24. #define AddStaticVehicle \
  25. __AddStaticVehicle
  26. #define AddStaticVehicleEx \
  27. __AddStaticVehicleEx
  28. #define CreateVehicle \
  29. __CreateVehicle
  30. #define DestroyVehicle \
  31. __DestroyVehicle
  32. #define ChangeVehicleColor \
  33. __ChangeVehicleColor
  34. stock __AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1, color2)
  35. {
  36. new
  37. vehicleID,
  38. string[24]
  39. ;
  40. vehicleID = _AddStaticVehicle(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle,
  41. color1, color2);
  42. format(string, sizeof(string), "%d-%d", color1, color2);
  43. SetSharingData(vehicleID, string);
  44. return vehicleID;
  45. }
  46. stock __AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle, color1,
  47. color2, respawn_delay)
  48. {
  49. new
  50. vehicleID,
  51. string[24]
  52. ;
  53. vehicleID = _AddStaticVehicleEx(modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: z_angle,
  54. color1, color2, respawn_delay);
  55. format(string, sizeof(string), "%d-%d", color1, color2);
  56. SetSharingData(vehicleID, string);
  57. return vehicleID;
  58. }
  59. stock __CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2, respawn_delay)
  60. {
  61. new
  62. vehicleID,
  63. string[24]
  64. ;
  65. vehicleID = _CreateVehicle(vehicletype, Float: x, Float: y, Float: z, Float: rotation, color1, color2,
  66. respawn_delay);
  67. format(string, sizeof(string), "%d-%d", color1, color2);
  68. SetSharingData(vehicleID, string);
  69. return vehicleID;
  70. }
  71. stock __DestroyVehicle(vehicleid)
  72. {
  73. SetSharingData(vehicleid, "0-0");
  74. return _DestroyVehicle(vehicleid);
  75. }
  76. stock __ChangeVehicleColor(vehicleid, color1, color2)
  77. {
  78. new
  79. string[24]
  80. ;
  81. format(string, sizeof(string), "%d-%d", color1, color2);
  82. SetSharingData(vehicleid, string);
  83. return _ChangeVehicleColor(vehicleid, color1, color2);
  84. }
  85. stock __OnVehicleRespray(playerid, vehicleid, color1, color2)
  86. {
  87. #pragma unused \
  88. playerid
  89. new
  90. string[24]
  91. ;
  92. format(string, sizeof(string), "%d-%d", color1, color2);
  93. SetSharingData(vehicleid, string);
  94. return 1;
  95. }
  96. stock GetVehicleColor(vehicleid, &color1, &color2)
  97. {
  98. new
  99. stringData[24],
  100. stringColor[2][12],
  101. i
  102. ;
  103. GetSharingData(vehicleid, stringData);
  104. if((i = strfind(stringData, "-", true)) != -1)
  105. {
  106. strmid(stringColor[0], stringData, 0, i);
  107. strmid(stringColor[1], stringData, (i + 1), strlen(stringData));
  108. color1 = strval(stringColor[0]);
  109. color2 = strval(stringColor[1]);
  110. return 1;
  111. }
  112. return 0;
  113. }