Jump to content
kromka

Access from init.sqf

Recommended Posts

But nobody jumped out. You probably think about parachute. But this is cargo drop generated by script. It has nothing to do with crew or chopper.

Share this post


Link to post
Share on other sites

Try to debug it and know if the chopper considers the first waypoint reached.

 

Dropping the cargo don't prooves it, as it's code is waypoint independent.

 

Because maybe your chopper is still trying to reach his first waypoint.

Share this post


Link to post
Share on other sites

@barbolani

Chopper definitely reach first WP.

To check it i use script distance2D and additionally

expectedDestination

When chopper reaches first WP coordinates of second WP are hinted properly until he arrives border of airfield.

Only objects placed there are waypoints of another vehicles. But "expectedDestination" shows that choppers 2 WP in this moment are changed to some other values (always the same).

Is it possible WP of one unit may interfers with other unit?

Share this post


Link to post
Share on other sites

Could it be detecting the enemy units and deciding to flee rather than engage or ignore.

 

you could try making them dumber

{
_x disableAI "FSM";
_x disableAI "target";
_x disableAI "autotarget";
_x allowfleeing 0;
} foreach crew vehiclename;

.

Share this post


Link to post
Share on other sites

YES

You are god of scripting :)

It solves problem of changing course. Althought i am not sure why "civilian" retreats from east. But i will check it.

Share this post


Link to post
Share on other sites

Oh yes, I had the same problem long time ago for fastroping.

 

In Arma engine civvies dislike CSAT, can't remember the technical Word for that.

Share this post


Link to post
Share on other sites

_x disableAI "FSM";

is not necessary because at some point it cause chopper just stops.

It has still the same WP, but it doesn't fly forward anymore just hangs.
 

Share this post


Link to post
Share on other sites

strange it should only disable the danger routine, but being Arma strange things happen all the time.

 

I found flyinheight was having the same effect now and again.

Share this post


Link to post
Share on other sites

Unfortunately I have another question.

In MP I've placed couple of players.

I want to add this selectable respawn menu. I know how to do it, i know how to prevent of choosing respawn first time, but I don't know how to make user don't appear in any respawn point but one the position which has been placed in editor.

Is it possible? Maybe there is other approach?

Regards.

Share this post


Link to post
Share on other sites

Long time gone...

Quiet obvious (probably) problem:

 

init.sqf:

/***** PLAYERS *****/
slots = [slot, slot_1, slot_2, slot_3, slot_4, slot_5];
_handle = [slots] execVM "scripts\cleanNonFilledSlots.sqf";
waitUntil {scriptDone _handle};

gMasters = [gm_czarny];
{
	_x addBackpack "tf_rt1523g";
	_x addCuratorEditableObjects [vehicles,true];
	_x addCuratorEditableObjects [(allMissionObjects "Man"), false];
	_x addCuratorEditableObjects [(allMissionObjects "Air"), true];
	_x addCuratorEditableObjects [(allMissionObjects "Ammo"), false];
} forEach [zeus_czarny];

players = allPlayers;
{
	null = [[_x], "guer"] execVM "scripts\setObjSide.sqf";
} forEach players;

null = [fiaWeaponCrate, count allPlayers] execVM "scripts_specific\addFiaStuffToCrate.sqf";

if (isNil "jammingStarted") then 
{
	jammingStarted = false;
};

addFiaStuffToCrate.sqf:

	private ["_crate", "_howManyPlayers"];
	_crate = _this select 0;
	_howManyPlayers = 5;

	clearWeaponCargo _crate;
	clearItemCargo _crate;
	clearBackpackCargo _crate;
	clearMagazineCargo _crate;

	// clothes and containters

	// items
	_crate addItemCargo ["FirstAidKit", _howManyPlayers];
	_crate addItemCargo ["ItemMap", _howManyPlayers];
	_crate addItemCargo ["ItemCompass", _howManyPlayers];
	_crate addItemCargo ["ItemWatch", _howManyPlayers];
	_crate addItemCargo ["ItemRadio", _howManyPlayers];
	_crate addItemCargo ["Medikit", 1];
	_crate addItemCargo ["ToolKit", 1];
	_crate addItemCargo ["tf_anprc152_2", _howManyPlayers];

Problem is any player sees modified crate on dedicated server. I've tries every configuration with isServer. I also added line

null = [fiaWeaponCrate, count allPlayers] execVM "scripts_specific\addFiaStuffToCrate.sqf";

to initPlayerLocal. And nothing. I ran mission on dedicated and on local server (from eden) when I ran it from eden only me can use modified crate.

Help.

Share this post


Link to post
Share on other sites

You should use global command to add stuff to the box otherwise

changes  will be only visible for that client where script executed

	params ["_crate", ["_howManyPlayers",5]];

	clearWeaponCargoGlobal _crate;
	clearItemCargoGlobal _crate;
	clearBackpackCargoGlobal _crate;
	clearMagazineCargoGlobal _crate;

	// clothes and containters

	// items
	_crate addItemCargoGlobal ["FirstAidKit", _howManyPlayers];
	_crate addItemCargoGlobal ["ItemMap", _howManyPlayers];
	_crate addItemCargoGlobal ["ItemCompass", _howManyPlayers];
	_crate addItemCargoGlobal ["ItemWatch", _howManyPlayers];
	_crate addItemCargoGlobal ["ItemRadio", _howManyPlayers];
	_crate addItemCargoGlobal ["Medikit", 1];
	_crate addItemCargoGlobal ["ToolKit", 1];
	_crate addItemCargoGlobal ["tf_anprc152_2", _howManyPlayers];

Pozdrawiam..

Share this post


