Home   Help Search Login Register  

Author Topic: ending an mp mission immediately if insufficient slots taken...  (Read 3302 times)

0 Members and 1 Guest are viewing this topic.

Offline filth

  • Members
  • *
  • Who's the bad man?
hello.

here's my problem: i want to set a trigger/script to end a mission if too few slots in a certain group are occupied at the start.

i can't just set a dead detection script or condition line in a trigger because that's something i want to do later on in the mission.

ie. i want to be able to detect if not enough players take up slots in a group right at the beginning of the mission, rather than later on, if their numbers dwindle to a few. (which would cause a seperate trigger to fire).

any suggestions plz? cheers.
« Last Edit: 07 Jul 2007, 22:54:05 by filth_merchant 101 »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Well, you could use the time command which returns the number of seconds since the mission started, not including the briefing.
Code: [Select]
blah blah && time < 5where blah blah is your other conditions would mean that trigger will only fire in the first 5 seconds of the mission. Conversely,
Code: [Select]
blah blah && time > 60will only fire after the mission has been playing over a minute. 

I highly recommend this tutorial on a few of the issues of MP mission making. I wish it had been available before I started  making my first MP mission. It would have saved me weeks of hair-pulling.
« Last Edit: 03 Jul 2007, 21:07:36 by Mr.Peanut »
urp!

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Have you disabled AI? I mean, if your group consists of 8 units, and either a unit doesn't exist, or he is a player, so you have no AI in your group. If that is the case, you can just count the number of units. So instead of "blah blah" in Peanuts example, you add (count units groupname < 5), where groupname is name of the group. And with that example the mission would end if there were less than 5 members of the group. If you however allow AI in the group, it all gets more complicated. What you could do is use CoC NS to check it. Once CoC NS has started, it makes an array that got every player in it. So what you could do, was simply count that array (but I think it adds one element into the array for the server, so if it's a dedicated server, you'd get 1 extra element).

Offline filth

  • Members
  • *
  • Who's the bad man?
ok. thx for the responses. i am basically trying to end an mp mission if no slots from either group alpha or group charlie are taken. - i have tried the following:

1. a trigger set with the condition: (count units alpha) < 1 && time < 5
and set to activate a script: [] exec "slotsnotfilled.sqs"
but this doesn't fire after 5 secs if no alpha slots are taken.

2. a trigger set with the condition:
({vehicle _x in thislist} count units alpha) + ("_x in thislist" count units alpha) < 1 && time < 5
set to activate the same script. but this doesn't work either. (i use both to count units in and out of vehicles).

i've also tried the following:

3. a trigger set with the condition: ({vehicle _x in thislist} count units alpha) < 1 && time < 5
same activation. no joy either. - also...

4. a trigger set with the condition: ("_x in thislist" count units alpha) < 1 && time < 5
no dice.

any suggestions?

btw... does this: (count units groupname < 1)
work whether members of the group are inside a vehicle or not?

cheers.

ps. thx for the tut link, nuts.

pps. it's been suggested that the camcreate command doesn't work in multiplayer. - any truth to the rumour?

ta.
« Last Edit: 05 Jul 2007, 02:47:17 by filth_merchant 101 »

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
"count units groupname > number" works no matter what "situation" the group might be in, if they are in vehicles or whatever doesn't mess it up. However, what it needs to work is that there actually is a group with that name, which is your problem.

The problem is, if there are no units in alpha, there is no group with the name alpha. I guess you've written "alpha = group this" in the leaders init field or something, but since this unit isn't selected at start, he is never created and the group never gets the group name. So one thing you have to make sure is add "alpha = group this" to all units in that group, and likewise with all other groups.

Now to how to detect if a group is present or not...

That's a tricky one. Only solution I can come up with this early in the morning is this:

You can run this check on the group:

"(leader alpha) != ObjNull"

Problem is, that won't do anything if there is nobody in the group, but if there are anyone in the group, then it will become true.
So what you could do, was run a script at start. It then runs that check on both alpha and charlie. If they are both present, the check will come true, and exit the script. If one or both are not present, it will not come true, and then after the check, you set a variable to true, which then fires off a trigger which again ends the missions...

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
The correct condition might be:
Code: [Select]
isNull (leader alpha) && time >1
As for camCreate in MP, it depends how it is used. I know you are using it for the heli transport script so the question becomes : is the heli transport script run on every client? To answer that I need to know how you call the script. If you use a trigger to call it (most likely) then what are the trigger conditions?


