Don't like ads? PRO users don't see any ads ;-)
Guest

RemoveBuilding

By: AshBFunky on Dec 3rd, 2011  |  syntax: PAWN  |  size: 2.00 KB  |  hits: 1,283  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #if !defined MAX_REMOVED_OBJECTS
  2.         #define MAX_REMOVED_OBJECTS 100
  3. #endif
  4.  
  5. enum RemovedObjectsENUM {_model, Float:_oX, Float:_oY, Float:_oZ, Float:_oRadius}
  6. new RemovedObjects[MAX_REMOVED_OBJECTS][RemovedObjectsENUM];
  7.  
  8. stock RemoveBuilding(modelid, Float:oX, Float:oY, Float:oZ, Float:oRadius)
  9. {
  10.         new slot = GetObjectFreeSlot();
  11.         if(slot == -1) return printf("\tCannot remove any more objects.\nIncrease MAX_REMOVED_OBJECTS in your script.\nIt is currently: %i", MAX_REMOVED_OBJECTS);
  12.         RemovedObjects[slot][_model] = modelid;
  13.         RemovedObjects[slot][_oX] = oX;
  14.         RemovedObjects[slot][_oY] = oY;
  15.         RemovedObjects[slot][_oZ] = oZ;
  16.         RemovedObjects[slot][_oRadius] = oRadius;
  17.        
  18.         for(new i; i < MAX_PLAYERS; i++)
  19.         {
  20.             if(!IsPlayerConnected(i)) continue;
  21.             RemoveBuildingForPlayer(i, modelid, oX, oY, oZ, oRadius);
  22.         }
  23.         return 1;
  24. }
  25.  
  26. forward REMOBJ_OnPlayerConnect(playerid);
  27. public OnPlayerConnect(playerid)
  28. {
  29.         for(new i; i < MAX_REMOVED_OBJECTS; i++)
  30.         {
  31.             if(RemovedObjects[i][_model] != 0) RemoveBuildingForPlayer(playerid, RemovedObjects[i][_model], RemovedObjects[i][_oX], RemovedObjects[i][_oY], RemovedObjects[i][_oZ], RemovedObjects[i][_oRadius]);
  32.         }
  33.         if(funcidx("REMOBJ_OnPlayerConnect") != -1) CallLocalFunction("REMOBJ_OnPlayerConnect", "i", playerid);
  34.         return 1;
  35. }
  36. #if defined _ALS_OnPlayerConnect
  37.     #undef OnPlayerConnect
  38. #else
  39.     #define _ALS_OnPlayerConnect
  40. #endif
  41. #define OnPlayerConnect REMOBJ_OnPlayerConnect
  42.  
  43. stock GetObjectFreeSlot()
  44. {
  45.         for(new i; i < MAX_REMOVED_OBJECTS; i++)
  46.         {
  47.             if(RemovedObjects[i][_model] == 0) return i;
  48.         }
  49.         return -1;
  50. }
  51.  
  52. stock CountRemovedObjects()
  53. {
  54.     new count = 0;
  55.     for(new i; i < MAX_REMOVED_OBJECTS; i++)
  56.     {
  57.         if(RemovedObjects[i][_model] != 0) count++;
  58.     }
  59.         return count;
  60. }
  61.  
  62.  
  63. stock _RemoveBuildingForPlayer(playerid, modelid, Float:fX, Float:fY, Float:fZ, Float:fRadius)
  64. {
  65.         return RemoveBuilding(modelid, fX, fY, fZ, fRadius);
  66.         #pragma unused playerid
  67. }
  68. #define RemoveBuildingForPlayer _RemoveBuildingForPlayer