Lunchbox

Cleanup Bikes Script

15 posts in this topic

Posted (edited)

Created a small script that runs once an hour to cleanup bikes that are abandoned if you are using the spawn bike script. Run the script server side, don't run it via mission.

while {true} do {
	uiSleep 3600;
	{		
		if ({alive _x} count crew _x == 0 && (typeOf _x) in ["Exile_Bike_MountainBike"]) then {
			deleteVehicle _x;
		};
	} forEach vehicles;
};
Edited by Lunchbox
2 people like this

Share this post


Link to post
Share on other sites

Some tips to improve it o.O

You should check if there are any nearby players, wouldn't want my bike removed when on a loot run. 

Even more advanced add event handlers that register when players mount or dismount from the bike so you can check if it has been inactive for more than a specific amount of time. 

2 people like this

Share this post


Link to post
Share on other sites
Advertisement

Posted (edited)

Not to be dumb but could i have a example of how to set this up server side ? Im amusing just make a pbo for it correct? Im asking for an example because i have been struggling a little bit on this one.

Edited by DIamond

Share this post


Link to post
Share on other sites

Posted (edited)

1 hour ago, DIamond said:

Not to be dumb but could i have a example of how to set this up server side ? Im amusing just make a pbo for it correct? Im asking for an example because i have been struggling a little bit on this one.

try this (drop it in the @ExileServer/addons folder). It runs every 5 minutes and deletes any bike that doesn't have a player within 100m of it (it's untested though so try it and see :) )

https://www.dropbox.com/s/afd0r7csjm8awt9/a3_exile_bikeDeleter.pbo?dl=0

Edited by second_coming
1 person likes this

Share this post


Link to post
Share on other sites

Posted (edited)

11 minutes ago, second_coming said:

try this (drop it in the @ExileServer/addons folder). It runs every 5 minutes and deletes any bike that doesn't have a player within 100m of it (it's untested though so try it and see :) )

https://www.dropbox.com/s/afd0r7csjm8awt9/a3_exile_bikeDeleter.pbo?dl=0

Thanks SC you are a life saver/fps saver... :rock: I dont mind being a test dummy for more fps at all.

1c6ba5cf4aa06111bc034e90747b3a0cd93691bd

Edited by DIamond

Share this post


Link to post
Share on other sites

Posted (edited)

@second_coming My rpt threw this 

21:17:14 Warning Message: Script \x\addons\a3_exile_bikeDeleter\initServer.sqf not found

File path is correct and the initserver.sqf is in the pbo. Just not Reading it.

Any ideas?

Edited by DIamond

Share this post


Link to post
Share on other sites

Posted (edited)

On 5/8/2016 at 10:03 AM, Lunchbox said:

Created a small script that runs once an hour to cleanup bikes that are abandoned if you are using the spawn bike script. Run the script server side, don't run it via mission.


while {true} do {
	uiSleep 3600;
	{		
		if ({alive _x} count crew _x == 0 && (typeOf _x) in ["Exile_Bike_MountainBike"]) then {
			deleteVehicle _x;
		};
	} forEach vehicles;
};

WHY WHY WHY??? Exile has a beautiful thread system for a reason!

Run this in InitServer.sqf in your mission file.


Private ["_time"];

_time = 3600; //How often you want this to run (time in sec)

_function = {

{		
	_position = position _x; 
	if ((typeOf _x) in ["Exile_Bike_MountainBike","Exile_Bike_OldBike"]) then 
	{
		if([_position, 100] call ExileClient_util_world_isAlivePlayerInRange) exitwith {};
		deleteVehicle _x;
	};
} forEach vehicles;

};

[_time, _function, [], true] call ExileServer_system_thread_addTask;	

Thats just a quick example of your code run by exile in an efficient manner :)

Edited by happydayz
2 people like this

Share this post


Link to post
Share on other sites

ANd just pulled open the pbo linked and it does it the right way ;) top marks :P

1 person likes this

Share this post


Link to post
Share on other sites
18 hours ago, happydayz said:

ANd just pulled open the pbo linked and it does it the right way ;) top marks :P

So which should we use and is this something we should use if we are using the default bike spawn script?

Share this post


Link to post
Share on other sites

u should be able to use either. theres no real need for it to be in a server pbo tho as its a tiny amount of code.

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.