Jump to content
  • 0

[Help] Working on Custom Script - Get this Error


MatthewK

Question

Can anyone tell me what is going wrong here, please :)

 

 

Original Script (Adapted from another source):

//Original Script By [MIC] Murcielago

_n = 0;

While {True} Do 
{

//LINE 9 Below
If (((Vehicle Player) Distance (NearestObject[Player,"HeliHEmpty"]) < 7) And (Damage (NearestObject[Player,"HeliHEmpty"]) < 1) ) Then {Player Setdamage 1;};

If ( ((Vehicle Player) Distance (NearestObject[Player,"HeliHEmpty"]) > 7) And (Player Distance (NearestObject[Player,"HeliHEmpty"]) < 20) And (_n == 0) And (Damage (NearestObject[Player,"HeliHEmpty"]) < 1) ) Then {TitleText ["\n\n\n" + Localize "STR_Limited_Area_Warning","PLAIN"];};

Sleep 0.05;

//Line 15 Below
If ( ((Vehicle Player) Distance (NearestObject[Player,"HeliHEmpty"]) < 20)  And (Damage (NearestObject[Player,"HeliHEmpty"]) < 1) ) Then {_n = _n + 0.05;};

If ( _n > 1 ) Then {_n = 0;};

};

Error Log:

If (((Vehicle Player) Distance (NearestObject[Player,"HeliHEmpty"]) < 7)>
18:57:39 Error position: <NearestObject[Player,"HeliHEmpty"]) < 7)>
18:57:39 Error Type Object, expected Number
18:57:39 File Restricted_Area.sqf, line 9
18:57:39 Bad conversion: array
18:57:39 Bad conversion: array
18:57:39 Error in expression <0.05;