Link to post
Share on other sites

Maaan, it works. Thank you!

I need to check what is the purpose of adding non-global stuff. I am really curious.

Regards

Share this post


Link to post
Share on other sites

Is any difference if I will initialize variable _var with "1" (integer) or "1.0" (float)?

 

_var = 1

 

or

 

_var = 1.0

Share this post


Link to post
Share on other sites

Place this in debug console in watch section and find out yourself

_var1= 1; _var2= 1.0; _var1 isEqualTo _var2

Share this post


Link to post
Share on other sites

I see "true".

I've read somewhere that every Number in scripts is float, but I see it isn't mandatory to use always x.x format.

I tried o find any info about it on https://community.bistudio.com/wikibut it is quiet hard, but it seems there is some implicit conversion to float. Am I right?

Share this post


Link to post
Share on other sites

Hi. After long time I need help once again.

 

I create in init.sqf some variable:

varA = objNull;

In onPlayerRespawn.sqf I use it and pass to script:

[varA] exeVM "myScript.sqf"

In myScript.sqf I do something like this (if teleportTarget is already created:

hint format["%1", _this select 0];
teleportTarget = _this select 0;

fnc_addTeleport=
{
    private _placePosition = ((getPosATL player) findEmptyPosition [1, 5, "Flag_Green_F"]);
    if(count _placePosition == 3) then
    {
        teleportTarget = "Flag_Green_F" createVehicle _placePosition;
        if(player == sideLeader) then
        {    
            player removeAction idActionAddTeleport;
            idActionRemoveTeleport = player addAction actionRemoveTeleport;
        };
        idActionTeleport = player addAction actionTeleport;
    };
};

........... some piece of code ..............

if(teleportTarget isEqualTo objNull) then
{
    if(player == sideLeader) then
    {
        idActionAddTeleport = player addAction actionAddTeleport;
    };
}
else
{
	if(player == sideLeader) then 
	{
		player removeAction idActionRemoveTeleport;
		idActionRemoveTeleport = player addAction actionRemoveTeleport;
	};
	idActionTeleport = player addAction actionTeleport;
};

Problem is whenever I call myScript.sqf teleportTarget is always null.

I expect it shouldn't be null. I read that local vars are nullfied after script, but teleportTarget is global one. On the other side I can't do something like (_this select 0) = something. I recieve then some error.

I would like to recieve something called in C++ "passing by reference" (variable state is remembered after exit of function). How to solve this?

Share this post


Link to post
Share on other sites
19 minutes ago, kromka said:

varA = objNull;

 

19 minutes ago, kromka said:

[varA] exeVM "myScript.sqf"


since varA is always objNull, it is quite logical your 
 

20 minutes ago, kromka said:

teleportTarget = _this select 0;


will also always be objNull

Share this post


Link to post
Share on other sites

init.sqf is done only once on the beginning of the mission.

 

Then if it is null, player who is sideLeader

if(teleportTarget isEqualTo objNull) then 
{
	if(player == sideLeader) then 
	{ idActionAddTeleport = player addAction actionAddTeleport; }; 
}

has possibility to create an object which is assigned to teleportTarget

fnc_addTeleport=
{
    private _placePosition = ((getPosATL player) findEmptyPosition [1, 5, "Flag_Green_F"]);
    if(count _placePosition == 3) then
    {
        teleportTarget = "Flag_Green_F" createVehicle _placePosition;		//here is creation
        if(player == sideLeader) then
        {    
            player removeAction idActionAddTeleport;
            idActionRemoveTeleport = player addAction actionRemoveTeleport;
        };
        idActionTeleport = player addAction actionTeleport;
    };
};

Now teleportTarget is not a null. And I would like to do somehow varA assigned to teleportTarget also should contain element "Flag_Green_F".

 

I would like to do something like this:

C++ code

int main()
{
    int a = 3;
    someFunc(a);
    //now "a" is 4 not 3 because "a" was send to someFunc as a reference
    return 0;
}

void someFunc(int& param)
{
    param++;
}

Sorry for other language code but it explain exactly what i would like to achieve.

Share this post


Link to post
Share on other sites

sideLeader is not a command, so if it is undefined your code that is followed will be ignored. Also will possibly throw undefined error. You do have errors enabled, right?

 

if you want to pass something by reference, put it in array and then modify array with set command

  • Like 1

Share this post


Link to post
Share on other sites

I dont have any errors. sideLeader is in

........... some piece of code ..............

which I've omitted to simplify this example. My apologies if this misleaded you.

I will check this passing using array. It may solve all my problems.

Share this post


Link to post
Share on other sites

@killzone_kid

Thank you. Your suggestion about array works just like i needed.

Now I see something very weird. When I run mission as MP in Eden, I can place and remove object as expected, but after respawn (from menu) when I point on my body, menu action is multiplied? When I move head to other direction this multiplication dissapears.

Why?

This is package with the whole script. It is rather simple one: it just adds to the leader possibility to add/remove teleport mast (green flag) and to all players possibility to teleport from red flag to this mast.

teleportToFlag

Share this post


Link to post
Share on other sites

I can’t see the code, but if you added action to player it will not magically get removed just because you died, so when you look at your body it will show it to you. Add removeAllActions corpse on respawn or on death

Share this post


Link to post
Share on other sites

I don't know why Dropbox prevents displaing content. Anyway it is downloadable.

Earlier I've tried to remove all actions but it changes nothing.

I've add to first line of onPlayerRespawn.sqf "removeAllActions player;" (script is called on secong line) but it also changes nothing.

 

How it is even possible to see menu from my corpse because of watching at it? Is it intentional or is it bug?

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

×