Jump to content
Sign in to follow this  
Laviski

halo script not working on dedicated server.

Recommended Posts

hey,

when i test this locally it works perfectly, but when i put it on my dedicated server it doesn't work can anyone shed some light as to why?

i have the line of code in the init as well.

// GeneralCarver Crew Parajump Manager Script
// Author: GeneralCarver
// Version: 1
// Date: 12/15/10
// Description: This script manages the ejection of A.I. or players in the cargo of an air vehicle.

/*
How to use...

NOT RECOMMENDED FOR USE WITH ACE2 MOD!


Launch the script with the following line of code. The code needs to be executed server side and at the moment you want to units to eject out of plane.
The plane could be piloted by a human player or A.I. The pilot in the script is ignored.

gc_crew_parajump_manager_script = [vehiclename, jump delay] execVM "gc_crew_parajump_manager.sqf";

array elements description...
vehiclename - name of vehicle which units will be ejecting out of.
jump delay - pause between crew jumping out.  (recommend 0.75 on dedicated server)



*/

// ==================================================================================================
// Define Variables

private ["_veh", "_jump_delay"];
_veh = _this select 0;
_jump_delay = _this select 1;

//
// ==================================================================================================




// ==================================================================================================
// Begin Script

{
if (_x == crew _veh select 0) then 
{
// nothing, its the driver. leave in.
} else 
{
// eject the unit...
_x action ["eject", _veh];
// wait until the server sees the unit is out of plane...
waituntil {vehicle _x != _veh};
_x setvelocity [0,0,0];
[_x] exec "ca\air2\halo\data\Scripts\HALO_init.sqs";
hint 'Don''t forget to open your chute!';
// pause between jumps..
sleep _jump_delay;
};
} foreach crew _veh;

//
// ==================================================================================================




// ==================================================================================================
// Change Log

/*

v1 - 12/15/10 - Released.

*/

Share this post


Link to post
Share on other sites

I reworked the script for you. Give it a shot and let know how it goes (did not test).

input is the same: [vehicle name,delay] execVM "TheBelowScript.sqf";

//by Kempco

//------Clients and Server-----//
Laviski_HALO_fnc = {
_this spawn {//So I can use the same PVEH for both functions
	if (!local _this) exitWith {};
	_this action ["eject",vehicle _this];
	WaitUntil{_this == vehicle _this};
	_this setVelocity [0,0,0];

	_ACE = if (isClass(configFile>>"CfgPatches">>"ace_main")) then{true}else{false};

	if (_ACE) then {
		if !(_this hasWeapon "ACE_ParachutePack") then {_this AddWeapon "ACE_ParachutePack"};
		WaitUntil {_this hasWeapon "ACE_ParachutePack"};
	}else{ 
		[_this] exec "ca\air2\halo\data\Scripts\HALO_init.sqs";//Free fall animation will be initiated locally here.
		Laviski_Call_PVEH = [_this,(compile "_this switchmove 'HaloFreeFall_non'")]; publicVariable "Laviski_Call_PVEH";//Braodcast animation globally
	};
	HintSilent "Don't forget to open your chute!";
	sleep 7;
	HintSilent "";
};
};
"Laviski_Call_PVEH" addPublicVariableEventHandler {((_this select 1) select 0) call ((_this select 1) select 1)};
//------------------------------//






//---------Server Only----------//
if (!isserver) exitWith {};

_veh = _this select 0;
_dly = _this select 1;

_HALO_units = [];
{if (_x != driver _veh) then {_HALO_units = _HALO_units + [_x]}} foreach crew _veh;
for "_i" from 0 to (count _HALO_units - 1) do {
_unit = _HALO_units select _i; 
if (local _unit) then {
	_unit call Laviski_HALO_fnc;
}else{Laviski_Call_PVEH = [_unit,Laviski_HALO_fnc]; publicVariable "Laviski_Call_PVEH"};
sleep _dly;
};
//------------------------------//

Edited by Kempco

Share this post


Link to post
Share on other sites

thank for reply.

but that makes them eject normally with chute opening straight away.

Share this post


Link to post
Share on other sites

You need to run most of the script on the client that is should be ejected:

//clientside.sqf
_veh = vehicle _this;
_this action ["eject", _veh];

// wait until the unit has ejected
waituntil {vehicle _this != _veh};
_this setvelocity [0,0,0];
[_this] exec "ca\air2\halo\data\Scripts\HALO_init.sqs";
hint "Don't forget to open your chute!";

private ["_veh", "_jump_delay"];
_veh = _this select 0;
_jump_delay = _this select 1;

{
if (_x != driver _veh) then //More reliable check
{
	// eject the unit using MP Framework from the Functions module (https://community.bistudio.com/wiki/Multiplayer_framework)
	 [nil, _x, "loc", rEXECVM, "clientside.sqf", _x] call RE;
	sleep _jump_delay;
};
} foreach crew _veh;

Edited by Deadfast

Share this post


Link to post
Share on other sites
I reworked the script for you. Give it a shot and let know how it goes (did not test).

input is the same: [vehicle name,delay] execVM "TheBelowScript.sqf";

//by Kempco

//------Clients and Server-----//
Laviski_HALO_fnc = {
_this spawn {//So I can use the same PVEH for both functions
	if (!local _this) exitWith {};
	_this action ["[color="#00FF00"]GetOut[/color]",vehicle _this];
	WaitUntil{_this == vehicle _this};
	_this setVelocity [0,0,0];

	_ACE = if (isClass(configFile>>"CfgPatches">>"ace_main")) then{true}else{false};

	if (_ACE) then {
		if !(_this hasWeapon "ACE_ParachutePack") then {_this AddWeapon "ACE_ParachutePack"};
		WaitUntil {_this hasWeapon "ACE_ParachutePack"};
	}else{ 
		[_this] exec "ca\air2\halo\data\Scripts\HALO_init.sqs";//Free fall animation will be initiated locally here.
		Laviski_Call_PVEH = [_this,(compile "_this switchmove 'HaloFreeFall_non'")]; publicVariable "Laviski_Call_PVEH";//Braodcast animation globally
	};
	HintSilent "Don't forget to open your chute!";
	sleep 7;
	HintSilent "";
};
};
"Laviski_Call_PVEH" addPublicVariableEventHandler {((_this select 1) select 0) call ((_this select 1) select 1)};
//------------------------------//






//---------Server Only----------//
if (!isserver) exitWith {};

_veh = _this select 0;
_dly = _this select 1;

_HALO_units = [];
{if (_x != driver _veh) then {_HALO_units = _HALO_units + [_x]}} foreach crew _veh;
for "_i" from 0 to (count _HALO_units - 1) do {
_unit = _HALO_units select _i; 
if (local _unit) then {
	_unit call Laviski_HALO_fnc;
}else{Laviski_Call_PVEH = [_unit,Laviski_HALO_fnc]; publicVariable "Laviski_Call_PVEH"};
sleep _dly;
};
//------------------------------//

You know what, try running the exact same code but instead of "Eject" use "GetOut" instead.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×