If ( ((Vehicle Player) Distance (NearestObject[Player,"HeliHEmpty"]) < 20>
18:57:39 Error position: <NearestObject[Player,"HeliHEmpty"]) < 20>
18:57:39 Error Type Object, expected Number
18:57:39 File Restricted_Area.sqf, line 15
18:57:39 Bad conversion: array
18:57:39 Bad conversion: array
18:57:39 Bad conversion: array
18:57:39 Bad conversion: array
18:57:39 Bad conversion: array
18:57:39 Error in expression < Do 
{
Link to comment
Share on other sites

16 answers to this question

Recommended Posts

  • 0

Ok,

 

Have rewritten it.  Cant test it from where I am but give it a go.

 

The script now

  • Checks for alive "HeliHEmpty"s within the warning range (rather than trying to find one in the whole map). 
  • Only if any are found it then checks if any are alive.
  • If an alive heli is within range it checks if the player is in the warning or death zone and either kills them or warns them every second.
  • Warning and death ranges are now variables for easy fine turning.
  • Variables are defined and initalised.
Private ["_n","_nearbyHeliEmpty","_aliveNearbyHeliEmpty","_vehiclePlayer","_nearestHeliEmpty","_warningRange","_deathRange"];

_n = 0;
_warningRange = 20;
_deathRange = 7;

While {True} Do 
{
	_nearbyHeliEmpty = [];	
	_aliveNearbyHeliEmpty = [];	
	_nearestHeliEmpty = "";	
	_vehiclePlayer = Vehicle Player;	
	
	_nearbyHeliEmpty = nearestObjects [_vehiclePlayer, ["HeliHEmpty"], _warningRange];
	if ((count _nearbyHeliEmpty) > 1) then {
		{
			if (alive _x) then { 
				_aliveNearbyHeliEmpty set [(count _aliveNearbyHeliEmpty),_x]; 
			}; 
		}count _nearbyHeliEmpty;
		if ((count _aliveNearbyHeliEmpty) > 1) then{
			_nearestHeliEmpty = _aliveNearbyHeliEmpty select 0;
			If ((_vehiclePlayer Distance _nearestHeliEmpty) < _deathRange) Then {Player Setdamage 1;};
			If ((_n == 0) && {_vehiclePlayer Distance _nearestHeliEmpty  >= _deathRange}) Then {
				TitleText ["\n\n\n" + Localize "STR_Limited_Area_Warning","PLAIN"];
			};
			_n = _n + 0.05;
		};
	};
	Sleep 0.05;
	If ( _n > 1 ) Then {
		_n = 0;
	};
};

Let me know if you get any errors and I will have a quick look.

Link to comment
Share on other sites

  • 0

Wow, Muchc cleaner.. Thanks.. I get this error now though: 

_nearbyHeliEmpty = nearestObjects [_vehiclePlayer, ["HeliHE>
17:28:58 Error position: <nearestObjects [_vehiclePlayer, ["HeliHE>
17:28:58 Error 0 elements provided, 3 expected
17:28:58 File Restricted_Area.sqf, line 14
17:28:59 Bad conversion: array
17:28:59 Error in expression < = Vehicle Player;	
Link to comment
Share on other sites

  • 0

Try changing

	_vehiclePlayer = Vehicle Player;

to

	_vehiclePlayer = (Vehicle Player);

It runs on my test server without an error although I am only testing to see if it runs rather than functionality.  I did not test the original way so have not verified the error.

 

Give it a go.

Link to comment
Share on other sites

  • 0

Same old I'm afraid. It's been bugging me for days now, probably best accept its an arma thing!! :(

_nearbyHeliEmpty = nearestObjects [_vehiclePlayer, ["HeliHE>
1:17:31 Error position: <nearestObjects [_vehiclePlayer, ["HeliHE>
1:17:31 Error 0 elements provided, 3 expected
1:17:31 File Restricted_Area.sqf, line 14
1:17:31 Bad conversion: array
1:17:31 Error in expression < (Vehicle Player);	
Link to comment
Share on other sites

  • 0

 

Same old I'm afraid. It's been bugging me for days now, probably best accept its an arma thing!! :(

_nearbyHeliEmpty = nearestObjects [_vehiclePlayer, ["HeliHE>
1:17:31 Error position: <nearestObjects [_vehiclePlayer, ["HeliHE>
1:17:31 Error 0 elements provided, 3 expected
1:17:31 File Restricted_Area.sqf, line 14
1:17:31 Bad conversion: array
1:17:31 Error in expression < (Vehicle Player);	

 

 

I think its just not accepting the syntax of: 

 _nearbyHeliEmpty = nearestObjects [_vehiclePlayer, ["HeliHEmpty"], _warningRange];

I personally dont know how to fix it, but i have noticed in my practice that from time to time depending on what you are making, replacing a command with a local variable like here:

_vehiclePlayer = Vehicle Player;

causes some issues, and other times it works flawless. The issue may even be that you used _vehiclePlayer as the variable. I have read in the wiki that naming your variables with like names of global variables and arma commands can cause some confusion in the game engine.

 

 

On a side note, i have seen a similar script, maybe poke around for it and you'll find what your missing.  I think it worked off of a plotpole, may be as simple as changing a classname. Wish i had some better input. Good luck! 

Link to comment
Share on other sites

  • 0

Ok,

 

Fully working code with the item to put the protection on as a variable.

// Ring of protection by RimBlock (http://epochmod.com/forum/index.php?/user/12612-rimblock/)
//
// This script will allow you to set two rings around an object (vehicle, building, player).  The first ring will create a warning, the second will kill the player.
// 
// Completely rewritten from initial code by [MIC] Murcielago.

Private ["_n","_classnameProtected","_nearbyProtected","_vehiclePlayer","_nearestProtected","_warningRange","_deathRange","_nearbyProtected","_aliveNearbyProtected"];

_n = 0;
_warningRange = 20;
_deathRange = 7;
_classnameProtected = "Wooden_shed_DZ";

While {True} Do 
{
	_nearbyProtected = [];	
	_aliveNearbyProtected = [];	
	_nearestProtected = "";	
	_vehiclePlayer = (Vehicle Player);	
	_nearbyProtected = nearestObjects [_vehiclePlayer, [_classnameProtected], _warningRange];
	if ((count _nearbyProtected) >= 1) then {
		{
			if (alive _x) then { 
				_aliveNearbyProtected set [(count _aliveNearbyProtected),_x]; 
			}; 
		}count _nearbyProtected;
		if ((count _aliveNearbyProtected) >= 1) then{
			_nearestProtected = _aliveNearbyProtected select 0;
			If ((_vehiclePlayer Distance _nearestProtected) < _deathRange) Then {Player Setdamage 1;};
			If ((_n == 0) && {_vehiclePlayer Distance _nearestProtected  >= _deathRange}) Then {
				TitleText ["[WARNING]: Entering restricted area.  Continuing will result in death.","PLAIN"];
			};
			_n = _n + 0.05;
		};
	};
	Sleep 0.05;
	If ( _n > 1 ) Then {
		_n = 0;
	};
};

Put the following in the compiles.sqf

ringOfProtection =					compile preprocessFileLineNumbers "[File path and name]";	

Call it (probably from the init.sqf)  after the line "_playerMonitor = ..." with

[] spawn ringOfProtection;

Note this is likely to have at least a small impact on each player.

Link to comment
Share on other sites

  • 0

Just posted it as a release in the mods forum.  

 

Make sure you change the classname to be protected or sheds will be troublesome  ;) .

 

@oSoDirty.

Funnily enough I have added it to a plot pole in order to turn it on, troubleshoot and test it  :) .

Link to comment
Share on other sites

  • 0

Lol... I appreciate your efforts dood and I think its just my machine maybe , but its still not working..

I've done what you said, followed the instructions step by step and even had my mate check them over, but I get this now:

15:09:05 Error position: <nearestObjects [_vehiclePlayer, [_classn>
15:09:05 Error 0 elements provided, 3 expected
15:09:05 File Restricted_Area.sqf, line 14
15:09:05 Bad conversion: array
15:09:05 Error in expression <= (Vehicle Player);
Link to comment
Share on other sites

  • 0

I'm no expert, so I could be wrong but, why is it like this [_classnameProtected] ? Shouldn't that one not have brackets, as I have it below?

 

_nearbyProtected = nearestObjects [_vehiclePlayer, _classnameProtected, _warningRange];

 

It's an array, so it needs to be inside brackets. Your way breaks the code altogether and the user doesn't even get a warning , let alone die.. I tried it ;)

Link to comment
Share on other sites

  • 0

Nearestobjects uses an array.  NearestObject uses an item.

 

 

Lol... I appreciate your efforts dood and I think its just my machine maybe , but its still not working..

I've done what you said, followed the instructions step by step and even had my mate check them over, but I get this now:

15:09:05 Error position: <nearestObjects [_vehiclePlayer, [_classn>
15:09:05 Error 0 elements provided, 3 expected
15:09:05 File Restricted_Area.sqf, line 14
15:09:05 Bad conversion: array
15:09:05 Error in expression <= (Vehicle Player);

 

You in a vehicle ?.  If so then try outside of a vehicle.

Link to comment
Share on other sites

  • 0

can you please post your whole RPT file (in spoiler tags or via pastebin etc) plus the actual .sqf file you are using (i.e with your own classname changed).

 

I am also assuming you are running the Windows version rather than Linux.  Is this correct ?.

Link to comment
Share on other sites

  • 0

I am starting to think something is truly wrong with nearestObjects.  I am using it to detect a plot pole within 50m and strangely the script works awesome.  But kicks out a RPT error every time the code gets ran which results in HUGE RPT files that no one can read with all the spam.

 

I tried switching the code up to count with nearObjects only to get the same result.

 

Array conversion errors with:

 

error: 0 elements provided, 3 expected

Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...