Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=========================Ulric Object Streamed================================
- // Credits to:
- // - Xaviour212 / Dimas Rizward H, make this Gamemode
- // - [HIC]TheKillers for this turtorial
- // - [Ulric]Mas.Boy / Xtrememood for helping me.Love you :D :maho
- #include <a_samp>
- #define MAX_STREAMED_OBJECTS 5000 //The less the better, this will total at around 3mb AMX file size.
- new ObjectModel[MAX_STREAMED_OBJECTS]; //Objectmodel
- new Float:ObjectPos[MAX_STREAMED_OBJECTS][3]; //ObjectPos (X, Y, Z)
- new Float:ObjectRotation[MAX_STREAMED_OBJECTS][3]; //ObjectRotation (X, Y, Z)
- new Float:ObjectDistance[MAX_STREAMED_OBJECTS]; //Veiw distance
- new ObjectIDS[MAX_PLAYERS][MAX_STREAMED_OBJECTS]; //Object ID's.
- new ObjectStreamed[MAX_PLAYERS][MAX_STREAMED_OBJECTS]; //Objects being viewed by a player
- new ObjectID = -1; //ObjectCount
- new ObjectUsed[MAX_STREAMED_OBJECTS]; //Disable = 0 enable = 1
- stock CreateDynamicObject(ModelID, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:Dist = 100.0)
- {
- ObjectID++; //ObjectID
- ObjectModel[ObjectID] = ModelID; //Model
- ObjectPos[ObjectID][0] = X; //XPos
- ObjectPos[ObjectID][1] = Y; //YPos
- ObjectPos[ObjectID][2] = Z; //ZPos
- ObjectRotation[ObjectID][0] = rX; //RotationX
- ObjectRotation[ObjectID][1] = rY;//RotationY
- ObjectRotation[ObjectID][2] = rZ; //RotationZ
- ObjectDistance[ObjectID] = Dist; //View distance
- ObjectUsed[ObjectID] = 1; //Disable/enable the object, it's starting off being enabled.
- }
- stock DestoryObjectEx(ObjectId) //Destroys the object
- {
- ObjectUsed[ObjectId] = 0;
- for(new i; i<MAX_PLAYERS; i++)
- {
- if(ObjectStreamed[i][ObjectId] == 1)
- {
- ObjectStreamed[i][ObjectId] = 0;
- DestroyPlayerObject(i, ObjectIDS[i][ObjectId]);
- }
- }
- }
- stock SetObjectDistance(ObjectId, Float:Dist) //Sets the view distance of a object
- {
- ObjectDistance[ObjectId] = Dist;
- }
- public OnFilterScriptInit()
- {
- SetTimer("Stream", 400, true);
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- forward Stream();
- public Stream()
- {
- for(new i; i<MAX_PLAYERS; i++)//Goes through all players
- {
- if(IsPlayerConnected(i)) //All online players
- {
- for(new S; S<ObjectID+1; S++) //All active Checkpoints
- {
- if(ObjectUsed[S] == 1) //Checks if the object is enabled
- {
- 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
- {
- 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
- ObjectStreamed[i][S] = 1; //Shows the object streamed for the player
- continue;
- }
- }
- }
- }
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment