Jump to content
Sign in to follow this  
VanhA-ICON

Command line for script faulty

Recommended Posts

Could someone pinpoint what is the correct way to use this:

if ((isServer) && (crate == "USSpecialWeaponsBox")) then crate setVehicleInit "handle = [] execVM ""scripts\weaponcargo.sqf""";

The script does work on dedicated just fine but I'd like to get rid of this error in init.sqf

It gives ye olde "Type boolean..." error

Error position: <== "USSpecialWeaponsBox")) then crate se>
 Error ==: Type Bool, expected Number,String,Object,Side,Group,Text,Config entry,Display (dialog),Control,Team member,Task,Location

Here's the script if needed:

// Ammocrate script (exp) by VanhA

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

_vehicle = _this select 0;

_crate = _this select 1;

_mark = _this select 2;

_caller = _this select 3;

// ensure the car is stopped

// in only works with arrays. in _vehicle doesn't do anything as _vehicle is an object, so we use crew vehicle

if ((player in (crew _vehicle)) && (isEngineOn _vehicle)) exitWith {

hint "Turn off the engine";

};

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

// ensure there is someone in the car

if (!(player in (crew _vehicle))) exitWith {

hint "You need to get in first";

};

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

if ((_caller in (crew _vehicle)) && (_vehicle engineOn false)) then {sleep 1};

if (!isNull crate) then {

deleteVehicle crate;

crate = objNull;

publicVariable "crate";

// see below for the addPublicVariableEventHandler

// as addPublicVariableEventHandler will not fire on the client/server that has used publicVariable, the addAction must be added manually

my_car_action = the_car addAction ["Drop Crate","scripts\ammo.sqf"];

};

if (_caller != driver _vehicle) exitWith {};

_mark = format["%1Ammo.",(name player)];

// only delete the marker if it actually exists.

// non existing markers return [0,0,0] for their position

// and as we can't compare arrays we have to convert it to a string

if ("[0,0,0]" != format ["%1", markerPos _mark]) then {

deleteMarker _mark;

};

crate = "USSpecialWeaponsBox" createVehicle (position _vehicle);

// let's publicVariable the crate object over the network

// add a publicVariable Eventhandler on all other clients

//"crate" addPublicVariableEventHandler {

//if (isNull crate) then {

//removeAction my_car_action;

//} else {

//my_car_action = the_car addAction ["Drop Crate","scripts\ammo.sqf"];

//};

//};

publicVariable "crate";

_Offset = [1,0,0];

_worldPos = _RelObj modelToWorld _Offset;

_obj setPos _worldPos;

_pos = position crate;

_mssg = format["%1's Ammocrate.",(name player)];

_mark = createMarker [_mark, _pos];

_mark setMarkerShape "ICON";

_mark setMarkerType "mil_triangle";

_mark setMarkerColor "ColorYellow";

_mark setMarkerText _mssg;

_mark setMarkerSize [0.3, 0.3];

_mark setMarkerDir 45;

// now that part will only work for the caller

// all other players will have the standard ammo and weapons in the ammobox

// put that in an extra script, and then call it from within setVehicleInit

crate setVehicleInit "handle = [] execVM ""scripts\weaponcargo.sqf""";

processInitCommands;

// empty the crate first

clearMagazineCargo crate;

clearWeaponCargo crate;

//then add what you need

crate AddWeaponCargo ["M8_carbine", 4];

crate AddMagazineCargo ["30Rnd_556x45_G36", 160];

crate addWeaponCargo ["Binocular", 6];

crate addWeaponCargo ["NVGoggles", 6];

crate addWeaponCargo ["Mk_48", 2];

crate addMagazineCargo ["100Rnd_762x51_M240", 40];

crate addWeaponCargo ["SMAW", 2];

crate addMagazineCargo ["SMAW_HEAA", 8];

crate addMagazineCargo ["Mine", 10];

crate addMagazineCargo ["HandGrenade_West", 20];

crate addMagazineCargo ["SmokeShellRed", 20];

crate addWeaponCargo ["MetisLauncher", 1];

crate addMagazineCargo ["AT13", 1];

crate addWeaponCargo ["Stinger", 1];

crate addMagazineCargo ["Stinger", 1];

crate addWeaponCargo ["G36K", 10];

crate addWeaponCargo ["M9", 5];

crate addMagazineCargo ["15Rnd_9x19_M9", 30];

if (true) exitWith {};

This is from my "co27 Fall of Czernobog" mission and I'd like to fix this very badly

Share this post


Link to post
Share on other sites

Hello.

You need to check what type the crate is.

Like so:

((typeOf crate) == "USSpecialWeaponsBox")

i.e. you cannot compare an object with a string.

Hope this helps.

Share this post


Link to post
Share on other sites
Hello.

You need to check what type the crate is.

Like so:

((typeOf crate) == "USSpecialWeaponsBox")

i.e. you cannot compare an object with a string.

Hope this helps.

Thanks, but I tried all sorts of variations of that and it keeps giving

#typeOf

error with it

Share this post


Link to post
Share on other sites

Hm, I tried that and it worked.

I can't test this in Arma now, but the below code should run successfully.

if(isServer && ((typeOf crate) == "USSpecialWeaponsBox")) then{
   crate setVehicleInit "handle = [] execVM ""scripts\weaponcargo.sqf""";
};

Share this post


Link to post
Share on other sites
Hm, I tried that and it worked.

I can't test this in Arma now, but the below code should run successfully.

if(isServer && ((typeOf crate) == "USSpecialWeaponsBox")) then{
   crate setVehicleInit "handle = [] execVM ""scripts\weaponcargo.sqf""";
};

aah, I'll have to retry that. As I had

if((isServer) && ((typeOf crate)

The reason it works in mission even with that flaw is that I have a class defined addAction for humvees to drop the ammocrate.

This command line is simply to ensure for all clients to see the same cargo as it is modified with a different script to empty the box and refill it with custom weapons.

Share this post


Link to post
Share on other sites
Hi.

Did you get a chance of testing this further?

Hi. I've been busy but yes, managed to try it out.

Still giving the

#typeOf

error.

It's very hard to identify it. This command line's only purpose is to give other clients the same content in the crate as the player who dropped the crate from humvee sees.

:confused:

The odd thing is that it does work regardless.... if only I could get rid of this error. Otherwise I'll end up removing the script all together

Share this post


Link to post
Share on other sites

Hm, strange.

If you want you can PM me the mission and I can have a look at it.

It's hard to get a clear view of what you want to achieve or how the script will run and in which context.

Share this post


Link to post
Share on other sites
Hi. I've been busy but yes, managed to try it out.

Still giving the

#typeOf

error.

It's very hard to identify it. This command line's only purpose is to give other clients the same content in the crate as the player who dropped the crate from humvee sees.

:confused:

The odd thing is that it does work regardless.... if only I could get rid of this error. Otherwise I'll end up removing the script all together

try to set typeOf crate in a variable

_tcrate = "";

_tcrate = typeOf crate;

if(isServer && (_tcrate == "USSpecialWeaponsBox")) then{

crate setVehicleInit "handle = [] execVM ""scripts\weaponcargo.sqf""";

};

maybe u must do than too: _tcrate = toUpper(_tcrate)

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  

×