Forum Jump :

Author Message

Yibba  



Posts: 8
Rank:


Level: Member

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

 
#1 Posted at 2016-03-08 05:07        
     
I am making a mission to where, after infil, the screen fades to black, time turns to day, players get teleported and switched to sitting down, then fade out to 8 hours later. I have the time of day down, the fade out down, and the teleporting on ONE unit included in the code working flawlessly. This map has a capability of having 24 players.

Here is my script:
Player_01 setPos (getMarkerPos "mark_01");
Player_01 setdir 206;
Player_01 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
Player_02 setPos (getMarkerPos "mark_02");
Player_02 setdir 206;
Player_02 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
Player_03 setPos (getMarkerPos "mark_03");
Player_03 setdir 206;
Player_03 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
Player_04 setPos (getMarkerPos "mark_04");
Player_04 setdir 206;
Player_04 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
Player_05 setPos (getMarkerPos "mark_05");
Player_05 setdir 206;
Player_05 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
etc...

This will not work when not all 24 players are slotted, due to missing variables. how can i modify this script to check on each player if they are slotted or not. I know this most likely involves isplayer, but I do not have the scripting knowledge to implement it.

Also, is there a way for all player input to be blocked until fade out so that even if inputs are entered, the player stays seated?

Thanks in advance


Author Message


Posts: 612
Rank:


Level: Member

Country: au
Location: Perth
Occupation: Arma Addict
Age: 20
In-game name: BroBeans

 
#2 Posted at 2016-03-08 05:47        
     
This will help with disabling input.

you could try
if (hasInterface) then {
};


Advertisement


Author Message

Yibba  



Posts: 8
Rank:


Level: Member

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

 
#3 Posted at 2016-03-08 05:54        
     
# BroBeans : This will help with disabling input.

you could try
if (hasInterface) then {
};
Well I am a noob... let me see if the script works if i put GD semicolons after

Player_03 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"....... lol

If not, would i put each player with tha command, or surround the whole thing with just one?

Added 9 minutes later:

What i mean is either:
if (hasInterface) then {
Player_01 setPos (getMarkerPos "mark_01");
Player_01 setdir 206;
Player_01 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
};

or:

if (hasInterface) then {
Player_01 setPos (getMarkerPos "mark_01");
Player_01 setdir 206;
Player_01 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
Player_02 setPos (getMarkerPos "mark_02");
Player_02 setdir 206;
Player_02 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
Player_03 setPos (getMarkerPos "mark_03");
Player_03 setdir 206;
Player_03 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
Player_04 setPos (getMarkerPos "mark_04");
Player_04 setdir 206;
Player_04 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
Player_05 setPos (getMarkerPos "mark_05");
Player_05 setdir 206;
Player_05 switchmove "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"
};

Also, The original fixed code works but still throws a script error

Added 7 minutes later:

And once again, forgot that in the finalized version, the script errors will not post. Thanks for the disableUserInput info though! Works like a charm!

This post was edited by Yibba (2016-03-08 06:11, 590 days ago)


Author Message


Posts: 612
Rank:


Level: Member

Country: au
Location: Perth
Occupation: Arma Addict
Age: 20
In-game name: BroBeans

 
#4 Posted at 2016-03-08 06:36        
     
woops i completely missed the absence of semi colons after the switchmove .. LOL

What is the script error?

if (hasInterface) would go around the whole lot, it basically checks whether the unit is a player and then if it is, executes this code.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#5 Posted at 2016-03-08 07:34        
     
I'm not sure to understand the behavior of this code. hasInterface will check if there is a player on a local PC. Then, on each PC you fire a code with a local effect? right?
I'm trying another approach but i'm surely wrong:
if !(isServer) exitwith {}; // only on server
{
  [_x,_foreachindex] spawn {
  _plr = _this select 0;
  _i = _this select 1;
  _plr setPos getMarkerPos ("mark_"+str(_i+1));
  _plr setdir 206;
  [_plr, "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"] remoteExec ["switchmove"]; // broadcast to all PC
  waitUntil {< ...your event here... >};
  [_plr,""] remoteExec ["switchmove"];
} forEach allPlayers;

You need to rename marker without "0" : "marker_1" "marker_2" as auto incremented in in 3DEN.
Probably missing argument for JIP.

This post was edited by Pierre MGI (2016-03-08 17:01, 590 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#6 Posted at 2016-03-08 07:49        
     
Wanna do the same task for more than two times? Loops.

if (isServer) then {
    _markers = allMapMarkers select {_x find "mark_" != -1};
    {
        _x setPos getMarkerPos (_markers select _forEachIndex);
        _x setDir 206;
        [_x, "AmovPercMstpSlowWrflDnon_AmovPsitMstpSlowWrflDnon"] remoteExec ["switchMove"];
    } forEach allPlayers;
};

What this code does line by line:
    1. Make sure code runs only once on the server.
    2. Get a list of all markers starting with the string "mark_".
    3. Start forEach loop with the allPlayers array.
    4. Match the first player with the first marker from the list, the second with the second marker etc.
    5. Sets player's direction to 206 degrees.
    6. Makes them switch to given animation. Since we're only on the server broadcast it to all machines.
    7. End forEach loop, and because how SQF is structured, define the loop.
    8. End the code that is running on the server.

Also that's not how hasInterface works. It whould still make the code run on each player's machine, triggering undefined variable errors. Yes it does somewhat check if the machine it's running on is a player machine, but not that the unit is player.

EDIT: Pierre ninja'd me but that code is unnecessary.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#7 Posted at 2016-03-08 16:59        
     
Modified my script because I didn't catch it was only players to teleport. I teleported all playable units.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message

Yibba  



Posts: 8
Rank:


Level: Member

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

 
#8 Posted at 2016-03-09 07:58        
     
I put 01 02 03 etc because it helps me with filterimg, and mostly because I use 2 digit numbers for everything.... Habits I guess. I am not scripting today, but will try that code romorrow. Thanks for the replies. I will use the crap out of this script for a lot of different things.

I will post my full completed script tomorrow, and would appreciate if you guys let me know if I am doing anything unnecessary.