Forum Jump :

Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#1 Posted at 2014-11-18 16:03        
     
OK thanks to all the Help from the ArmaHolic Community was able to find the answer to my problem.

Scripts that work in Single player and break in MP is normally due to a script being or having Local effect when it needs to be Global.

Some links below will help you trouble shoot the problem.

Bis wiki on BIS_fnc_MP
BIS wiki on addactions
BIS wiki on Multiplayer Scripting
ArmaHolic Page on Making Scripts work on Dedicated server
KillzoneKid explains addActions scripts/commands

Special Thanks to
Tajin
Spencer42
654wak654
BrotherhoodOfHam

for all the help with my question


This post was edited by shadowmarine578 (2014-12-21 16:07, 1030 days ago)


Author Message


Posts: 69
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age: 23
In-game name: Mr. Ryan

 
#2 Posted at 2014-11-18 16:22        
     
Well about half of the time you've used it, you've spelt it Reniforcements which isn't your problem but it could become one if you were to reference any of these later on, so just go through and check all of them *THUMBS UP*

When you say it won't work; Are you hosting it or running dedicated, and are the addAction's appearing at all?

If I've helped you out, or you like my missions, consider donating, however small :-) PayPal Donations. Or check out My Wordpress Site for my content!

Advertisement


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#3 Posted at 2014-11-18 16:52        
     
Before going into detail.:

Look at the different parts of your script and think about where it has to run.

Placing the markers for example.
It won't go well if you let every player do that. So how are you planning to decide who gets to do it?



In general, its best to run all code that defines the flow of the mission only on the server and from there send/receive data to/from the clients.


Scripting it isn't that hard, the BIS_fnc_MP function happily does most of the work for you. Its more important to get the logic right first.

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.

Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#4 Posted at 2014-11-18 17:19        
     
@Tajin
Well i was just using an addAction placed on an object at main base so if a player was there and heard his team mates were requesting the support he could go to the object and call the scripts from the addAction command on it it removes the addActon and goes in order so at any given time the place marker script can only be fired once per rotation.

so if i used the first addAction to place the markers the next addAction i would get would be to call in the reinforcements after that it would be the clean up script addaction then it just loops from there.

@spencer42
all the addActions appear like they should the markers are created literally the only thing that breaks is the unit spawn script, and its being tested in MP on a Dedicated server so i want to make sure the scripts are being fired on server side like Tajin said but that seams to be where i am dropping the ball and no units are being spawned at all. but if i place the same script i use to spawn the units in just a trigger out side of the script being called it works fine

ive tryed isServer, isDedicated, BIS_fnc_MP and even none of those commands with the fear the script would fire x times the amount of people in game but cant seam to pin down why the script stops working in MP.

the below is one of the scripts i was useing to spawn the units

_Helicrew1 = [];
_SupportHeli1 = [];
_SupportGroup1 = [];

if (isDedicated) then {

_Helicrew1 = creategroup WEST; 
_SupportHeli1 = [getMarkerPos "mkr_Set_Reniforcements_Spawn", 140, "B_Heli_Transport_01_F", _Helicrew1] call BIS_fnc_spawnVehicle;

_wp1 = _Helicrew1 addWaypoint [(getmarkerpos "mkr_Set_Reniforcements_LZ"), 0];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "FULL";

_wp2 = _Helicrew1 addWaypoint [(getmarkerpos "mkr_Set_Reniforcements_LZ"), 0];
_wp2 setWaypointType "TR UNLOAD";
_wp2 setWaypointSpeed "LIMITED";
_wp2 setwaypointstatements ["this land 'land'"];

_wp3 = _Helicrew1 addWaypoint [(getmarkerpos "mkr_Set_Reniforcements_Spawn"), 0];
_wp3 setWaypointType "CYCLE";
_wp3 setWaypointSpeed "FULL";

_wp4 = _Helicrew1 addWaypoint [(getmarkerpos "mkr_Set_Reniforcements_Spawn"), 0];
_wp4 setWaypointType "CYCLE";
_wp4 setWaypointSpeed "FULL";

_SupportGroup1 = [getmarkerpos "mkr_Set_Reniforcements_Spawn", WEST, ["B_soldier_AR_F","B_soldier_AR_F","B_so­ldier_AR_F","B_soldier_AR_F"],[],[],[],[­],[],180] call BIS_fnc_spawnGroup;
_wp1a = _SupportGroup1 addWaypoint [getmarkerpos "mkr_Set_Reniforcements_Reinforce_Point", 0];

sleep .5;
_SupportGroup1 = _SupportGroup;
{ _x assignAsCargo (_SupportHeli1 select 0); _x moveIncargo (_SupportHeli1 select 0);} foreach units _SupportGroup1;
};

This post was edited by shadowmarine578 (2014-11-18 17:43, 1063 days ago)


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#5 Posted at 2014-11-18 20:57        
     
https://community.bistudio.com/wiki/BIS_fnc_MP <-- Familiarize youself with that.

