About Me:
Hello dear SA-MP community :) My name's Nickk888, i'm a German/Polish PAWN Scripter since 2011, I own a YT channel about SA-MP Scripting in Polish language and I create scripts for the public for free. Excuse my English skill, I'm no native English speaker, so please keep this in mind :) I'll try my best ^_^
About Script:
Nickk's Vehicle Streamer is a, well... A vehicle streamer :D It allows you to create a lot more then 2,000 Vehicles on your server, and by a lot more i mean A FREAKING LOT MORE! Technically over 100,000, but I've limited it to 100,000 because you know the lag it would create? But you can change it in the source and recompile if you want :)
How does it work:
Well, it works by assigning the vehicles into chunks that are created on the map while the script is loaded, the script creates about 17,656 chunks (Depending on the settings), by chunks i mean Dynamic Areas using Incognito's Streamer, the script checks if ANY player is on a chunk(Dynamic Area), if so, it will load(Create) the vehicles assigned(Registered) in this particular chunk and neighbor chunks to create a seamless vehicle stream without vehicles popping up suddenly. If the player leaves the chunk, it will unload this chunk and the other as well (Only if there is no other player on it of course).
Why did i do it that way? Well, because of efficiency! There is only 1 timer that checks every second(Can be changed in the setting in Scriptfiles) if ANY player is on a chunk, that's it! There is no player to vehicle distance check! All of that makes it A LOT faster!
Efficiency:
As i wrote above, the efficiency depends on the amount of chunks that are created, less chunks = Better performance, you can change all of that in the settings, by default the chunk size is 300(Samp Units(?)), so by that it will create from X/Y -20,000 to X/Y 20,000 about 17,656 chunks, why 40,000 x 40,000? Because that's the default limit you can travel outside the map, so if there are vehicles outside the map, it will still create them!
Average operating time every second on 17,656 chunks is 2-60ms, tested on 1-3 players, needs to be tested on a larger server! But i think because of how Incognito's streamer works, it will probably be still very efficient!
Functions:
You will need to use those functions in your Gamemode or other Filterscript, the main script "nvs-core.amx" will receive those commands.
Code:
CreateDynamicVehicle(model, Float:x, Float:y, Float:z, Float:rot, color1, color2, respawndelay = -1, addsiren = 0)
DestroyDynamicVehicle(vehicleid)
SetDynamicVehiclePos(vehicleid, Float:x, Float:y, Float:z)
SetDynamicVehicleZAngle(vehicleid, Float:zangle)
SetDynamicVehicleHealth(vehicleid, Float:health)
ChangeDynamicVehicleColor(vehicleid, color1, color2)
AddDynamicVehicleComponent(vehicleid, componentid)
PutPlayerInDynamicVehicle(playerid, vehicleid, seatid)
SetDynamicVehicleToRespawn(vehicleid)
ChangeDynamicVehiclePaintjob(vehicleid, paintjobid)
LinkDynamicVehicleToInterior(vehicleid, interiorid)
SetDynamicVehicleVirtualWorld(vehicleid, worldid)
CountDynamicVehicles()
CountSpawnedDynamicVehicles()
GetDynamicVehicleInternalID(vehicleid)
GetDynamicVehicleModel(vehicleid)
GetDynamicVehicleVirtualWorld(vehicleid)
GetDynamicVehicleInterior(vehicleid)
GetDynamicVehiclePos(vehicleid, &Float:x, &Float:y, &Float:z, &Float:angle)
GetDynamicVehicleColor(vehicleid, &color1, &color2)
You will need to use them if you want to attach and dettach something on the vehicle like an object, 3d Text Label etc.
Code:
OnDynamicVehicleSpawn(vehicleid, internal_id)
OnDynamicVehicleDespawn(vehicleid, internal_id)
Incognito's Streamer for the core functions.
maddinat0r's Sscanf 2 for some "Get" functions it's needed.
Screenshots:
There are no Screenshots, what should i show you? Vehicles on the map? It's a Vehicle Streamer, watch the video!
Video:
Turn on subtitles on the video! I've added english subtitles.
CLICK HERE!
If the link doesn't work, use this Video ID on Y0uTube: JTzxolbxlAU
Known problems:
- I have no idea how i should implement the respawn delay on vehicles... It works.. but, only when the vehicle is spawned. It will not respawn if the vehicle is despawned.
- If you create a vehicle outside the 40,000 x 40,000 boundaries, it will not create the vehicle.
You can change the MAP_SIZE definition in the source file and recompile the script but...
It's not recommended to do so! You have plenty of space withing the boundaries...
Why outside?... - Unfortunately there is no check if a script that has created Dynamic Vehicles, has been unloaded so the vehicles are automatically removed,
you will need to keep track of the ID's within the script and use the Destroy function to remove them "Manually" on OnFilterScriptExit and or OnGameModeExit. - There is a possibility to "overflow" a chunk with vehicles, the script can only register 2000 vehicles per chunk, so if there are vehicles that want to register to a full chunk, it will either not Create the vehicle and or not register the vehicle.
- There is also no check if there are too much vehicles created on the server, the script will try to spawn them, but if the CreateVehicle function will fail, well, it will not spawn the vehicle.
Just don't create that much vehicles in one place and you'll be fine...
Changelog:
Beta 1.0
Code:
First Release.
Mirror 1: http://bit.do/nvs-link
Mirror 2: https://github.com/Nickk888SAMP/Vehicle-Streamer
Last words:
This system needs a lot of testing! It's still beta! Please test if it works on your server, if you find any bugs, glitches and other problems, please let me know!