sortel 0 Posted March 21, 2003 Is there anyway to output text to a file on the server or to the screen in order to debug multiplayer scripts? I have been using hint, but it is clearly not designed for this and does not work as I need in multiplayer mode. Â Thanks! Share this post Link to post Share on other sites
RED 0 Posted March 21, 2003 Could you post an example of how you are using hints to do this? are you getting values from a dialog? RED Share this post Link to post Share on other sites
sortel 0 Posted March 21, 2003 Sure. Â For example, when a trigger fires off a script, I want to make sure that it is only runs once on the server, so I would output hint format ["Trigger: Wave #1, West Count=%1", _wc] If I were to see two in a log, then I would know that it was called twice. Â I am still trying to understand what is run where and when in MP mode. Another example: I am running a script in the Init field of each soldier (4 groups of 5) in a coop MP mission. Â At the end there is a "_this doStop", but for some reason, some team members still show up as "Away", except on the server/player. Â I would love to write out some trace info on each of the "playable" units to see when/why this is not working. Thanks! Share this post Link to post Share on other sites
Guest jacobaby Posted March 21, 2003 To execute a script ONLY on the server, do this. Name a gamelogic "SERVER" and put it in the corner of your mission map somewhere. At the start of the script you ONLY want to run once, use this line at the very start of the script. </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ?! local server:exit <span id='postcolor'> That will check for the PC where the SERVER gamelogic is local, and this will only be on the host. The script will then exit and not run on any client PC's. The format for DOSTOP you need to use is this </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> DOSTOP _this <span id='postcolor'> As a guide, here is what I have discovered by trial and error. 1) Player units are always local on client PC's 2) Vehicles BECOME local if a player enters them, or if he is in command of the driver of them. I am unsure if they become NOT LOCAL once you leave them, and I am unsure what the situation is when TWO human players are in the same vehicle, but I assume the vehicle BECOMES local to the Driver of the vehicle. 3) any script called by a trigger will be GLOBAL in action / execution. 4) Scripts called by local or player units are LOCAL in action, UNLESS they are called via the INIT field of a unit in the mission editor. I hope that helps you sort it out TJ Share this post Link to post Share on other sites
uiox 0 Posted March 21, 2003 In MP scripting most part of command relates to group only works on server side (setcombat,formation,formdir,move,position,etc..). So you need to start a script with the command on the server, but we don't have a command for this. A solution: A loop on the server PubVarClientAskForCommand = false #loop @PubVarAskClientForCommand PubVarAskClientForCommand = false _Command = PubVarDocommand (a number relates to commands) Goto _command ;Move #1 PubVarGroup move [pubvarMoveX,pubvarMoveY,pubvarMoveZ] goto "loop" In a client PubVarGroup = _groupClient PubVarDocommand = 1 pubvarMoveX = 123 pubvarMoveY = 235 pubvarMoveZ = 330 PubVarAskClientForCommand = true Note all variables are publicvariable for "dialog" between server and client, if you have many groups and sides use always call command like this: #SetCombat _TypeCombat = _this select 2 Call format ["PubWaitEvent%1%2 = true ; publicvariable {PubWaitEvent%1%2}",side _Group ,_IdGroup ] Call format ["PubTypeOfAction%1%2 = 2 ; publicvariable {PubTypeOfAction%1%2}",side _Group ,_IdGroup ] Call format ["PubCombat%1%2 = %3 ; publicvariable {PubCombat%1%2}",side _Group ,_IdGroup,_TypeCombat  ] Goto "End" If you want an exemple of this you can take a look to my multi-squad MP mission. http://www.geocities.com/uiox46/MSOFP.html Share this post Link to post Share on other sites
sortel 0 Posted March 21, 2003 Thanks for all of the replies. Â Since nobody has mentioned a method to output trace info in scripts, it must not be possible. Along the lines of when/where scripts run: 1) Where does the script in a trigger's condition field run? Â I would assume the server. 2) All of my units have this in their Init field: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">this exec "initSoldier.sqs"<span id='postcolor'> Here is initSoldier.sqs: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; initSoldier.sqs ; Initialize soldier with equipment and mode ; Clear weapons RemoveAllWeapons _this ; Add Magazines ; Seems to be better to add magazines first _this AddMagazine "M16" _this AddMagazine "M16" _this AddMagazine "M16" _this AddMagazine "M16" _this AddMagazine "M16" ; Add Weapons _this AddWeapon "M16" ; Select _this selectWeapon "M16" ; Set bahavior _this setbehaviour "aware" ; Stop (if not team leader) ? leader _this != _this: doStop _this exit <span id='postcolor'> As you can see the last line stops the caller it is not the team leader. Â All playable soldiers execute this script, but randomly one or more non-player playable units on the players team still shows "Away" Â It does not seem consistant except that it NEVER occurs on the Server-player's units. Where does a script called from the Init field of a "Playable" unit whose leader is a real MP "Player" get called? Thanks. Share this post Link to post Share on other sites
Guest jacobaby Posted March 22, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (sortel @ Mar. 21 2003,21:42)</td></tr><tr><td id="QUOTE">Along the lines of when/where scripts run: 1) Where does the script in a trigger's condition field run? Â I would assume the server. Answer: Scripts Via triggers activate globally on every PC. This is why you have to be careful not to have events repeated several times; 2) All of my units have this in their Init field: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">this exec "initSoldier.sqs"<span id='postcolor'> As you can see the last line stops the caller it is not the team leader. Â All playable soldiers execute this script, but randomly one or more non-player playable units on the players team still shows "Away" Â It does not seem consistant except that it NEVER occurs on the Server-player's units. ANSWER (?) At a guess I would say that time delay (lag) between the server and the client is making that happen. Try a 10 second delay before the DOSTOP command and see if that sorts it. Where does a script called from the Init field of a "Playable" unit whose leader is a real MP "Player" get called? ANSWER That one took a bit of reading to understand And its a good point. I THINK that your own squad, where they are AI controlled, are LOCAL in scope. I have seen FX that would indicate that, and also, your own squad in MP never see lag effects unless they are human players. Regardless of that, any INIT field called script is executed on all computers. Interestingly you could use the FOREACH command to just run your script for the group leaders and then alter the guns etc that way. It REALLY takes some getting used to this local/global business. I must admit I never realised half of this (and still wonder how much I DONT know) before I started writing scripts that are used within addons and running them on my deddy server. TJ<span id='postcolor'> See "answers"(?) below Share this post Link to post Share on other sites