Home   Help Search Login Register  

Author Topic: Object search in MP  (Read 1782 times)

0 Members and 5 Guests are viewing this topic.

Offline Se7eN

  • Contributing Member
  • **
  • Cannot load mission, missing addons: Brain.pbo
Object search in MP
« on: 05 Jul 2005, 19:39:34 »
I had write a script for a MP map, but looks like its a little bit buggy. Its workin fine in single player mode.
I would like to ask some "multiplayer guru" to have a look at this script.
www.dpr.iweb.hu/objectsearch.eden.zip

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Object search in MP
« Reply #1 on: 06 Jul 2005, 10:12:37 »
I'll take a look at this later (not saying I'm a Guru but... ::) ), but you should provide some more info on what the script is supposed to do, and what the problem is. Makes it easier to find out WHY it has a problem, when you know WHAT the problem is.  :-X
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Se7eN

  • Contributing Member
  • **
  • Cannot load mission, missing addons: Brain.pbo
Re:Object search in MP
« Reply #2 on: 06 Jul 2005, 13:50:08 »
Function of the script:

You have to pick up a LaserDesignator from the enemy soldier, and take it to the extract.
If you havent got the LaserDesignator,  then the end trigger hint a message: "Find the LaserDesignator"
If you have it, the end trigger  finnish the mission.
If you pick up the item, then all the other players can read a sidechannel message: "player has the LaserDesignator"
If a player have the LaserDesignator and die, than all the other players can read a sidechannel message: "player died. Find the LaserDesignator!"

The bugs:

-If player pick up the LaserDesignator, then the others cant see the sidechannel message only the player
-If "p2" has the LaserDesignator and go into the end trigger, then he can see a "Nice Work" message, but the other player see the hint message : "Find the LaserDesignator"
-If "p1"  has got the LaserDesignator, and "p2" shoot him down, than "no unit error" in the sidechannel message.

  :joystick:

« Last Edit: 06 Jul 2005, 14:03:40 by Se7eN »

Offline Se7eN

  • Contributing Member
  • **
  • Cannot load mission, missing addons: Brain.pbo
Re:Object search in MP
« Reply #3 on: 11 Jul 2005, 09:09:40 »
Any Idea?  ???

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Object search in MP
« Reply #4 on: 11 Jul 2005, 21:25:20 »
Hmm... okay, looking briefly at the scripts, I think you need help on some MP concepts.

First off, you need to know exactly what machine a specific script or trigger is going to be executed on. The "loop.sqs" script will be run on all clients, since it is run thru an init field. The other two scripts will also be run on all clients, since their trigger conditions are the same on all clients. Keep in mind that due to the time delay caused by internet, the triggers might not fire at exactly the same time on all clients.

Second, the command "player" will return a different object on every machine. Keeping in mind the fact that all scripts should be run on all clients at about the same time, you need to realize that any script using the "player" command will be run different on each machine.

So with those two points in mind, here are the problems:

Quote
-If player pick up the LaserDesignator, then the others cant see the sidechannel message only the player
In "loop.sqs" (which is looping on all clients), you check the condition player hasweapon "LaserDesignator". So if p1 picks up the LD, his "loop.sqs" script will check that condition and go "oh yeah, I have the LD", and will thus play the message. P2's "loop.sqs" script will look at that condition and go "nope, I don't have the LD", and will then continue to loop.

A solution: replace the script with triggers similar to your "killed" triggers (condition: p1/p2 hasweapon "LaserDesignator"). Otherwise, in your looping script, check whether p1 has it, then check if p2 has it, etc. Be advised that your current looping script will NOT reset itself--so if a player picks up the LD, then drops it, then picks it up again, it will NOT display a message on the second pickup. A trigger set to activate repeatedly should solve this problem.

Quote
-If "p2" has the LaserDesignator and go into the end trigger, then he can see a "Nice Work" message, but the other player see the hint message : "Find the LaserDesignator"
Again, "endscript.sqs" gets executed on every client, but since it uses the "player" command, the script ends up referring to different players on each client.

Solution: This one is more complicated to get working exactly how you want it. Try this:

Change the trigger's condition to: this && player in thislist

Leave it's "on activation" field the same.

Change "endscript.sqs" to look like this:

Code: [Select]
_katona = _this select 0
_endtrigger = _this select 1
_b = 1

if (_katona hasweapon "LaserDesignator") then   {_b = 2}
if (_b < 2 )then { hint format ["%1\nSearch the LaserDesignator!", name _katona]}
if (_b > 1 )then { goto "end"}
exit

#end    
endgame1 = true
publicvariable "endgame1"

exit

Now it will work like this: the trigger will only execute on a given client when that player is inside of the trigger area (instead of when ANY west unit is in the area). If that player doesn't have the LD, then a hint to go look for it will be displayed on his machine only. If he does have the LD, then the "endgame1" variable will be set to true on all clients.

Then what you need to do is make a trigger that has the condition "endgame1". This trigger will be executed on all clients once the variable is set from the "endscript". From that trigger you would do things like display the "Nice work!" message, play any cutscenes, and end the mission.

Quote
-If "p1"  has got the LaserDesignator, and "p2" shoot him down, than "no unit error" in the sidechannel message.
This one I don't know the answer to. Perhaps there is a difference in the way the "name" command works in MP vs SP. I also know that in SP, after a unit has been dead for a few seconds, he is turned into a static object, which will return that error from the "name" command.

Maybe you should try using a "killed" eventhandler instead. It might run faster or something. Just delete the triggers and plop this into the gamelogic's 'init' field:

player addeventhandler ["killed", {_this exec "script\diescript.sqs"}]



Hope that helped. :)
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Se7eN

  • Contributing Member
  • **
  • Cannot load mission, missing addons: Brain.pbo
Re:Object search in MP
« Reply #5 on: 12 Jul 2005, 09:03:45 »
THX General!

I will try to fix it.

:cheers:

Offline Se7eN

  • Contributing Member
  • **
  • Cannot load mission, missing addons: Brain.pbo
Re:Object search in MP
« Reply #6 on: 12 Jul 2005, 18:41:23 »
Thanks again....it looks like working correctly ;D, but one more bug is already have.
I tryed it with 4 slots.

Quote
player sidechat format ["%1 is down! Find the documents!",name _katona]

This script working fine with p2,p3,p4. Only with p1 (who is is the leader) has the bug:  
"error no unit is down! Find the documents!"

i've tryed to use
Quote
player addeventhandler ["killed", {_this exec "script\diescript.sqs"}]
, but it's buggy too for me

 ???