Taurus 20 Posted July 15, 2007 Array Server: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">groupOne = format["%1",[guy1,guy2]]; publicVariable "groupOne"; Client: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_tmpGroup = call compile groupOne; Results in: 'EAST |#|1-1-G' missing ; Illegal chars in unit names or whats up with that? Running version 1.05 And creating a new group and publicVar that one like Server: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_tmpGroup = createGroup west; [guy1,guy2] join _tmpGroup; groupOne = _tmpGroup; publicVariable "groupOne"; And after 1 minute at the Client: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(units groupOne) join player; DID NOT WORK IN MULTIPLAYER OF COURSE!!! Even tho' I know the units to be in the group with debugging the server(thanks BIS for not including easier ways of own hacks to do this! ) Took me some ~5 hours just to test/debug/realize it didn't work... (thanks...) I give up! Share this post Link to post Share on other sites
zaphod 0 Posted July 15, 2007 after server published "groupOne", the contents are available on clients ... so _tmpvariable=call compile.... is not needed because groupOne has stored your data. Share this post Link to post Share on other sites
Schwab 0 Posted July 15, 2007 how about you just add a ; to your string if it says missing ; ? so <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> groupOne = format["%1",[guy1,guy2]]+";"; Share this post Link to post Share on other sites
zyklone 1 Posted July 15, 2007 You can't convert objects to strings and then back to objects. Share this post Link to post Share on other sites
Schwab 0 Posted July 15, 2007 Sure you can ? Having an Object "oldshilka" and a Logic "dahin", executing a script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _tempstring = format ["newshilka = %1",oldshilka] + ";"; hint _tempstring; call compile(_tempstring); newshilka setpos(getpos(dahin)); Will place the oldshilka at the position of the trigger. Or are we talking of 2 different things ? Share this post Link to post Share on other sites
tj72 0 Posted July 15, 2007 This is whats funny about the call compile. You make a string out of the code just to transport it across the network with PublicVariable. Then you call compile it with a + statement as Schwab said to take it back to an object. So you should be able to make format %1 anything into a string and pubvar it. But on the receiving end you have to take the string and add it to something to create a new object locally So simply %1 the list of guys is halfway there. You cant call compile just a string (as your doing in first post) because its just a list of the two guys names in this case. call compile guy1 and guy2? you want a = [guy1,guy2] because there is your statement thats call/compile-able). So thats why you create a new variable (Im still not sure if that can be local or has to be global. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> groupone = format ["%1",guy1,guy2] Pubvar it.... then on the other side... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> groupeone2 = [] call compile ("groupeone2 =" + groupone) now you have the code of groupone in the other machine available here as groupeone2 try using locals with it as Im still not sure all the rules at play but I hope local variables can work in that call compile thingy, just seems more flexible. Share this post Link to post Share on other sites
ManDay 0 Posted July 15, 2007 CALL calls a code-block. It doesnt just parse the rawdata afaik call compile "{ groupone =[ unit1,unit2 ]; };"; would rather work. and SS you dont just put in "guy1" and "guy2" since that will substitute it all. you cannot identify/refer to units without a proper handle. and handle cannot be casted into strings. instead of casting a handle a property of the unit (the ident like "EAST-1") is getting casted. Share this post Link to post Share on other sites
tj72 0 Posted July 15, 2007 Call executes the code that comes after it. Compile allows the string value to be used as code during the Call. What im not sure about yet is if you can have <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Call Compile ("_groupone =" + groupone) or not.... Share this post Link to post Share on other sites
ManDay 0 Posted July 15, 2007 Call executes the code that comes after it. Compile allows the string value to be used as code during the Call.What im not sure about yet is if you can have <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Call Compile ("_groupone =" + groupone) or not.... you either write very slow or you didnt read what i wrote in the edit. btw, i remember that i managed to get the editor-name displayed in a hint sometime. dunno how i did this - i try it. Share this post Link to post Share on other sites
tj72 0 Posted July 15, 2007 I wrote it before your edit. Still, Im not following your point. If one machine has guy1 as a handle. and guy1 is made into a string guy1strng and PublicVar'd then any other machine who creates a variable and call compiles newvariable + guy1strng that handle has ben recreated on the new machine has the same unit and access with its own new handle. And we are out of the woods on this problem... No? Share this post Link to post Share on other sites
ManDay 0 Posted July 15, 2007 No. This casting stream is a one-way one. Handle >> (Exceptional Cast - using an "inner" property: the ident) String NOT: String >> Handle if the cast from handle to string would use the editor-name then the backcast would work. thats why im looking for a way to find it. (see above) ok - i got it working again. if the unit HAS an editor name, format[ "%1",unit ] will return the editor name - if not the exceptional cast is done. Share this post Link to post Share on other sites
Taurus 20 Posted July 15, 2007 after server published "groupOne", the contents are available on clients ...so _tmpvariable=call compile.... is not needed because groupOne has stored your data. No? as you can not publicVariable arrays, you need to convert them to strings and convert them back. http://community.bistudio.com/wiki/publicVariable The array with units consist of: EAST 1-1-B:1, EAST 1-1-B:2, EAST 1-1-B:3 It seems that the "call compile" thing doesn't take kindly to spaces in object names. And the reason to why I don't call them Guy1, Guy2 and etc are that they are created dynamically depending on how many units gets killed, and I can not dynamically create variable names for each of them. Or can I? Having spawned 3 new guys at the server so they can mount an server-local vehicle. Then after a while, I disembark them to avoid every client running their "disembark" script. But I can not get them to join me, the client. So why doesn't the publicVariable "Group" guys want to join me then? On the client I put myServerCreatedPubVarGroup join player; *Please note here than I can read the contents of group server-side, so I know they are in it. But it seems it doesn't get transfered over the network. They belong to the server you say. Yepp, they do. The other guys belong to the client, yes they do. On the server I can count units in the players group, even tell what their names are, but I can not make them join the player group, because he is a "remote client" Example: server count units PlayerGroup 7 serverGroup join PlayerGroup No! On the client I can not to anything because it doesn't know anything about no group even tho' I publicVariable:d it. I've soon had it with this, spent over two weeks of getting a "semi-real" scenario with a truck heading out the the player and reinforce him when his troops got killed. First I had the issue with pathing. Needed to dynamically create waypoints to the exact spot on the map which the driver could find a route to. Not to forget the issue with players trying to disembark their units, they must move into driver spot to "own" the truck and get "leader" of the units in it as that is what you become when you are the driver. Meaning that I need to disembark the driver and have him mount the truck as a driver each time, checking if somebody is at the wheel and very kindly ask him to leave because the driver wants to get back for tea-time! And this thing with the join player! So thats why you create a new variable (Im still not sure if that can be local or has to be global. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> groupone = format ["%1",guy1,guy2] Pubvar it.... then on the other side... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> groupeone2 = [] call compile ("groupeone2 =" + groupone) now you have the code of groupone in the other machine available here as groupeone2 try using locals with it as Im still not sure all the rules at play but I hope local variables can work in that call compile thingy, just seems more flexible. I'll try this when I get some steam up again. Share this post Link to post Share on other sites
zaphod 0 Posted July 15, 2007 jee i was drunk and 3 a.m. =) didn't see that you format the array before as well ... so as i see now, the answer was just a missing ; inside the string as described by Schwab? i would do it like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //server _data=[w1,w2,w3,w4]; yourglobal=str(_data); publicvariable "yourglobal"; //client _data=call compile yourglobal; Share this post Link to post Share on other sites
Taurus 20 Posted July 15, 2007 jee i was drunk and 3 a.m. =)didn't see that you format the array before as well ... so as i see now, the answer was just a missing ; inside the string as described by Schwab? i would do it like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //server _data=[w1,w2,w3,w4]; yourglobal=str(_data); publicvariable "yourglobal"; //client _data=call compile yourglobal; No worries, I've been up 22 hrs when I posted my first post and spent 10 or more of them trying to make things work in MP mission editing Arma... I would have preferred being drunk 4 hrs earlier, but I wasn't. Well, that could work if I could set the names like that. Just as a side note: What is the difference between "str(_data)" and "format["%1",_data]? Share this post Link to post Share on other sites
zaphod 0 Posted July 15, 2007 str is a simple but native function to create string-representations from all other datatypes like arrays or objects... format is more like a "string builder" for complex outputs. Share this post Link to post Share on other sites
sickboy 13 Posted July 15, 2007 The whole problem is as described earlier, a unit that is not named (editor or setVehicleVarName) will create a problem to address them on another computer when you saved their designation in a string. There are methods that make it possible but they might not be handy to use: [*] Name all your units in the editor [*] Name all your units at the start of the mission by capturing them by a trigger on the server, then use a setVehicleInit on every one of them e.g: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_counter=0; {_x setVehicleInit format["this setVehicleVarName 'unit_%1'",_counter]; _counter=_counter+1;} forEach (list trigger); processInitCommands;I tested the above in pre v1.08. It is possible that with the network object fixes in 1.08 you can leave out the setVehicleInit+ProcessInitCommands and only use setVehicleVarName. The units are now all designated unit_# and as such when you call compile them, it works. [*] AFAIK a group command will always return the units inside the group in the same order on every computer. If you publicVariable the group, and then send the indexes of the units you wish to use through a string, then you have a method of adressing the units on other computers. [*] You can use setVehicleInit and processInitCommands to execute a init on the unit you wish to use on the other computers, the this parameter contains the unit the init was executed on, on every machine. This can be handy except when you need to execute things on many many units as you will have to do many individual vehicle inits [*] Grab all units by trigger, and compare the strings of the units with the string that was PV'ed, when the string matches, you found the right unit. Hope this helps PS. I just see you are using 1.05: Many many commands are broken in Multiplayer in pre 1.07beta. Since 1.07beta you can actually use join from any computer to join any unit with any group, if the unit or group is local or not, does not matter. I remember these problems from 1.05 etc :-) Share this post Link to post Share on other sites
Taurus 20 Posted July 15, 2007 sickboy Thanks for clearing it up. The "problem" still exists because: 1: The units are spawned depending on how many troops there are in the players group at a given time. Therefor I can not name, nor place them in the editor. Sure your code would make an way to dynamically name units, which can come in handy later. 2: I still can not get the "server units" to join "client player" I tried these two things Test one: Server: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">globalGroup = createGroup (side <someAIServerGuy>); _newGuy = globalGroup createUnit ["SoldierWB", getPos <someAIServerGuy>, [], 2, "NONE"]; publicVariable "globalGroup"; Client: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">sleep 30; player sideChat format ["30s. Times up add:%1(?:%2)",units globalGroup,globalGroup]; (units globalGroup) join player; SideChat result: MP-local,pre-view Player "[WEST C1-1-1],(WEST GrpName)" MP-remote client Player "[],(WEST GrpName)" So the client "knows about" the group, but not the units in it. Test two: Server: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">globalGroup = createGroup (side <someAIServerGuy>); _newGuy = (group <someAIServerGuy>) createUnit ["SoldierWB", getPos <someAIServerGuy>, [], 2, "NONE"]; [_newGuy] join globalGroup; publicVariable "globalGroup"; Client: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">sleep 30; player sideChat format ["30s. Times up add:%1(?:%2)",units globalGroup,globalGroup]; (units globalGroup) join player; SideChat result: MP-local,pre-view Player "[WEST C1-1-1],(WEST GrpName)" MP-remote client Player "[],(WEST GrpName)" Again thee client "knows about" the group, but not the units in it. Please note that the actual unit name and group name was something else, I cant remember now exactly how it was. But it was something "Like" that. [edit] PS. I just see you are using 1.05: Many many commands are broken in Multiplayer in pre 1.07beta.Since 1.07beta you can actually use join from any computer to join any unit with any group, if the unit or group is local or not, does not matter. I remember these problems from 1.05 etc :-) Ok! Seems I need to put the "new patches introduce old bugs"-thought aside and upgrade then! If it will work after that I would be glad, if some of my scripts are broken by doing so it wouldn't be such a big problem because most of them doesn't work properly anyways [edit2] By the!? v.108 weighs in at 927 MB! Hehe, did the replace every file in the game or what? [edit3] <span style='font-size:17pt;line-height:100%'>IT WORKS!!! OMG! I'm getting my troops as a remote client now!!</span> The ~1GB of a file was worth it! Just that the transfer of an array didn't work, but I guess I can create new groups along the way if the game engine "re-uses" i.e. if WEST 1-1C is null then after a while createGroup will create WEST 1-1C again? Just curious if - Fixed: Functions createGroup, createUnit now fully works in MP was the problem? - New: Console output of dedicated servers can be logged to file specified in the server config entry logFile. Sweet, is it possible to do in a MP-local game, i.e. are there a "defaultServer.cfg" somewhere? - Fixed: Group leader left by team switch no longer orders some commands Will this mean I'm no longer having a "target box" on stuff that I previously ordered my AI guys to fire at when I, the player dies and take over that unit when using respawn=4? Share this post Link to post Share on other sites
Doolittle 0 Posted July 15, 2007 Took me some ~5 hours just to test/debug/realize it didn't work... Impressive! You have what I call the gift.. which means you keep fighting the good fight to get something to work. Just take heart, we all go through this! When I was first programming I spent about 13 hours on an error only to find I had a missing ";"!! Ah, memories. Doolittle Share this post Link to post Share on other sites
Taurus 20 Posted July 15, 2007 Impressive! You have what I call the gift.. which means you keep fighting the good fight to get something to work. Just take heart, we all go through this! When I was first programming I spent about 13 hours on an error only to find I had a missing ";"!! Ah, memories.Doolittle hehe About missing ; Luckily for java and stuff theres EDI's available which complains loudly if we miss out such things(now) I've spent 2 weeks total, don't even want to begin calculating hrs/day on "developing" this mission I want to do. Vacation now, with "standard summer weather" = it rains, and yes, and these things require patience Read above, it does work now, atleast the createGroup, publicVariable "group" thing over the network after I upgraded to 1.08. It made me abit more and positive, which are reflected by the amount of smiles used. I could get through developing this mission and have it completed soon! Share this post Link to post Share on other sites
sickboy 13 Posted July 15, 2007 Im happy it works now.. I would learn from this happening and in the future first test a new version before going to conclussions; Saves you and other ppl time :-) Share this post Link to post Share on other sites
Taurus 20 Posted July 15, 2007 Im happy it works now..I would learn from this happening and in the future first test a new version before going to conclussions; Saves you and other ppl time :-) True that, it would have saved me time, others who reply do so of their own free will, I'm grateful that some, as yourself sickboy do answer and try stuff out of course Even tho' I got the group thing working the struggle of unit into arrays still exists. Which you gave an example on. [edit] And that thing not being able to put spawned units into an array and "call compile" that array must be a bug IMHO. Share this post Link to post Share on other sites
sickboy 13 Posted July 15, 2007 [edit]And that thing not being able to put spawned units into an array and "call compile" that array must be a bug IMHO. Well, after creating them, if you directly setVehicleVarName them (Not sure if you need to use it together with setVehicleInit and processInitCommands together), you actually can Share this post Link to post Share on other sites
=jps=sgtrock 4 Posted July 15, 2007 When I was first programming I spent about 13 hours on an error only to find I had a missing ";"!! Ah, memories.Doolittle I knew there was a reason that I preferred writing Python code to writing code in any other language. Share this post Link to post Share on other sites
Taurus 20 Posted July 16, 2007 [edit]And that thing not being able to put spawned units into an array and "call compile" that array must be a bug IMHO. Well, after creating them, if you directly setVehicleVarName them (Not sure if you need to use it together with setVehicleInit and processInitCommands together), you actually can <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_array = []; <for loop here which uses _i = _i + 1>{ _newGuy = <code to create unit here>; _tmpName = format["Wz%1",_i]; //Will be Wz0 and etc _newGuy setVehicleInit format["this setVehicleVarName '%1'",_tmpName]; processInitCommands; _array set [_i,_newGuy]; }; myArray = format["%1",_array]; //this is a global variable sideChatting it Wz0,Wz1 and etc. Can even "name _array select 0" which returns: Benjamin Franko When I try to <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_clientArray = call compile myArray; Over at the client it returns "scalar loolercopers!!" Without processInitCommands it returned |#| West 1-1-B:1 ... missing ] when I tried to <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_clientArray = call compile myArray; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_array = []; <for loop here which uses _i = _i + 1>{ _newGuy = <code to create unit here>; _tmpName = format["Wz%1",_i]; //Will be Wz0 and etc _newGuy setVehicleVarName _tmpName; _array set [_i,_newGuy]; }; myArray = format["%1",_array]; //this is a global variable If I sideChat that array I get Wz0,Wz1 and etc When I try to <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_clientArray = call compile myArray; It returns the same scalar loolercopters What am I doing wrong here? Share this post Link to post Share on other sites
tj72 0 Posted July 16, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _clientarry = [] call compile ("_clientarry =" + MyArry) it works with string names that reference global variables so I expect it to work for the names too. Declaring the local variable right before the code allows it to work. Global variables should be predefined too in the init. Share this post Link to post Share on other sites