[Include] [INC/FS] Fallout's Object Streamer v1.2 for 0.3e (updated on 20-09-'12 ~ new features!)
#1

_Fallout's Object Streamer v1.2:____________________________________________



_How the streamer works:____________________________________________
This is a very fast streamer that loads the closest 800 objects (can be changed), only when the objects are in range of the player's view.
It only updates if the player is moving, because objects shouldn't be updated if the player isn't moving right?

The streamer has been tested with 100.000 objects without problems (tested on samp 0.3d).
The limit is higher, but it has not been tested yet, because I think nobody has more then 100.000 objects?

You can see how it works in the video below.


_Features:____________________________________________
- Instant update when teleporting players using SetPlayerPos (they won't fall trough objects).
- When using PlayerObjects, you can still use all the normal functions on that object. There are no separate PlayerObject versions of each function.
- Easy to implement in your gamemode/filterscript.
- Vehicles don't fall trough the ground.
- Fast object streaming.


_Converters:____________________________________________
- ConvertFFS
- CodeGenerators
-
Please suggest links for other converters

_Configuration of the streamer:____________________________________________
Code:
#define F_MAX_OBJECTS           2500    //maximum amount of objects the streamer will create; PLEASE change this to the amount of objects you are using.
#define UpdateTime              1000    //update time in ms (milliseconds). A lower value means faster updating.
#define ObjectsToStream         500     //maximum number of objects that will be streamed for one player. (maximum = 1000 objects in 0.3e)
#define StreamRange             500.0   //the player's object view range, doesn't need to be changed because objects already fade at 300 distance.
#define DistanceBeforeUpdate    5.0     //the distance a player must travel before objects get updated. (also matters a lot for CPU usage)
#define DebugMode               1       //change this to 1 if you want to see debug messages in-game. (time taken for update, objects streamed, objects created, objects destroyed, ...)
#pragma dynamic                 30000   //increase this value if you have problems with stach/heap size.
_Functions:____________________________________________
Code:
native F_CreateObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:vdist=0.0, bool:InstantUpdate=false);                 //creates an object, returns the objectid or -1 if not successful. (viewdistance and InstantUpdate parameter  are optional)
native F_CreatePlayerObject(playerid, modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:vdist=0.0, bool:InstantUpdate=false); //creates a player-specific object, returns the objectid or -1 if not successful. (viewdistance and InstantUpdate parameter  are optional)
native F_DestroyObject(objectid);                                                                                                                   //destroys an object.
native F_IsObjectCreated(objectid);                                                                                                                 //returns 1 if the object is created, returns 0 if it's not.
native F_IsObjectCreatedForPlayer(playerid, objectid);                                                                                              //returns 1 if the object is created for a certain player, returns 0 if it's not.
native F_PlayerObjectUpdate(playerid, Float:x, Float:y, Float:z);                                                                                   //update objects for a player in a certain position.
native F_MoveObject(objectid, Float:x, Float:y, Float:z, Float:speed, Float:rx=0.0, Float:ry=0.0, Float:rz=0.0, bool:UpdatePos=true);               //moves an object. (rotation parameters rx ry and rz and UpdatePos are optional) (UpdatePos will update the object's coordinates for streaming at the right position)
native F_StopObject(objectid);                                                                                                                      //stops an object from moving, returns 1 on success and 0 if the object is invalid.
native F_IsObjectMoving(objectid);                                                                                                                  //returns 1 if the object is moving, returns 0 if the object is not moving, returns -1 if the object is invalid.
native F_AttachObjectToPlayer(objectid, playerid, Float:x, Float:y, Float;z, Float:rx, Float:ry, Float:rz, bool:InstantUpdate=false);               //attaches an object to a player.
native F_AttachObjectToVehicle(objectid, vehicleid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, bool:InstantUpdate=false);             //attaches an object to a vehicle.
native F_SetObjectPos(objectid, Float:x, Float:y, Float:z, bool:InstantUpdate=false);                                                               //sets the position of an object. (InstantUpdate parameter  is optional)
native F_GetObjectPos(objectid, &Float:x, &Float:y, &Float:z);                                                                                      //gets the position of an object in x, y and z.
native F_SetObjectRot(objectid, Float:rx, Float:ry, Float:rz);                                                                                      //sets the rotation of an object.
native F_GetObjectRot(objectid, &Float:rx, &Float:ry, &Float:rz);                                                                                   //gets the rotation of an object in rx, ry and rz.
native F_CountObjects();                                                                                                                            //returns the amount of created objects.
native F_RefreshObjects(playerid);                                                                                                                  //recreates (refreshes) a certain player's objects. (useful to recreate broken objects like glass, boxes, barrels, ...)
native F_ObjectUpdateForAll();                                                                                                                      //instantly updates the objects for all players.
native SetPlayerPos(playerid, Float:x, Float:y, Float:z, bool:InstantUpdate=true);                                                                  //added extra parameter (optional) to disable instant object update.
_Callbacks:____________________________________________
Code:
native F_OnObjectMoved(objectid);             //callback which is called when an object has finished moving.
Functions like F_SetObjectPos(); can also be used on objects created with F_CreatePlayerObject();