It works best when you write functions (or load scripts as functions). You can then directly call them with bis_fnc_mp.


As far as addActions are concerned: https://community.bistudio.com/wiki/addAction
Check out the "condition" parameter. Utilize that and you can easily hide/show your action without having to remove/restore them. The parameter can be a script that returns true/false or simply a variable. Very useful for MP.



Now about your spawn-units script. This is why it doesn't work:

1. When someone used an addAction, that code is ONLY run on his machine.
2. You have an "isDedicated" check in your script.
... combine the two and you get... nothing!

You could either go the quick and dirty way and simply remove the "isDedicated" check. You don't risk having the script executed several times at once (as can happen with triggers) since only the client who uses the action will run the script. However, its better to keep AI on serverside wherever possible.


So I suggest you put a BIS_fnc_MP call in your action and use that to execute the script directly on the server.
In case you didn't know:
You can put code directly into the addAction, you don't have to exec a scriptfile with it.


Check out these two blogposts from KillzoneKid about addActions, he nicely demonstrates just how powerful and flexible that command really is:
http://killzonekid.com/arma-scripting-tutorials-addaction-quirks/
http://killzonekid.com/arma-scripting-tutorials-addaction-quirks-v2/

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.

Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#6 Posted at 2014-11-19 02:32        
     
# Tajin : https://community.bistudio.com/wiki/BIS_fnc_MP <-- Familiarize youself with that.

It works best when you write functions (or load scripts as functions). You can then directly call them with bis_fnc_mp.


As far as addActions are concerned: https://community.bistudio.com/wiki/addAction
Check out the "condition" parameter. Utilize that and you can easily hide/show your action without having to remove/restore them. The parameter can be a script that returns true/false or simply a variable. Very useful for MP.



Now about your spawn-units script. This is why it doesn't work:

1. When someone used an addAction, that code is ONLY run on his machine.
2. You have an "isDedicated" check in your script.
... combine the two and you get... nothing!

You could either go the quick and dirty way and simply remove the "isDedicated" check. You don't risk having the script executed several times at once (as can happen with triggers) since only the client who uses the action will run the script. However, its better to keep AI on serverside wherever possible.


So I suggest you put a BIS_fnc_MP call in your action and use that to execute the script directly on the server.
In case you didn't know:
You can put code directly into the addAction, you don't have to exec a scriptfile with it.


Check out these two blogposts from KillzoneKid about addActions, he nicely demonstrates just how powerful and flexible that command really is:
http://killzonekid.com/arma-scripting-tutorials-addaction-quirks/
http://killzonekid.com/arma-scripting-tutorials-addaction-quirks-v2/

Tajin you sir are the man! I will get started on trying out what you gave me and will post what i did in a few if i get it working.

