Jump to content
Sign in to follow this  
Donnie_Plays

HELP NEEDED - Autorun for server

Recommended Posts

I am using an autorun script that I found here on the forums. I can get this script to work no problem playing locally hosted MP games with friends, but I cannot get this to work for players on a server. It seems like it should run locally, but the autorun only works in local hosted by executing the sqf in Init.sqf like this...

Init.sqf

[player] execVM "autorun.sqf";

autorun.sqf

(findDisplay 46) displayAddEventHandler ["KeyDown", {
    if (_this select 1 == (actionKeys 'User9') select 0) then {
		if (isNil "AR_active") then {AR_active = false};
 		if (AR_active) exitWith {AR_active = false};
		if (!isNull objectParent player) exitWith {};
		if (surfaceIsWater (getPos player)) exitWith {};

		AR_active = true;
		AR_weapon = currentWeapon player;
		AR_animation = switch (true) do {
			case (AR_weapon isEqualTo ""): {"AmovPercMevaSnonWnonDf"};
			case (AR_weapon isEqualTo (handgunWeapon player)): {"AmovPercMevaSlowWpstDf"};
			case (AR_weapon isEqualTo (primaryWeapon player)): {"AmovPercMevaSlowWrflDf"};
			case (AR_weapon isEqualTo (secondaryWeapon player)): {"AmovPercMevaSlowWlnrDf"};
		};
		player addEventHandler ["AnimDone", {
			if ((!AR_active) || {!((currentWeapon player) isEqualTo AR_weapon)} ||
			{!isNull objectParent player} || {surfaceIsWater (getPos player)} ||
			{_this select 1 == AR_animation && speed (vehicle player) <= 0}) exitWith {
				player removeEventHandler ["AnimDone", _thisEventHandler];
				AR_active = false;
				AR_weapon = nil;
				AR_animation = nil;
			};
			player playMoveNow AR_animation;
		}];
		player playMoveNow AR_animation;
	};
}];

// Stop running
(findDisplay 46) displayAddEventHandler ["KeyDown", {
	if (_this select 1 != (actionKeys 'User9') select 0) then {
		if (AR_active) then {AR_active = false};
	};
}];

I have tried executing this autorun.sqf file several ways on my server but it just will not work. Any ideas? I know about Cypress Autorun, but I'm trying to avoid using it, if possible. I strongly prefer this specific code, if I can get it working on the server. It works like a charm in MP hosted.

Share this post


Link to post
Share on other sites

I don't do any server stuff, but maybe try changing init.sqf to :

initPlayerServer.sqf

Share this post


Link to post
Share on other sites
13 hours ago, Von Quest said:

I don't do any server stuff, but maybe try changing init.sqf to :

initPlayerServer.sqf


I just tried this and it does not work, still. I have tried multiple ways to get this to work. I do not understand why it works in MP hosted but not on a server. There has to be something I'm missing.

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  

×