_Download:____________________________________________

Include:
F_Streamer_1.2.rar

Include with filterscript:
F_Streamer_1.2_2.rar

Note: You don't need to download this filterscript if you want to put the objects in your gamemode. If you put them in your gamemode follow the instructions for "Use in gamemode" at "How to install"


_How to install:____________________________________________

Use as filterscript:
- Put the filterscript in this folder: server\filterscripts\<here>
- Change F_MAX_OBJECTS to the amount of objects you are using. (a little higher, for example: I you have 1000 objects, you should set this value to 1100 for avoiding problems when you add some more objects)
- Add F_Streamer to your filterscripts line in server.cfg
- Put your objects under OnFilterScriptInit() or where ever in the script you want them to be.

Use in gamemode:
- Put this inc in this folder: server\pawno\include\<here>
- Change F_MAX_OBJECTS to the amount of objects you are using. (a little higher, for example: I you have 1000 objects, you should set this value to 1100 for avoiding problems when you add some more objects)
- Add #include <F_Streamer> at the top of your gamemode.
- Put your objects under OnGameModeInit() or where ever in the script you want them to be.


_Creating objects:____________________________________________

Code:
F_CreateObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:vdist=0.0, bool:InstantUpdate=false);
Example:
Code:
F_CreateObject(987, 1126.183594, 1014.555176, 10.000000, 0.0000, 0.0000, 43.5305, 200.0, true);
In this example, creating this object will instantly show the object for all players instead of at the next update, because the last parameter is set to true. You should not do this for all objects, because it will take ages to load all objects if you refresh the player's objects each time you create an object...


To create the objects, you just need to change all object lines from CreateObject() to F_CreateObject()
(use CTRL + H in pawno)
The last parameter, draw distance, doesn't need to be added. When not added, it uses the standard drawdistance.

Little stress test video:
[ame]http://www.youtube.com/watch?v=HhshSJufhJo[/ame]

Streaming speed video:
[ame]http://www.youtube.com/watch?v=calvWe8dszU[/ame]


_Changelog:____________________________________________

20-09-'12 v1.2 released
- Improved streaming with SetPlayerPos.
- Added InstantUpdate parameter to SetPlayerPos.
- Stuff updated with moveobject parameters.
- Minor updates at F_CreateObject and F_PlayerObjectUpdate.
- Bug fixed with playerobjects still being created after the player left.
- Updated distance sorting code for faster update times.
- Added debug mode (shows ingame information about objects being created/destroyed).
- Made streamer run even faster!
- Added function AttachObjectToVehicle.
- Fixed attached objects not re-appearing after the object was out of range.

26-12-'11 v1.1 released
- Loading 100.000 objects happens in the blink of an eye now, instead of in a minute. (issue with slow objectid assignment)
- Function removed: F_IsValidObject. (see F_IsObjectCreated)
- Streamer starts up faster now. (start of the update timer now happens after all objects are created)
- Function added: F_CountObjects();

25-12-'11 v1.0 released
- Fixed a bug with F_MoveObject rotation not working correctly.
- Added IsObjectCreated(objectid);
- Streamer runs a little faster.

24-12-'11 v0.9 released
- Bug fixed which made the streamer work really slow.
- Streamer runs even faster now!
- Added InstantUpdate parameter to F_CreateObject and F_CreatePlayerObject.
- Added new setting for the configuration: DistanceBeforeUpdate. //the distance a player must travel before objects get updated. (also matters a lot for CPU usage)

21-12-'11 v0.8 released
- 0.3d compatible.
- Added F_IsObjectCreatedForPlayer(playerid);
- Added F_IsObjectMoving(objectid);
- Fixed problem with trying to move objects that were already moving.
- Fixed some other small bugs.

16-01-'11 v0.7 released
- Added AttachObjectToPlayer(objectid, playerid, x, y, z, rx, ry, rz);
- No more need for adding F_OnPlayerConnect(playerid); -> see credits

09-01-'11 v0.6 released
- Version works for sa-mp 0.3c
- Added Player Objects (F_CreatePlayerObject)
- Added F_OnObjectMoved(objectid);

20-08-'10 v0.5 released
- Version for sa-mp 0.3b (with draw distance parameter) (also works on 0.3a)

16-01-'10 v0.4 released
- Missing objects bug totally fixed

15-01-'10 v0.3 released
- Object calculation is A LOT faster now (it uses a lot less CPU).
- Code optimized

13-01-'10 v0.2 released
- New function: F_RefreshObjects(playerid) //recreates (refreshes) a certain player's objects. (useful to recreate broken objects like glass, boxes, barrels, ...)
- Stuff fixed with missing objects

02-01-'10 v0.1 released
- Initial release


_Credits:____________________________________________
- Credits to Hiddos and ****** for the callback hook for OnPlayerConnect.




If there are any questions, just ask them here!
NO mirrors please.
Reply
#2

nice work !awesome
Reply
#3

Nice Fallout
Reply
#4

Good work Fall!
Reply
#5

thanks all
Reply
#6

im gonna try to use this cause my other one broke on me


EDIT: Works Amazingly =)
Reply
#7

Quote:
Originally Posted by FS}Nameless [LDR
]
im gonna try to use this cause my other one broke on me
please tell me how it goes ^^
Reply
#8

Cool Nice work
Reply
#9

fallout did you know this problem on stunt and freeroams servers when ramps and jumps are to long ? than you cant see some objects did your streamer didnґt have this problem
Reply
#10

Another streamer.
Nice release fallout, I hope the nearest 10 objects problem was resolved (obviously, with the release :P).

I might test this out on my server, see how it competes against our current streamer.
Code:
#define StreamRange   400.0 //the player's object view range, doesn't need to be changed.
Interesting
Nice work.
Reply
#11

Quote:
Originally Posted by Antoni0
fallout did you know this problem on stunt and freeroams servers when ramps and jumps are to long ? than you cant see some objects did your streamer didnґt have this problem
I don't understand what you mean with that problem could you explain more please? ^^

Quote:
Originally Posted by Rac3r
Another streamer.
Nice release fallout, I hope the nearest 10 objects problem was resolved (obviously, with the release :P).

I might test this out on my server, see how it competes against our current streamer.
Code:
#define StreamRange   400.0 //the player's object view range, doesn't need to be changed.
Interesting
Nice work.
why interesting? ^^

there is a view distance to lower CPU usage.
the player can't see further then 400 so it's not necessary to stream these objects
the objects already fade away at a distance of 380 before they are destroyed by the streamer
Reply
#12

Please redownload
I changed something but it's stupid because it's just such a small thing to call it an update, and only 10 people have downloaded it already... so just redownload it
Reply
#13

Great
Reply
#14

Good script, great!
Reply
#15

Nice Fallout
Reply
#16

I use midostream but this one looks to good !
Reply
#17

Awesome this is definetley getting used on my server
Its making my pawno freeze :S


WTF my server just complied 10 megabytes when theres only 500 lines most of them teleports


**.amx 9.91 MB (10,399,273 bytes) (With the objects of your streamer) (roughly 250 objects)
**.amx 250 KB (256,490 bytes) (without it)
Reply
#18

I hope this gets fixed, because I like this streamer very much
Reply
#19

You probally forgot to change F_MAX_OBJECTS, set it to the amount of objects you have.

It's set to 4000 standard

but... 9MB?!? Wtf
Reply
#20

One suggestion:
Use in stead of MAX_PLAYERS an own defined PLAYERSLOT; that makes sure your amx is less. (only not if you have 500 slots of course :P)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)