Advertisement
dann1s

WE

Dec 17th, 2019
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.32 KB | None | 0 0
  1. #define MAX_REMOVED_OBJECTS (1000)
  2. enum ObjectRemoved
  3. {
  4.     Model,
  5.     Float:Location[3]
  6. }
  7. new
  8.         RemovedObject[MAX_REMOVED_OBJECTS][ObjectRemoved],
  9.         g_SlotID = -1
  10. ;
  11.  
  12. // Nove Funkcije
  13. stock IsPosInRangeOfPoint3D(Float:pos_x, Float:pos_y, Float:pos_z, Float:range, Float:range_x, Float:range_y, Float:range_z)
  14. {
  15.     pos_x -= range_x;
  16.     pos_y -= range_y;
  17.     pos_z -= range_z;
  18.     return ((pos_x * pos_x) + (pos_y * pos_y) + (pos_z * pos_z)) < (range * range);
  19. }
  20. stock AddSnowObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:d_stream = 200.0)
  21. {
  22.     new
  23.             object = CreateDynamicObject(modelid, (x + 0.075), (y + 0.15), (z + 0.15), rx, ry, rz, .streamdistance = d_stream);
  24.     for(new a = 0; a < 30; a++)
  25.         SetDynamicObjectMaterial(object, a, 17944, "lngblok_lae2", "white64bumpy");
  26.     return object;
  27. }
  28.  
  29. stock IsPosInArea(Float:pos_x, Float:pos_y, Float:min_x, Float:min_y, Float:max_x, Float:max_y)
  30. {
  31.     if(pos_x >= min_x && pos_x <= max_x
  32.     && pos_y >= min_y && pos_y <= max_y)
  33.         return true;
  34.     return false;
  35. }
  36.  
  37. stock CreateSnowInArea(Float:min_x, Float:min_y, Float:max_x, Float:max_y, Float:max_z = 300.0, Float:min_obj_model_size = 30.0)
  38. {
  39.     new
  40.             count;
  41.     for(new a = 0; a < SEARCH_DATA_SIZE; a++)
  42.     {
  43.         if(SearchData[a][SearchZ] > max_z)
  44.             continue;
  45.         if(!IsPosInArea(SearchData[a][SearchX], SearchData[a][SearchY], min_x, min_y, max_x, max_y))
  46.             continue;
  47.         if(GetColSphereRadius(SearchData[a][Search_Model]) < min_obj_model_size)
  48.             continue;
  49.         if(IsObjectRemoved(SearchData[a][Search_Model], SearchData[a][SearchX], SearchData[a][SearchY], SearchData[a][SearchZ]))
  50.             continue;
  51.         AddSnowObject(
  52.             SearchData[a][Search_Model],
  53.             SearchData[a][SearchX],
  54.             SearchData[a][SearchY],
  55.             SearchData[a][SearchZ],
  56.             SearchData[a][SearchRX],
  57.             SearchData[a][SearchRY],
  58.             SearchData[a][SearchRZ],
  59.             (100.0 + GetColSphereRadius(SearchData[a][Search_Model]))
  60.         );
  61.         count++;
  62.     }
  63.     printf("Total snow objects: %i", count);
  64.     return true;
  65. }
  66.  
  67. stock RemoveObject(modelid, Float:pos_x, Float:pos_y, Float:pos_z)
  68. {
  69.     g_SlotID++;
  70.     if(g_SlotID == MAX_REMOVED_OBJECTS)
  71.     {
  72.         printf("Error: Limit for removed objects is reached. Open your script and change \"MAX_REMOVED_OBJECTS\" definition to a bigger value if you want to have more removed objects.");
  73.         g_SlotID--;
  74.         return -1;
  75.     }
  76.     if(g_SlotID == 1000)
  77.     {
  78.         printf("SA-MP limit: There appears to be a limit of around 1000 lines/objects. There is no workaround.");
  79.         g_SlotID--;
  80.         return -1;
  81.     }
  82.     RemovedObject[g_SlotID][Model]      =   modelid;
  83.     RemovedObject[g_SlotID][Location][0]    =     pos_x;
  84.     RemovedObject[g_SlotID][Location][1]    =     pos_y;
  85.     RemovedObject[g_SlotID][Location][2]    =     pos_z;
  86.     return g_SlotID;
  87. }
  88.  
  89. stock GetNumberOfRemovedObjects()
  90.     return (g_SlotID + 1);
  91.    
  92. stock IsObjectRemoved(modelid, Float:pos_x, Float:pos_y, Float:pos_z)
  93. {
  94.     if(!GetNumberOfRemovedObjects())
  95.         return false;
  96.     for(new a = 0; a < GetNumberOfRemovedObjects(); a++)
  97.     {
  98.         if(modelid == RemovedObject[a][Model])
  99.         {
  100.             if(IsPosInRangeOfPoint3D(pos_x, pos_y, pos_z, 0.5, RemovedObject[a][Location][0], RemovedObject[a][Location][1], RemovedObject[a][Location][2]))
  101.                 return true;
  102.         }
  103.     }
  104.     return false;
  105. }
  106.  
  107. //OnGameModeInit
  108. CreateSnowInArea(50.0, -3000.0, 3000.0, -750.0, 300.0, 30.0);
  109.  
  110. //RemoveObject primjer, ide pod OnGameModeInit
  111.     /*
  112.         @modelid - model of your object
  113.         @Float: pos_x - X coordinate for your object
  114.         @Float: pos_y - Y coordinate for your object
  115.         @Float: pos_z - Z coordinate for your object
  116.     */
  117. RemoveObject(4024, 1479.8672, -1790.3984, 56.0234);
  118.  
  119.  
  120. //onplayerconnect
  121. if(GetNumberOfRemovedObjects())
  122. {
  123.     for(new a = 0; a < GetNumberOfRemovedObjects(); a++)
  124.     {
  125.         RemoveBuildingForPlayer(
  126.             playerid,
  127.             RemovedObject[a][Model],
  128.             RemovedObject[a][Location][0],
  129.             RemovedObject[a][Location][1],
  130.             RemovedObject[a][Location][2],
  131.             0.5
  132.         );
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement