OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: sharkattack on 19 Dec 2007, 20:07:45
-
guys ...
im having issues with jip on a new co op im trying to build
at the min the player group starts in a pbx (named dinghy1) as the mission progresses the opfor group transfers to a chopper (named bird1) ... my problem is that on mission start all units start in dinghy1
so if a player jip he starts in the pbx which is not good (if other units are in chopper)
i have conditions which are met once the player group are onboard the chopper
(onboard=true;publiucvariable"onboard")
how could i make it so that if player group is "onboard" the jip guy wont start in the pbx
but will start in the chopper ....
also if chopper has dropped player group (gogogo=true;publicvariable"gogogo") how could i arrange it so that jip guy spawns at a marker point
this has me stumped ???
many thanx in advance
long live ofpec :angel:
-
Edit: Warning: snippet below has several errors in it. Do not use!
Not 100% certain but here goes:
One variable called startPos. Set it to 1 when mission starts. Set it to 2 when players in chopper. Set it to 3 otherwise. Do not set it in the init.sqf!
init.sqf
if isServer then {onPlayerConnected "publicVariable ""startPos""";};
if isPlayer then {nil = [] execVM "setPlayerStart.sqf";};
setPlayerStart.sqf
if not isNil startPos then {
waitUntil {player == player}; // there probably is a better way of doing this!
switch (startPos) do {
// player in boat
case 1: {
player moveInCargo myBoat;
};
// player in chopper
case 2: {
player moveInCargo myChopper;
};
// player at marker
case 3: {
player setPos getMarkerPos "markerStart";
};
};
else {
exitWith {};
};
Edit : Warning: snippet above has several errors in it. Do not use!
-
You may check all that in init.sqf or init.sqs which, AFAIK, are executed also for JIP players.
// init.sqf
Sleep 1;
_leader = obNull;
if (alive player) then
{
_leader = leader group player;
if (((vehicle player) distance (vehicle _leader)) > 100) then
{
// The player is far away from the leader of his group
if (vehicle _leader != _leader) then
{
// Player group leader is inside a vehicle
if (((vehicle _leader) emptyPositions "cargo") > 0) then
{
// There are cargo positions left
player moveInCargo vehicle _leader;
}
else
{
// There are no cargo positions left, the new player is sent to a safe placement
player setPos getMarkerPos "mk_safepoint";
};
}
else
{
// The leader of player's group is on foot
_poslead = getPos leader group player;
_dirlead = 180 + getDir leader group player;
player setDir _dirlead;
player setPos [(_poslead select 0)+sin(_dirlead+180)*3, (_poslead select 1)+cos(_dirlead+180)*3, 0];
};
};
};
-
waitUntil {player == player}; // there probably is a better way of doing this!
waitUntil { not (isNull player) };
makes more sense to the reader (player != player as long as player is objNull).
-
thanx a million guys
will try this out asap ...
nice one fellas .. :clap:
-
Init.sqf
// init.sqf
Sleep 1;
[] spawn
{
_leader = obNull;
waitUntil {alive player};
_leader = leader group player;
if (((vehicle player) distance (vehicle _leader)) > 100) then
{
// The player is far away from the leader of his group
if (vehicle _leader != _leader) then
{
// Player group leader is inside a vehicle
if (((vehicle _leader) emptyPositions "cargo") > 0) then
{
// There are cargo positions left
player moveInCargo vehicle _leader;
}
else
{
// There are no cargo positions left, the new player is sent to a safe placement
player setPos getMarkerPos "mk_safepoint";
};
}
else
{
// The leader of player's group is on foot
_poslead = getPos leader group player;
_dirlead = 180 + getDir leader group player;
player setDir _dirlead;
player setPos [(_poslead select 0)+sin(_dirlead+180)*3, (_poslead select 1)+cos(_dirlead+180)*3, 0];
};
};
};
// Rest of your init.sqs code here
-
thanx a million mate
now i get you !!
best wishes
-
Are you sure "waitUntil {alive player}" works?! As far as I know when the map starts there is no player object... so if there's no player object.... then that command is just skipped over. The only way I've been able to successfully run a script ONLY IF player is an object (and playerSide as well) is to have a trigger that runs when "local player". The trigger will fail when player is null but it continues to check for it.. which is why this works.
-
It depends what "no player object" means. If it means player is nil, then no, that line won't work at all (and will be simply ignored). However, as far as I am aware, player is objNull when it is not set to a real player object at the start of the game, so isNull player will be true and alive player will be false. This is why I prefer waitUntil { not (isNull player) } rather than waitUntil { alive player } or even waitUntil { player == player } since it is much clearer why you are waiting.
-
hi
the script works fine when the player units start on land
however if they start in transport ie boat insertion, the script is ignored.
and the jip player starts in cargo of his vehicle .
is there a way to only move the player in cargo of his insertion vehicle
if say the first objective hadnt been completed ??
hope i make sense ..
an excellent script many thanx
-
Do you mean that the JIP player may be already into a vehicle by default?
And in that case, if the JIP player's vehicle is far away from the position of the group leader you would expect the JIP player to leave its default vehicle and move close to the leader position or even into the vehicle of the leader?
-
hi mate
thats exactly the problem ....
:)
-
Just after
_leader = leader group player;
insert the following:
if ((vehicle player != player) && (vehicle player != vehicle _leader)) then
{
player action ["GETOUT", vehicle player];
unassignVehicle player;
};
Problem is that if a unit is already inside a vehicle, you cannot directly move to a different position into a vehicle, a position outside the vehicle or into another vehicle unless you get out him first.
-
will the moving of the unit be visible to the player who jip ?
if so would it be possible to add a blackout to hide the movement when player connects ?
again many thanx for all your help :)
-
Yes, you should put a BLACK FADED titletext at the very beginning of the init.sqf and a BLACK IN once the repositioning check is finished.
-
many thanx mate ...
-
It depends what "no player object" means. If it means player is nil, then no, that line won't work at all (and will be simply ignored). However, as far as I am aware, player is objNull when it is not set to a real player object at the start of the game, so isNull player will be true and alive player will be false. This is why I prefer waitUntil { not (isNull player) } rather than waitUntil { alive player } or even waitUntil { player == player } since it is much clearer why you are waiting.
I think you are mistaken mate, im not 100% sure, can't test it atm, but afaik, a waitUntil will always wait until the condition is true,
even if the condition contains nil variables. It will simply wait until the variables are not nil and the condition becomes true.
-
Actually, on testing I find that you are right about the operation of waitUntil. Sorry! waitUntil does wait until the condition is actually true, rather than just being non-false as I suspected. Still, I think my other statements are correct in spite of this error (specifically that player is defined as a null object, rather than being undefined/nil, on a dedicated server throughout a game or a dedicated client at the start of a game). I'm sure I've successfully used this particular value directly in if statements as well as in waitUntil (both then and else clauses of an if statement are ignored if there is an undefined value anywhere in the logical expression). Still, I haven't done a specific MP test on this, so I might still be wrong in the other parts of my original statement.
-
the script posted by MAN THE MAN works great however during testing when using Norrins revive script
we have found if the leader is awaiting revive then the jip will spawn at startpont
(if he is lucky ... could be anywhere )
would it be possible to have jip start at a marker pos
(which is moved in conjunction with completed objectives )
thanks in advance guys :)
trying to include in an upcoming co op pack
-
I was integrating the multiple respawn points script into my mission and had problems until I made the "main" respawn marker "respawn_west". The problem was similar to what you are describing -- occasionally players would spawn in what seemed to be random locations (in the ocean mostly). Once I changed the main respawn point (I think "base_respawn" or something") to "respawn_west" I didn't have any more trouble.
-
would it be possible to have jip start at a marker pos
Well, a JIP will execute init.sqf so you might try something like:
// whateverelse in init.sqf
waitUntil {local player};
Sleep 0.1;
player setPos getMarkerPos "mk_respawn1";
-
thanks mate ...
will give it a go
cheers :)
-
im trying to have players join in progress at a marker (startpoint).. the marker will move as objectives are cleared
"mk_startpoint" setMarkerPos getMarkerPos "mk_pos_two";
this seems to work as the marker shifts position when conditions are met
however the jip still starts at the markers origional position
anyone see what im doing wrong
// init.sqf
if (isServer) then {intro = true; publicVariable "intro";};
server execVM "revive_init.sqf";
waitUntil {local player};
Sleep 0.1;
player setPos getMarkerPos "mk_startpoint";
many thanks in advance ???
-
I am assuming that for JIP Players that the marker position has not been updated as it has moved so it is wherever it was when you placed it at mission start.
The only solution that immediately comes to mind is to store/update mk_startpoint's position as a public variable so when a JIP player joins you can use public variable to update the marker position then setPos the player to it. So, whenever you move the marker also re-broadcast the pv and then add a move marker sequence using the pv for JIP players. This solution requires 1.09 or above since it was only after 1.09 that public variable could be used for arrays. If not using 1.09 or later then you would have to use a separate pv for the x, y, and z elements of the position array.
-
I think the markers, as any other global object in the game which position has changed, are synced with any new client connecting.
Try the following, change the Sleep 0.1 by Sleep 2