Xaviour212

Ulric Object Streamed

Mar 7th, 2011
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.06 KB | None | 0 0
  1. //=========================Ulric Object Streamed================================
  2. //  Credits to:
  3. //  - Xaviour212 / Dimas Rizward H, make this Gamemode
  4. //  - [HIC]TheKillers for this turtorial
  5. //  - [Ulric]Mas.Boy / Xtrememood for helping me.Love you :D :maho
  6.  
  7.  
  8. #include <a_samp>
  9.  
  10. #define MAX_STREAMED_OBJECTS 5000 //The less the better, this will total at around 3mb AMX file size.
  11. new ObjectModel[MAX_STREAMED_OBJECTS]; //Objectmodel
  12. new Float:ObjectPos[MAX_STREAMED_OBJECTS][3]; //ObjectPos (X, Y, Z)
  13. new Float:ObjectRotation[MAX_STREAMED_OBJECTS][3]; //ObjectRotation (X, Y, Z)
  14. new Float:ObjectDistance[MAX_STREAMED_OBJECTS]; //Veiw distance
  15. new ObjectIDS[MAX_PLAYERS][MAX_STREAMED_OBJECTS]; //Object ID's.
  16. new ObjectStreamed[MAX_PLAYERS][MAX_STREAMED_OBJECTS]; //Objects being viewed by a player
  17. new ObjectID = -1; //ObjectCount
  18. new ObjectUsed[MAX_STREAMED_OBJECTS]; //Disable = 0 enable = 1
  19.  
  20. stock CreateDynamicObject(ModelID, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:Dist = 100.0)
  21. {
  22.     ObjectID++; //ObjectID
  23.     ObjectModel[ObjectID] = ModelID; //Model
  24.     ObjectPos[ObjectID][0] = X; //XPos
  25.     ObjectPos[ObjectID][1] = Y; //YPos
  26.     ObjectPos[ObjectID][2] = Z; //ZPos
  27.     ObjectRotation[ObjectID][0] = rX; //RotationX
  28.     ObjectRotation[ObjectID][1] = rY;//RotationY
  29.     ObjectRotation[ObjectID][2] = rZ; //RotationZ
  30.     ObjectDistance[ObjectID] = Dist; //View distance
  31.     ObjectUsed[ObjectID] = 1; //Disable/enable the object, it's starting off being enabled.
  32. }
  33.  
  34. stock DestoryObjectEx(ObjectId) //Destroys the object
  35. {
  36.     ObjectUsed[ObjectId] = 0;
  37.     for(new i; i<MAX_PLAYERS; i++)
  38.     {
  39.       if(ObjectStreamed[i][ObjectId] == 1)
  40.       {
  41.         ObjectStreamed[i][ObjectId] = 0;
  42.         DestroyPlayerObject(i, ObjectIDS[i][ObjectId]);
  43.         }
  44.     }
  45. }
  46.  
  47. stock SetObjectDistance(ObjectId, Float:Dist) //Sets the view distance of a object
  48. {
  49.     ObjectDistance[ObjectId] = Dist;
  50. }
  51.  
  52. public OnFilterScriptInit()
  53. {
  54.     SetTimer("Stream", 400, true);
  55.     print("\n--------------------------------------");
  56.     print(" Blank Filterscript by your name here");
  57.     print("--------------------------------------\n");
  58.     return 1;
  59. }
  60.  
  61. forward Stream();
  62. public Stream()
  63. {
  64.     for(new i; i<MAX_PLAYERS; i++)//Goes through all players
  65.     {
  66.       if(IsPlayerConnected(i)) //All online players
  67.       {
  68.         for(new S; S<ObjectID+1; S++) //All active Checkpoints
  69.         {
  70.           if(ObjectUsed[S] == 1) //Checks if the object is enabled
  71.           {
  72.                 if(IsPlayerInRangeOfPoint(i, ObjectDistance[S], ObjectPos[S][0], ObjectPos[S][1], ObjectPos[S][2]) && ObjectStreamed[i][S] == 0)//Is the player close enough to the object
  73.                 {
  74.                 ObjectIDS[i][S] = CreatePlayerObject(i, ObjectModel[S], ObjectPos[S][0], ObjectPos[S][1], ObjectPos[S][2], ObjectRotation[S][0], ObjectRotation[S][1], ObjectRotation[S][2]);//Create the object
  75.                 ObjectStreamed[i][S] = 1; //Shows the object streamed for the player
  76.                 continue;
  77.                 }
  78.                 }
  79.             }
  80.         }
  81.     }
  82.     return 1;
  83. }
Add Comment
Please, Sign In to add comment