edit: on the other hand, you could replace the camCreate line with:
Code: [Select]
if (local server) then {"SmokeShellGreen" createVehicle getPos _car}and be done with it. Of course you then have to make sure you have a game logic named server.


« Last Edit: 05 Jul 2007, 18:53:59 by Mr.Peanut »
urp!

Offline filth

  • Members
  • *
  • Who's the bad man?
first of all, thx for the responses lads. - starting with the camcreate bit, i'm adding it to the helidrop script at the end. the set up is as follows: in the init line of the chopper, i've got this:
[this, car1, chute1, chute2, chute3, chute4] exec "heli4drop.sqs"
i have a trigger that fires when the chopper reaches an altitude of 50m adding the ammo release action to the chopper. the trigger is set to the following: condition line:
(getpos chopper1 select 2 > 50)
with the activation field reading:
chopper1 addAction ["Release Ammo Crate", "ammorelease.sqs"]
the ammorelease script is thus:
release4 = 1
~1
chopper1 removeAction 1

and this is what i've got at the end of the helidrop script:
? (_chute1PosZ > 3.7) : goto "DropUpdate"
~0.5
"SmokeShellGreen" camCreate getPos _car


this works fine in the editor. will it be ok in an mp environment?

next... the group not filled problem... peanut m8, i tried your condition line: isNull (leader alpha) && time >1 in a trigger, but no joy. it doesn't fire when the group isn't populated at the start.

garcia... i've tried to work out your suggested system of triggers and scripts, but i'm struggling a bit with the complexity of it all. any chance you could walk me through your idea with examples?

cheers for your help guys, it's much appreciated.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
I tried it in the editor and got it to work, but I've got a better way now...

What you do is add the following in the condition field of a end trigger:

Code: [Select]
(format ["%1",count (units alpha)] == "scalar") && (format ["%1",count units charlie] == "scalar")
And you just set the trigger to none, axis set to 0.

And about the camcreate. Problem with camcreate is it is local to each client. So if you run a script only on one computer during a MP game, and camcreate the smokeshell, it won't exist on any of the other computers. So while you might see it, nobody else will. If the script runs on all clients, there isn't any problem using camcreate (since it will just cause every client to create their own smokeshell, would possibly cause problems if it were something else). If the script runs on only one client, you can just replace camcreate with createvehicle. Difference between camcreate and createvehicle is that createvehicle is global. So if you create the smokeshell on only one computer with createvehicle, all other will see it too.

Offline filth

  • Members
  • *
  • Who's the bad man?
garcia, thanks for the tip on camcreate. i have changed all camcreate commands to createvehicle. out of curiosity, how do you know whether a script will run locally or on all clients?

as far as the 'end mission if group not populated at start' problem, i'm still having trouble getting either suggestion to work. just as a test, i set up two west groups in the editor with one named as alpha, the other not named. i set two triggers set to none present. the first has this as a condition line:

isNull (leader charlie) && time >1

the second has this as a condition line:

(format ["%1",count (units alpha)] == "scalar") && (format ["%1",count units charlie] == "scalar")

neither trigger fires.  ??? :confused: if you got it to work, m8, would there be any chance of you posting an example in the editor?  :scratch: cheers.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Well, if me and you play a mission with this action:

Code: [Select]
chopper1 addAction ["Release Ammo Crate", "ammorelease.sqs"]
And you use it. Then ammorelease.sqs will only run on your computer. Other examples of when a script runs locally is most scripts that creates units or vehicles. CreateVehicle and CreateUnit are global commands, and because of this, if you play a mission with 2 players on a dedicated server, and runs a script for all clients, and in this script you create a jeep with CreateVehicle, then you will actually get 1 jeep for both players and the server, so you end up with 3 jeeps. So usually scripts creating vehicles have this at the start (at least I use it when I create things):

Code: [Select]
? !(local server) : exit
Which will exit the script if the client isn't the server.

