SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 02/01/2010, 01:51 PM   #1
ғαιιοцт
High-roller
 
ғαιιοцт's Avatar
 
Join Date: Feb 2008
Posts: 1,704
Reputation: 178
Post [INC/FS] Fallout's Object Streamer v1.2 for 0.3e (updated on 20-09-'12 ~ new features!)

_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:

Streaming speed video:


_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 Y_Less for the callback hook for OnPlayerConnect.




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

Last edited by ғαιιοцт; 23/09/2012 at 10:44 AM. Reason: Update v1.2 for 0.3e + new features
ғαιιοцт is offline   Reply With Quote
Old 02/01/2010, 01:51 PM   #2
Deat_Itself
Gangsta
 
Join Date: May 2009
Location: UAE (Abudhabi,Shahama)
Posts: 605
Reputation: 4
Default Re: [INC] Fallout's Object Streamer

nice work !awesome
Deat_Itself is offline   Reply With Quote
Old 02/01/2010, 02:31 PM   #3
RenisiL
Gangsta
 
RenisiL's Avatar
 
Join Date: Aug 2008
Posts: 533
Reputation: 4
Default Re: [INC/FS] Fallout's Object Streamer

Nice Fallout
RenisiL is offline   Reply With Quote
Old 02/01/2010, 02:55 PM   #4
pliva_sb
Big Clucker
 
pliva_sb's Avatar
 
Join Date: Mar 2009
Location: Croatia
Posts: 127
Reputation: 1
Default Re: [INC/FS] Fallout's Object Streamer

Good work Fall!
pliva_sb is offline   Reply With Quote
Old 02/01/2010, 03:04 PM   #5
ғαιιοцт
High-roller
 
ғαιιοцт's Avatar
 
Join Date: Feb 2008
Posts: 1,704
Reputation: 178
Default Re: [INC/FS] Fallout's Object Streamer

thanks all
ғαιιοцт is offline   Reply With Quote
Old 02/01/2010, 03:10 PM   #6
fsnameless
Big Clucker
 
Join Date: Dec 2009
Posts: 110
Reputation: 1
Default Re: [INC/FS] Fallout's Object Streamer

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


EDIT: Works Amazingly =)
fsnameless is offline   Reply With Quote
Old 02/01/2010, 03:25 PM   #7
ғαιιοцт
High-roller
 
ғαιιοцт's Avatar
 
Join Date: Feb 2008
Posts: 1,704
Reputation: 178
Default Re: [INC/FS] Fallout's Object Streamer

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 ^^
ғαιιοцт is offline   Reply With Quote
Old 02/01/2010, 07:03 PM   #8
RyDeR`
High-roller
 
RyDeR`'s Avatar
 
Join Date: Feb 2009
Location: Belgium
Posts: 3,133
Reputation: 645
Default Re: [INC/FS] Fallout's Object Streamer

Cool Nice work
__________________

Sup?
RyDeR` is offline   Reply With Quote
Old 02/01/2010, 07:10 PM   #9
a-day
Big Clucker
 
Join Date: Jun 2008
Posts: 92
Reputation: 0
Default Re: [INC/FS] Fallout's Object Streamer

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
a-day is offline   Reply With Quote
Old 02/01/2010, 07:20 PM   #10
Rac3r
Gangsta
 
Join Date: May 2007
Posts: 700
Reputation: 32
Default Re: [INC/FS] Fallout's Object Streamer

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.
Rac3r is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] Fallout's SpeedoMeter - Updated for 0.3! ғαιιοцт Filterscripts 209 20/09/2014 02:10 PM
[Include] [INC] Fallout's New Menu Styles. Updated: V4 (new functions) ғαιιοцт Includes 160 07/02/2012 09:22 PM
Fallout's Streamer, 2 warnigns iLcke Help Archive 1 07/06/2011 02:41 PM
Fallout's Object Streamer HELP kikoto Help Archive 0 29/01/2011 09:43 AM
9 warnings because of Fallout's Object Streamer :S Ehab1911 Help Archive 3 17/11/2010 04:33 AM


All times are GMT. The time now is 07:07 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.