Jump to content

Fuzzy Bandit

Member
  • Content Count

    371
  • Joined

  • Last visited

  • Medals

Everything posted by Fuzzy Bandit

  1. Hello! Ok I've been going through this damned thing again and again, trying different methods, putting the vehicles in Arrays, giving them global variables, flippin' everything... and it still doesn't work. The issue is that when the script runs when I am hosting my own server (Using "Multiplayer > New" in-game), it runs absolutely fine. No glitches, hitches or errors appearing. However, if I run the script on a Dedicated Server (hosted myself using arma2server.exe and a server.cfg file), the script hardly progresses at all! At the current point, it would seem that all the script does is: Create A C130J Set the C130J's Azimut to 120 Update it's Dir for MP Takes all fuel out of the C130J That's it. Now that covers the first 13 lines of a 184 line-long script. That's 93% of the script missed. What I want to know is why on earth is my script doing so little in a Dedicated Server environment? I'd be hugely appreciative if people could give me some tips on why this is going wrong, or even test it themselves and see if it works. Thanks for any and all help. Code is placed below in a spoiler.
  2. I use exactly the same method for one of my missions. My team has run that on a dedicated server with no issues, so I don't see why it wouldn't work!
  3. Fuzzy Bandit

    Spawn a playable vehicle

    What is the exact set-up you're looking for? Do you want to spawn an empty vehicle? Or a vehicle with AI gunners? How will you get into the vehicle? Run up and get in? Move straight in when it spawns?
  4. Fuzzy Bandit

    Spawn a playable vehicle

    Are you creating this vehicle using scripts or the in-built editor? If you're using the editor, in the helicopter's "Insert Unit" dialogue, there's a drop-down box labelled 'Control'. If you set this to "Playable as Pilot, Gunner", the crew of the helicopter can then be manned by players instead of AI. I'm not sure if playable slots can be added using scripts though. Don't take my word for it - just an (slightly) educated guess.
  5. Fuzzy Bandit

    Need a Script Debugging

    Noted and invaluable! Will do some testing when I get the chance.
  6. Fuzzy Bandit

    Need a Script Debugging

    Ok, I'll try to post up a line-by-line analysis of the code. In terms of debug messages, what would you suggest? Just a hint? Or using [west,"HQ"] - that way you can see multiple messages... Code and Line-by-Line Run-Through are in the spoiler below. I just can't get why it's not working!
  7. Hello! Looking at Dynamically creating a hint depending a variety of variables. At the moment, nothing is appearing on my screen at all... It might not be possible to set an array in the place of the usual hint text, but by creating that text and the following variables... you're just making an Array, right? Here's the code. Comments highlighted in red are to help with the values of the variables. Let's say there are only 3 guns for simplicity's sake. In reality there might be 20+ guns. _side = (_this select 0); [color="Red"]//_side = EAST[/color] _array = (_this select 1); [color="red"]//_array = opGunArray[/color] [color="red"]//_pos = getMarkerPos "opforSpawn" //opGunArray = [[("D30_RU" createVehicle _pos), rLoaded], [("D30_RU" createVehicle _pos), rLoaded], [("D30_RU" createVehicle _pos), rLoaded]][/color] _messagetext = "Reloading Guns...\n\n"; _reloadHintArray = [_messagetext]; [color="red"]//opGunNumber = 3[/color] for "_i" from 0 to opGunNumber do { _message = format ["Gun %1: ", (_i + 1)]; _messagenumber = format ["%1", (_i + 1)]; _messagetext = _messagetext + (_message + "%" + _messagenumber + "\n"); _gunHint = call compile format ["(_array select %1) select 1", _i]; _reloadHintArray set [(count _reloadHintArray), (_gunHint)]; }; if (playerSide == _side) then { hintSilent format [_reloadHintArray]; }; Am I doing something wrong? Or is this just not possible all-together? By my figuring, after the loop has run _reloadHintArray should be something along the lines of: _reloadHintArray = ["Reloading Guns...\n\nGun 1: %1\nGun 2: %2\nGun 3: %3\n", (opGunArray select 0) select 1, (opGunArray select 1) select 1, (opGunArray select 2) select 1]; Cheers! ---------- Post added at 19:33 ---------- Previous post was at 19:24 ---------- Fixed it. Still not quite sure why that didn't work before though - just put the variables part in another For loop. _side = (_this select 0); [color="Red"]//_side = EAST[/color] _array = (_this select 1); [color="red"]//_array = opGunArray[/color] [color="red"]//_pos = getMarkerPos "opforSpawn" //opGunArray = [[("D30_RU" createVehicle _pos), rLoaded], [("D30_RU" createVehicle _pos), rLoaded], [("D30_RU" createVehicle _pos), rLoaded]][/color] _messagetext = "Reloading Guns...\n\n"; [color="red"]//opGunNumber = 3[/color] for "_i" from 0 to opGunNumber do { _message = format ["Gun %1: ", (_i + 1)]; _messagenumber = format ["%1", (_i + 1)]; _messagetext = _messagetext + (_message + "%" + _messagenumber + "\n"); }; _reloadHintArray = [_messagetext]; for "_i" from 0 to opGunNumber do { _gunHint = call compile format ["(_array select %1) select 1", _i]; _reloadHintArray set [(count _reloadHintArray), (_gunHint)]; }; if (playerSide == _side) then { hintSilent format _reloadHintArray; }; Is that the cleanest way to do it? Or is there a better way?
  8. Hello! Looking into how I would dynamically name a vehicle after creating it using code. My target is to create a series of guns which name themselves according using a For loop. Here's the unsuccessful code with anything related added in at the top. //Related Code opGunCount = 14; _pos = getMarkerPos "opforSpawn"; //Actual Code _c = 1; for [{_c = 1}, {_c <= opGunCount}, {_c = _c + 1}] do { gun = call compile format ["opgun%1", _c]; gun = "D30_RU" createVehicle _pos; publicVariable "gun"; }; I've tried a fair few variations of the code and tried using setVehicleVarName too. Please tell me anything that works for you, or any advice you may have. Been trying to get this damned thing to work for flippin' ages! Cheers!
  9. Apologies to bump a sort of 'Solved' thread, but just to let you know that I'm now using arrays for this current project and a previous project too. Took a bit of re-designing, but even the code looks a hell of a lot clearer now. Cheers for the help! :)
  10. Fuzzy Bandit

    Dynamically Creating Hints...

    rWaiting = "Waiting..."; rLoading = "Loading Ammo..."; rLoaded = "DONE"; It just produces a hint for the current status of reloading an array of guns. Here's related code: init.sqf if (isServer) then { opGunNumber = 18; opSearchNumber = 6; opGunArray = []; opSearchArray = []; [] execVM "debug.sqf"; }; /* rWaiting = Waiting Message rLoading = Loading Message rLoaded = Reload Complete Message rTime = time taken to reload gun = [minimum time, maximum time] */ rWaiting = "Waiting..."; rLoading = "Loading Ammo..."; rLoaded = "DONE"; rTime = [5, 20]; reloadGuns = compile (preprocessFileLineNumbers "funcs\func_reload.sqf"); reloadHint = compile (preprocessFileLineNumbers "funcs\func_reloadHint.sqf"); funcs\func_reload.sqf //_reload = [opGunArray OR bluGunArray] call reloadGuns /* _waiting = Waiting Message _loading = Loading Message _loaded = Reload Complete Message _time = Time taken to reload each gun */ _reloadDiff = ((rTime select 1) - (rTIme select 0)); _side = _this select 0; _array = _this select 1; _pvArray = format ["%1", (_this select 0)]; _c = 0; for "_c" from 0 to opGunNumber do { (_array select _c) set [1, rWaiting]; }; _c = 0; for "_c" from 0 to opGunNumber do { _gun = ((_array select _c) select 0); if ((_gun ammo "D30") < 30) then { _reloadTime = ((rTime select 0) + random(_reloadDiff)); (_array select _c) set [1, rLoading]; publicVariable _pvArray; _reload_hint = [_side, _array] call reloadHint; _gun removeMagazine "ARTY_30Rnd_122mmHE_D30"; _gun vehicleChat "Reloading Ammunition..."; sleep _reloadTime; _gun addMagazine "ARTY_30Rnd_122mmHE_D30"; _gun vehicleChat "Ammunition reloaded."; (_array select _c) set [1, rLoaded]; publicVariable _pvArray; _reload_hint = [_side, _array] call reloadHint; } else { sleep 0.2; (_array select _c) set [1, rLoaded]; _reload_hint = [_side, _array] call reloadHint; }; }; funcs\func_reloadHint.sqf _side = (_this select 0); //_side = EAST _array = (_this select 1); //_array = opGunArray //_pos = getMarkerPos "opforSpawn" //opGunArray = [[("D30_RU" createVehicle _pos), rLoaded], [("D30_RU" createVehicle _pos), rLoaded], [("D30_RU" createVehicle _pos), rLoaded]] _messagetext = "Reloading Guns...\n\n"; //opGunNumber = 3 for "_i" from 0 to opGunNumber do { _message = format ["Gun %1: ", (_i + 1)]; _messagenumber = format ["%1", (_i + 1)]; _messagetext = _messagetext + (_message + "%" + _messagenumber + "\n"); }; _reloadHintArray = [_messagetext]; for "_i" from 0 to opGunNumber do { _gunHint = call compile format ["(_array select %1) select 1", _i]; _reloadHintArray set [(count _reloadHintArray), (_gunHint)]; }; if (playerSide == _side) then { hintSilent format _reloadHintArray; }; Everything's working fine now. It returns (in progress): Reloading Guns... Gun 1: DONE Gun 2: DONE Gun 3: DONE Gun 4: DONE Gun 5: DONE Gun 6: Loading Ammo... Gun 7: Waiting... Gun 8: Waiting... Gun 9: Waiting... Gun 10: Waiting... Gun 11: Waiting... Gun 12: Waiting... Gun 13: Waiting... Gun 14: Waiting... Gun 15: Waiting... Gun 16: Waiting... Gun 17: Waiting... Gun 18: Waiting... Gun 19: Waiting... It reloads a set of guns in an array, here named "opGunArray". In my particular case opGunArray contains 19 elements, each one conistsing of the following (alternatives seperated by "//"): ["D30" createVehicle _pos, rLoaded [color="red"]//[/color] rWaiting [color="red"]//[/color] rLoading] I'm guessing this code is somewhat over-complicated. I usually manage to make it that way, anyway. If so, any tips for clearing it up? Or have I actually done an OK script? :P
  11. Fuzzy Bandit

    Error: Zero Devisor

    Well I'm using the 'Find in Files...' search tool in Notepad++ and the only place 'debug.sqf' can be found is in the init.sqf, under the (isServer) command. Upon further testing, it seems it's actually the beginning part of the code that's causing problems. For the moment it just seems to stop on the culprit line, ignoring it everything below it. Highlighted in red. //Define position variables _pos = getMarkerPos "opShipSpawn"; _regpos = getMarkerPos "opRegOffice"; //Reset opGunArray to an empty Array opGunArray = []; publicVariable "opGunArray"; //Create the OPFOR Plane opship = "C130J" createVehicle _pos; opship setDir 120; opship setPos getPos opship; opship setFuel 0; [color="Red"]opship addAction ["Engage Thrusters", "blastoff.sqf"];[/color] //Create the OPFOR Ship opmain = "Land_Destroyer" createVehicle _pos; opmain attachTo [opship, [0, -35, 0]]; this2 = [opmain,10,time,false,false] spawn BIS_Effects_Burn;
  12. Hello! Having a slight problem with one of my scripts... It works fine when I am the server, but if I host it on a Dedicated Server I get the error below, and the script goes all crazy. Error: Zero Divisor Now from the Biki entry it would appear that in my specific code I'm calling an element of an array that doesn't exist... but it should... Here's some example code (cut down) to show what's going on: init.sqf if (isServer) then { opGunArray = []; [] execVM "debug.sqf"; }; debug.sqf for "_c" from 0 to 13 do { opGunArray set [(count opGunArray), ("D30_RU" createVehicle _pos)]; _gun = (opGunArray [color="Red"]|#|[/color]select _c); _gun setPos getPos (opGunArray select _c); }; publicVariable "opGunArray"; The '|#|' is where the error is appearing. Cheers!
  13. Fuzzy Bandit

    Error: Zero Devisor

    That sounds feasible, but how can that happen if I use the (isServer) code inside the init.sqf? e.g. if (isServer) then { [] execVM "debug.sqf"; }; I understand the concept, but not sure how it's possible that it's running on all clients. I've trawled through all the code - there's nothing that initiates debug.sqf for anything but the server. Besides, you must do some testing! Or have you got to a point now where you write 5000 lines of code, load up the game and you've got your newest version of Domination? :P Cheers!
  14. Hello! I'll probably be pretty disappointed by this, but is there any way I could allow units outside of a vehicle to hear vehicleChat in another vehicle? I've tried using assignAsCargo, but that didn't work. If it's impossible it's all fine, I'll just fling a few group names round the place - it'd be cool is all! :) Cheers!
  15. Fuzzy Bandit

    Error: Zero Devisor

    There is more, but absolutely nothing that would interfere with the array. I just do a few things to _gun. And apologies - _pos is identified in the full code as: _pos = getMarkerPos "opSpawn"; When I get the chance I'll put some fun hint format debug code around the shop and see what's what. The really annoying thing is that it works absolutely flawlessly when I am the host. But if I slap it on a dedicated server it gives me that error and spawns roughly three times as many guns as it should and generally everything goes to hell. I thought it might be a speed thing, so I tried putting a small wait of 0.1 seconds in between adding to the Array and selecting the next element in it. Didn't seem to help much - just slowed the process ever-so-slightly. :P Cheers for the help!
  16. Fuzzy Bandit

    Error: Zero Devisor

    Surely though, in that piece of code, there shouldn't be any problems? First time through For loop: opGunArray = ["D30_RU" createVehicle _pos]; _gun = (opGunArray select 0); _gun setPos getPos (opGunArray select 0); Second time through For loop: opGunArray = ["D30_RU" createVehicle _pos, "D30_RU" createVehicle _pos]; _gun = (opGunArray select 1); _gun setPos getPos (opGunArray select 1); And so on and so forth. Surely I'm simply selecting them as I make them? I don't see why I'd be 'overshooting' as it were?
  17. Good tip zigzag! One of the best things about Placement Radius is that it makes your mission look that much cooler in the editor! :P
  18. Gutta say ruebe, for all my worries and woes about how I would manage this, that was THE most impressive, in-depth, helpful post I have ever read. I'll be testing a huge variety of things on the morrow. One thing that did confuse me, however, was your use of 'resp.'. Had a little look, and turns out it's an abbreviation for 'Respectively' in Swedish. Everything makes sense now! :D Once again, cheers. Here's hoping you won't have to make an angry reply about arrays to another one of my threads. ;)
  19. Fuzzy Bandit

    Script Help

    How about: _howMany = {alive _x} count units group man1; Oh mighty overlord...
  20. This should work. Added code highlighted in red. Change it as you need. // AI_respawn.sqf // © JULY 2009 - norrin if (!isServer) exitWith {}; _unit = _this select 0; _lives = _this select 1; _delay = _this select 2; _respawn_point = _this select 3; _move_script = _this select 4; _group = _this select 5; _side = _this select 6; _AI_unitArray = _this select 7; _AI_magArray = _this select 8; _AI_wepArray = _this select 9; _unitsGroup = units (group _unit); while {(count _unitsGroup) > 0} do { _remainingUnits = []; {if (alive _x) then {_remainingUnits = _remainingUnits + [_x]}} forEach _unitsGroup; _unitsGroup = _remainingUnits; sleep 1; }; deleteGroup _group; if (_lives == 0) exitWith {}; _lives = _lives - 1; _wait = Time + _delay; waitUntil {Time > _wait}; _group = createGroup _side; {_x createUnit [(getMarkerPos _respawn_point), _group];} forEach _AI_unitArray; sleep 2; hint "AI respawn"; _unitsGroup = units _group; {_x disableAI "MOVE"} forEach _unitsGroup; for [{ _loop = 0 },{ _loop < count _unitsGroup},{ _loop = _loop + 1}] do { _guy = _unitsGroup select _loop; removeAllWeapons _guy; {_guy removeMagazine _x} forEach magazines _guy; removeAllItems _guy; {_guy addMagazine _x} forEach (_AI_magArray select _loop); {_guy addWeapon _x} forEach (_AI_wepArray select _loop); _guy selectWeapon (primaryWeapon _guy); _guy setSkill (_AI_skillArray select _loop); [color="Red"] _guy setVehicleInit "blah blah blah"; processInitCommands;[/color] sleep 0.1; }; {_x enableAI "MOVE"} forEach _unitsGroup; _leader = leader _group; [_leader, _lives, _delay, _respawn_point, _move_script, _group, _side, _AI_unitArray,_AI_magArray, _AI_wepArray] execVM "AI_respawn\AI_respawn.sqf"; [_leader] execVM _move_script; if (true) exitWith {}; Never really uses Norrin's revive script before. I think that should work. We'll see eh? :D
  21. Try this: Create 2 markers. One called 'spawn1' and one called 'spawn2'. Now, we'll make a small script called spawn.sqf with the following code (assuming that the special NPC is named 'vip'): _c = round (random 1); _unit = (_this select 0); if (_c == 0) then { vip setPos getMarkerPos "spawn1"; } else { vip setPos getMarkerPos "spawn2"; }; Finally, put the following code in the initialisation line of our VIP: nul = [this] execVM "spawn.sqf"; That should work. There are probably cleaner ways, but that should get the job done.
  22. I said I was stabbing in the dark - I didn't say for a second that 'inCargo' was a real command - it was just guess code that might've worked, just like 'units in vehicle rhib_1' or 'cargo rhib_1'. Secondly, I assume your saying that if all there was was a commander in a vehicle, then the returned array from the crew command would be: [manInCommanderSeat]; I made the (obviously incorrect) assumption that the returned array would instead read: [nil, nil, manInCommanderSeat, nil, nil]; You make it sound as if I'm wandering the forums purposefully misleading people. The majority of people on this forum, including me, are learning about how to script and the concepts behind scripting. I am unsure of a great load of things, but try to help others with anything they need. Not because it gives me the 'wonderful satisfaction' of being a thread-solving hero, but because it helps me to learn, by applying my knowledge to a variety of situations and understanding how to use the commands and techniques within the engine. Feel free to step in at any time and help with the subject of the thread.
  23. Yeh it's pretty easy to get everybody out - it's separating them that's the difficult part! :D VirusLIVED - I'll go through some parts of the code. Remember though, the code I was using there wasn't working, but I'll give you the concepts non-the-less. On the fifth line, there is a single '{'. This is the start of my 'forEach' loop. Now the command 'crew' returns an Array in the following format: crew = [driver,gunner,commander,turrets,cargo]; So, in this case, 'select 4' would select element #4 of the Array, being 'cargo'. The reason that it is 'cargo' and not 'turrets' is because the first element of the Array is 0. So: driver = select 0 gunner = select 1 commander = select 2 turrets = select 3 cargo = select 4 What I tried to do in that segment of code was: Create an Array of the crew inside 'rhib_1' called '_unitArray'. Define a variable called '_units' containing only units defined in the 'cargo' part of the array. Create a loop which would cycle through each unit inside the 'cargo' part of the array, eject them and move them to the relative position. In regards to forEach loops, here's what they do: Let's say I had made an Array containing the unit names of 5 of my men. Let's call them man1, man2, so on and so forth. So, our array would read: myArray = [man1, man2, man3, man4, man5]; I then want to kill every unit inside my Array. To do this, I'll use a forEach loop. Here's the code I would use. { _x setDamage 1; } forEach myArray; So, that loop is going to repeat the code inside the '{}'s for each element inside myArray. _x turns into a sort of 'magic' variable, and each run through the loop it will be replaced by the value of the array. So, the loop would basically do: man1 setDamage 1; man2 setDamage 1; man3 setDamage 1; man4 setDamage 1; man5 setDamage 1; As I said, the code inside the '{}'s is repeated for all the elements in our array, each time replacing _x with the value of the chosen element in our array. Hopefully that explained things a little bit. The more you learn about this stuff the more you learn that a lot of things boil down to loops within loops. A good page to look at on the Biki would be the page on Control Structures. It gives a great insight into loops, IF and Switch statements and the like. I'm not saying you should sit and read through it like a machine, but it really is a fantastic reference.
  24. Post the respawn script and I'll have a look.
×