Now back to the ending...I see now what's wrong...

It should be

Code: [Select]
(format ["%1",count (units alpha)] == "scalar") || (format ["%1",count units charlie] == "scalar")
With && instead of || it won't trigger if one of the groups are present.

So if you add a trigger like this:

Activaiton: None
Axis: both 0
Type: End #1

And in Condition:

Code: [Select]
((format ["%1",count units alpha] == "scalar") || (format ["%1",count units charlie] == "scalar")) && time > 5
That will end the mission after 5 seconds if one of the groups alpha/charlie doesn't exist at start. And by using time you don't have to fiddle with timeout and countdown...I never remember how they work anyway ::)

Offline filth

  • Members
  • *
  • Who's the bad man?
garcia, you're a bloody genius.  :D
on the group unoccupied thing, the new code works perfectly.  :good:

as far as the addaction code goes, does this mean that if i use: chopper1 addAction ["Release Ammo Crate", "ammorelease.sqs"] in the init line of the chopper on a multiplayer mission, that all players will not see the ammo drop from the chopper?

i recently made a multiplayer mission where i added the addaction command to an ammo crate on the ground by using a trigger. when the trigger was fired, the action was added to the ammo crate to give players the option to move it to a different position on the map. everyone who played the mission was able to use the command and the script seemed to work fine.

i'm going to change the current mission so that the addaction to the chopper is done by a trigger, not in the init line. do you think this will make it a 'global' command and therefore work for everyone who plays it?

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Everyone will see the action, and everyone will be able to use the action. The problem is, that if player A uses the action, the script that is then run, only runs on player As computer, not on any other computer. I guess the reason it worked when you moved the ammocrate was because you used setpos, which is a global command.

An example: You have an object, lets say a jeep. You add an action to it, and when the action is used, it runs a script, say bomb.sqs. Now, if you add the action to the jeep in the init.sqs, everyone will be able to see it. Lets say player A and player B plays this mission together. Both sees the action when they get close to the jeep, but player A is the one who presses the action. On player As computer, bomb.sqs will then run. In bomb.sqs, player A is told to press on a location on the map. At the location he presses, a bomb will be created. Now, since the script only runs on his computer, if the script uses camCreate to create the bomb, player B won't see the bomb. If, however, createVehicle is used, both player A and player B will see the bomb, since createVehicle is a global command.

What decides if a command is global or local is if the result of the command happens on all computers, even though the command was given only on one computer. camCreate is a local command, because what it creates only shows on the computer it's run on. createVehicle is a global command since what it creates shows on all computers, even though it was only run on one computer. It's the same for addaction. It is a local command because the result of the command, namely the script that runs once you use the action, is only run on one computer, the one that belongs to the player who used the command... :blink:

Bah, now I'm getting confused myself :whistle: I'm a rather bad teacher though, so you should probably look at some tutorials and such ;)

Offline filth

  • Members
  • *
  • Who's the bad man?
you're not a bad teacher at all, m8... you're making perfect sense and i appreciate your explanation.

and as a result, i realise why the 'ammo crate move' thing i did on the previous mission worked.

now... what i need to know is this: i'm using David Berka's helidrop script that i found in the editor's depot to drop the ammo crate from the chopper (i don't know how to include a link in this post, but in the scripts depot, it's the one that's called: 'paradrop' and it's author is shown as 'mp').

my question is: will this script execute globally? it seems to be full of getpos and setpos commands, which i presume from what you say, are global commands.

basically, can i include this script in a multiplayer mission? if not, i'll try something less ambitious to generate the ammo crate at the desired location.

thx for your time on this, m8. i am learning a lot from what you're telling me.  :good:

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Heh, honestly I had to change the script to get it working...

And as I understand it, this script is run from a action, so it only runs on one computer...the only thing I can see that causes problems is that the parachute is camCreated. If you change it so the chute is created with createVehicle, it should work I think.


Think I looked at the wrong scripts :whistle:

well, it do look ok. It only uses setpos etc, so I think it should work.
« Last Edit: 07 Jul 2007, 14:21:03 by Garcia »

Offline filth

  • Members
  • *
  • Who's the bad man?
i'll give it a go.
thx again for your time and patience. :good: