Jump to content
Sign in to follow this  
Somerville

MP Action Woes - JIP, Respawn, etc.

Recommended Posts

Hi all,

So I'm working on an RPG map, Sahraniville, and so far it's all going fantastically - work is progressing well, and with the help of numerous members of this forum, we've overcome some scripting obstacles. However, we've encountered a few more, and I'm hoping someone can share some words of wisdom with me smile_o.gif

Firstly, the scripts; the first script is actions.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_array = [c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22];

waitUntil {alive player};

if (side player == west) then

{

{

_x addaction ["Arrest Civilian", "arrest.sqs"];

_x addaction ["Fine Civilian", "fine.sqf"];

_x addaction ["Disarm Civilian", "disarm.sqf"];

_x addAction ["Check Car Licence", "clicence.sqs"];

_x addAction ["Check Gun Licence", "glicence.sqs"];

} foreach _array;

player addaction ["Stats", "stats.sqf"];

}

else

{

player addaction ["Hands Up", "HandsUp.sqs"];

player addaction ["Stats", "stats.sqf"];

};

As you can see, it makes sure the player is 'alive' before adding the actions to the array. Now, the issue is, when a player joins-in-progress, unless the AI are enabled, the player has no actions. Which is wierd, because I thought at least the actions would be duplicated for existing units?

Anywho, the next issue. In Init.sqf, I have put the following:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

player addeventhandler ["killed", {_this execVM "was_killed.sqf"}];

... And Was_killed.sqf is:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

waitUntil {alive player};

player execVm "actions.sqf";

Which doesn't do anything *profanities, hair tearing*. I'm new to SQF, but I've been told SQS is 'dirty', so I should stay away. I didn't really want to have a trigger for each unit to run the actions for each unit, but if that's the best option in your opinion, I shall opt for it.

Can anyone suggest any way to make it work with players who JIP? I can't really ID the actions, because _id is local, and it's not worth tying global variables to actions (or is it?).. any help, pointers or whatever is very much appreciated smile_o.gif

Somerville

Share this post


Link to post
Share on other sites

You could try something like this,

in your init;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nul=[] execVM "initPlayer.sqf";

the initplayer.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (!isServer && (player != player)) then

{

// This only executes on a JIP player's computer, because that's the only place where !isServer && (player != player) during init.sqf

waitUntil { player == player };

waitUntil { time > 10 };

};

switch playerSide do

{

case east: { execVM "eastinit.sqf" };

case west: { execVM "westinit.sqf" };

case resistance: { execVM "indiinit.sqf" };

};

westinit.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addeventhandler ["killed", {_this execVM "was_killed.sqf"}];

player execVm "actions.sqf";

Hope that helps

Odin

Share this post


Link to post
Share on other sites

Okay, thanks Odin smile_o.gif

Is there a way to make ArmA check if the actions are already on the unit, and only then to add the actions to a unit that doesn't have them? Or would it be best just to have 'west' actions script, and 'civilian' actions script, run from the init line of each unit?

Edit:

Hmm - that doesn't seem to work on our dedicated server. I'm having a tweak with it now, see if I can make it work

Share this post


Link to post
Share on other sites

Bugger me, this is annoying! Nothing seems to be working!

Thanks for the suggestion Odin, but that doesn't seem to work sad_o.gif

Basically, with the current version in the first post, it works fine. It doesn't work, however, if a unit joins in progress. Anyone who plays from the beginning gets the actions, and I think it works if you leave the AI on. However, that means a load of markers and players cluttering up the map needlessly. Also, the actions don't work when the unit respawns. The problem with actions.sqf above is that it doesn't detect if the unit already has the actions, so you'll end up with units who have duplicate actions, right? Is there any way to stop this, so that units that respawn get the actions again, but those who already have them don't? Please help, I'm literally sobbing now - this is the last issue I need to fix before I can release it - I'll kiss whoever fixes it/helps fix it. Honestly.

The other issue, of course, is join in progress - however, all I need to know here is how to check if the actions have already been added and, if so, how to prevent it from being re-added. If I was, for example, to put in a variable - let's say, actions = false, and then declare that as 'true' at the bottom of actions.sqf.. then in the was_killed.sqf say:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?(actions = TRUE) : exit

Hope someone can help - I'm really stuck here sad_o.gif

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">The problem with actions.sqf above is that it doesn't detect if the unit already has the actions, so you'll end up with units who have duplicate actions, right? Is there any way to stop this, so that units that respawn get the actions again, but those who already have them don't?

Just a thought, you have an array of all the playable objects?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_array = [c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22];

When a player first JIPs, the Player command returns Null. Can you check your array (C1 through to C22). To see if any are either Nil or ObjNull during JIP startup e.t.c If it is, then it might mean the players object has not been used before.

If not, you could create a public array of all the players who start the mission, then check the JIP player to see if it's already in the array. If it isn't then you add the actions.

Share this post


Link to post
Share on other sites

Thanks for the reply, UNN smile_o.gif

I've not made a public array before - how does it work? Is there any chance you can put together a small example for me? Pwetty pweese?

Edit: Okay, I've looked at the Wiki - at ObjNull, isNull, and isNull_grp. What I seem to read of isNull_grp is that it checks if Any_value == isNull_grp. So am I correct in assuming you'd need to create a variable along the lines of "PlayerJIP == true", then check if this variable was true/false before adding actions, right?

Share this post


Link to post
Share on other sites

It's difficult to comment, because I run both the server and client on one PC. So I can't run any tests with more than one client connected at any one time. Consequently, I can only guess at some of the possible problems.

Also, I don't really understand what your doing in your mission. This array:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_array = [c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22];

Does it just contain all playable units of side civilian? If it does, do you have a similar array for all units of side West, set to playable?

Quote[/b] ] The problem with actions.sqf above is that it doesn't detect if the unit already has the actions, so you'll end up with units who have duplicate actions, right?

I would have thought that running a respawn script from the killed event would work ok for the West player. But if any of the Civis respawn while you are playing a West unit. Then you would have to reassign the Arrest and Fine e.t.c actions to the new civ object, for the West players. Is that correct?

Quote[/b] ]ll I need to know here is how to check if the actions have already been added

I thought that any unit that JIP's, can be assumed to have no user actions assigned on it's client? Which units get duplicate user actions after JIP, in your mission?

Share this post


Link to post
Share on other sites

how do you make vehicles respawn in a specific place, facing the original direction... like in evolution? what and where do you add that in? In the description.ext? and what do you put in the unit's init? also, what would i have to put on the map other than respawn_west...? any other kind of marker? please help?!? confused_o.gif

Share this post


Link to post
Share on other sites

I have no idea about AI enabled or disabled, but Domination mission is removing every possible kind of action from a dead player, then adding them back again on respawn. There is a separate script for JIP, but also setupplayer and respawn. I think I understand the concept of the scripts, but trying to explain other peoples scripts I think can lead to more confusion than being helpful.

@HeAvY TrAnCe:

I think you just have to examine Evo scripts. I don't play Evo and only briefly tried to learn the scripts a while back, but gave up (maybe I would have better chance today with more knowlegde). In Domination though, there are several methods in play. Arrays of positions and directions for newly generated "bonus vehicles", respawn scripts for boats, and respawn scripts for vehicles and choppers. Respawn scripts are typically run on each vehicle and restarts itself when vehicle is destroyed. Only scripts, no description.ext stuff going on.

Share this post


Link to post
Share on other sites

i actually got the vehicles to spawn where i wanted them to spawn... now i just have to figure out how to ge them to respawn if not used in 5 minutes or so... after being moved... working on ai respawn atm... wink_o.gif

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  

×