so u mean calling the addAction like this?
MDT1_PlaceMarkers = MDT1 addAction ["<t color='#68ccf6'>Place your Reinforcements LZ and OBJ</t>",{["MDT\Reinforcements\MDT1\MDT1_PlaceMarkers.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];

This post was edited by shadowmarine578 (2014-11-19 03:14, 1063 days ago)


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#7 Posted at 2014-11-19 14:39        
     
Yeh, using execVM with fnc_MP would also work.
Personally, I'd rather do it with a function, but thats up to you.

However, I'd recommend including a condition, as seen here:
MDT1_PlaceMarkers_act = MDT1 addAction [
    "<t color='#68ccf6'>Place your Reinforcements LZ and OBJ</t>",
    {
        [[],"MDT1_PlaceMarkers",true,true] spawn BIS_fnc_MP;
    },
    "",
    -5,
    false,
    false,
    "",
    '
        MDT1_PlaceMarkers_available
    '
];

This way you can simply change the variable "MDT1_PlaceMarkers
_available" to true or false and use publicVariable on it, to show/hide the action on all clients.

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.

Author Message


Posts: 105
Rank:


Level: Member

Country: us
Location:
Occupation: Marine
Age:
In-game name: shadowmarine578

 
#8 Posted at 2014-11-20 21:13        
     
SWEET!!!!!!!!!!!! i got it working ill post the code in a few but i did see one problem with it when it opens the map for the player it opens it for every one how would i call it to only open the map of the person calling the script?

Added 8 minutes later:

ok this is what i did a quick down and dirty of it anyway

first i made a script called FNC_MDT_addActionScripts.sqf
																	/*Shadowmarine578's MDT*/
																   /*Mission Define Terminal*/
/*
this is a simple but powerful script that calls on Functions to preform actions
MDT1 is the name of the laptop in the base if you want your player to have the addActions on a playable charter all u need to do is name your unit MDT1 or copy and past the
code below and place the name of your unit.

EX: MDT1 addAction ["<t color='#68ccf6'>Place your Reinforcements LZ and OBJ</t>",{["Functions\FNC_PlaceMarkers.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];
YourUnitNameHere addAction ["<t color='#68ccf6'>Place your Reinforcements LZ and OBJ</t>",{["Functions\FNC_PlaceMarkers.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];
and your done! :) just remember you dont want to have all the functions on one player other wise you will have tuns of them.

*/
if (isNil "missionStatus") then
{
/*Request BLUFOR Reinforcements*/
MDT1 addAction ["<t color='#68ccf6'>Place your Reinforcements LZ and OBJ</t>",{["Functions\Call_For_Reinforcements\FNC_PlaceMarkers.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];
MDT1 addAction ["<t color='#68ccf6'>call in Reinforcements</t>",{["Functions\Call_For_Reinforcements\FNC_CallReinforcements.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];
MDT1 addAction ["<t color='#B40404'>Delete Reinforcements</t>",{["Functions\Call_For_Reinforcements\FNC_RemoveALL.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];

/*Spawn OPFOR*/
MDT1 addAction ["<t color='#B40404'>Place OPFOR Units</t>",{["Functions\Spawn_OPFOR\FNC_SpawnOPFOR.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];
MDT1 addAction ["<t color='#B40404'>Remove OPFOR Units</t>",{["Functions\Spawn_OPFOR\FNC_RemoveOPFOR.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];

/*Place BLUFOR FOB*/
MDT1 addAction ["<t color='#68ccf6'>Place BLUFOR FOB</t>",{["Functions\Place_BLUFOR_FOB\FNC_DeclarFOB.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];

/*Place OPFOR FOB*/
MDT1 addAction ["<t color='#68ccf6'>Place OPFOR FOB</t>",{["Functions\Place_OPFOR_FOB\FNC_declarOPforFOB.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];

/*Custom unit addActions*/
yourUnitNameHere addAction ["<t color='#68ccf6'>Place your Reinforcements LZ and OBJ</t>",{["Functions\CustomFunctions\FNC_Custom_Function.sqf","BIS_fnc_execVM",true,false] spawn BIS_fnc_MP;}];

}else{hintC "Welcome, JIP Player...MDT JIP Module is Loading. Standby."; execVM "Functions\FNC_MDT_addActionScripts.sqf";};

in the init i simply placed
[]execVM "Functions\FNC_MDT_addActionScripts.sqf";
to call the scipt
the next thing i did was change around the Call for Reinforcements script
FNC_CallReinforcements.sqf
FNC_CallReinforcements =
{
	if (isServer) then {
						systemChat "Reinforcements are on the way";

						nul = ["mkr_MDT1_LZ",true,1,3,false,true,"mkr_MTD1_OBJ","random",1500,true,false,8,[0.05,0.7,0.6,0.35,0.9,1,1,0.75,1,1],[true,true,false,true],nil,"this setVariable ['AGM_AllowUnconscious', true];",1,false] execVM "LV\reinforcementChopper.sqf";

					};

};
[PlayerOne, PlayerTwo, Dave] call FNC_CallReinforcements;

and i did the same type of things to the rest of the scripts it made it work on in MP SO big thanks to Tajin who helped me with this :)

Added 5 minutes later:

# Tajin : Yeh, using execVM with fnc_MP would also work.
Personally, I'd rather do it with a function, but thats up to you.

However, I'd recommend including a condition, as seen here:
MDT1_PlaceMarkers_act = MDT1 addAction [
    "<t color='#68ccf6'>Place your Reinforcements LZ and OBJ</t>",
    {
        [[],"MDT1_PlaceMarkers",true,true] spawn BIS_fnc_MP;
    },
    "",
    -5,
    false,
    false,
    "",
    '
        MDT1_PlaceMarkers_available
    '
];

This way you can simply change the variable "MDT1_PlaceMarkers
_available" to true or false and use publicVariable on it, to show/hide the action on all clients.
oh i just seen your post uh not to familiar with conditions statements what is it checking?

This post was edited by shadowmarine578 (2014-11-20 21:26, 1061 days ago)


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#9 Posted at 2014-11-21 09:37        
     
Glad you got it working, congrats on that.
Though there are still a few things you could optimize.


sm:
oh i just seen your post uh not to familiar with conditions statements what is it checking?
In this case it only checks the "MDT1_PlaceMarkers_available" variable. Set that variable to true and the action will be visible, set it to false to hide it. Instead of the variable, you can also write any code there, as long as it returns a boolean value at the end.



Now about your FNC_CallReinforcements.sqf... it sure works the way you use it, but you're not using it a function.


1. Dont put a call command directly under the function unless you want to immediately execute it
2. execVM the file from your init. Note that this is only to LOAD the function, not to run it.
3. In BIS_fnc_MP, don't use BIS_fnc_execVM, instead call your function directly.

In your case that would look like this:
MDT1 addAction ["<t color='#68ccf6'>call in Reinforcements</t>",{
	[[],"FNC_CallReinforcements",true,false] spawn BIS_fnc_MP;
}];
Any parameters for it would go in the empty brackets.




More information on that here:
https://community.bistudio.com/wiki/Function

and if you really want to get into serious business with functions... here:
https://community.bistudio.com/wiki/Functions_Library_(Arma_3)

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.