Guest User

Untitled

a guest
Apr 22nd, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. //______________________|REMOVE BULDING|________________________________________|
  2. #if !defined MAX_REMOVED_OBJECTS
  3. #define MAX_REMOVED_OBJECTS 100 // Koliko obrisanih objekata ima.....
  4. #endif
  5.  
  6. enum RemovedObjectsENUM {_model, Float:_oX, Float:_oY, Float:_oZ, Float:_orX, Float:_orY, Float:_orZ, Float:_oRadius, restored}
  7. new RemovedObjects[MAX_REMOVED_OBJECTS][RemovedObjectsENUM];
  8.  
  9. /*
  10. native RemoveBuilding(modelid, Float:oX, Float:oY, Float:oZ, Float:oRadius = 0.25, Float:orX = 0.0, Float:orY = 0.0, Float:orZ = 0.0);
  11. native RestoreBuilding(slotid);
  12. native RemoveSpecificBuilding(modelid);
  13. native CountRemovedObjects();
  14. */
  15.  
  16. stock RemoveBuilding(modelid, Float:oX, Float:oY, Float:oZ, Float:oRadius = 0.25, Float:orX = 0.0, Float:orY = 0.0, Float:orZ = 0.0)
  17. {
  18. for(new i; i < MAX_REMOVED_OBJECTS; i++)
  19. {
  20. if(RemovedObjects[i][_model] != modelid) continue;
  21. if(RemovedObjects[i][restored] != 0)
  22. {
  23. if((RemovedObjects[i][_oX] == oX) && (RemovedObjects[i][_oY] == oY) && (RemovedObjects[i][_oZ] == oZ))
  24. {
  25. DestroyObject(RemovedObjects[i][restored]);
  26. RemovedObjects[i][restored] = 0;
  27. RemovedObjects[i][_model] = 0;
  28. return i;
  29. }
  30. }
  31. }
  32.  
  33. new slot = GetObjectFreeSlot();
  34. if(slot == -1) return printf("\tCannot remove any more objects.\nIncrease MAX_REMOVED_OBJECTS in your script.\nIt is currently: %i", MAX_REMOVED_OBJECTS);
  35.  
  36. RemovedObjects[slot][_model] = modelid;
  37. RemovedObjects[slot][_oX] = oX;
  38. RemovedObjects[slot][_oY] = oY;
  39. RemovedObjects[slot][_oZ] = oZ;
  40. RemovedObjects[slot][_oRadius] = oRadius;
  41.  
  42. RemovedObjects[slot][_orX] = orX;
  43. RemovedObjects[slot][_orY] = orY;
  44. RemovedObjects[slot][_orZ] = orZ;
  45.  
  46. for(new i; i < MAX_PLAYERS; i++)
  47. {
  48. if(!IsPlayerConnected(i)) continue;
  49. RemoveBuildingForPlayer(i, modelid, oX, oY, oZ, oRadius);
  50. }
  51. return slot;
  52. }
  53.  
  54. stock RestoreBuilding(slot)
  55. {
  56. if(slot < 0 || slot > MAX_REMOVED_OBJECTS) return 0;
  57. if(RemovedObjects[slot][_model] == 0) return 0;
  58. RemovedObjects[slot][restored] = CreateObject(RemovedObjects[slot][_model], RemovedObjects[slot][_oX], RemovedObjects[slot][_oY], RemovedObjects[slot][_oZ], RemovedObjects[slot][_orX], RemovedObjects[slot][_orY], RemovedObjects[slot][_orZ]);
  59. return 1;
  60. }
  61.  
  62. stock RemoveSpecificBuilding(modelid)
  63. {
  64. return RemoveBuilding(modelid, 0.0, 0.0, 0.0, 10000.0);
  65. }
  66.  
  67. stock RemoveBuildingInit(playerid)
  68. {
  69. for(new i; i < MAX_REMOVED_OBJECTS; i++)
  70. {
  71. if(RemovedObjects[i][_model] != 0) RemoveBuildingForPlayer(playerid, RemovedObjects[i][_model], RemovedObjects[i][_oX], RemovedObjects[i][_oY], RemovedObjects[i][_oZ], RemovedObjects[i][_oRadius]);
  72. }
  73. return 1;
  74. }
  75.  
  76. stock GetObjectFreeSlot()
  77. {
  78. for(new i; i < MAX_REMOVED_OBJECTS; i++)
  79. {
  80. if(RemovedObjects[i][_model] == 0) return i;
  81. }
  82. return -1;
  83. }
  84.  
  85. stock CountRemovedObjects()
  86. {
  87. new count = 0;
  88. for(new i; i < MAX_REMOVED_OBJECTS; i++)
  89. {
  90. if(RemovedObjects[i][_model] != 0) count++;
  91. }
  92. return count;
  93. }
  94. //______________________________________________________________________________|
Advertisement
Add Comment
Please, Sign In to add comment