Home   Help Search Login Register  

Author Topic: Dedi Server vs. Non-Dedi Server Script Issue (equipping soldiers)  (Read 3759 times)

0 Members and 1 Guest are viewing this topic.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
I've had a look at the few topics around here on a similar topic, but none of them were that helpful... and I still have the problem.

I'm calling a script from my mission's init.sqf, like so:
Code: [Select]
if(isServer) then {
    [] execVM "setWeapons.sqf";
};

This script basically just does what it says on the tin, and assigns weapons to each of the player/playable units in-game.  The setWeapons.sqf script is a little something like this:
Code: [Select]
if (!isServer) exitWith {};

_units = [alphaOne, alphaTwo, alphaThree, alphaFour, alphaFive];

... then just a bunch of addMagazine and addWeapon lines in a foreach loop (after a removeAllWeapons) ...

This script works perfectly in SP, and on a non-dedicated server... but it doesn't even seem to run on a dedicated server, as no weapons are assigned whatsoever (units have their default loadouts).

I've been looking over this for ages now, and I just can't wrap my head around it.  Does anyone have any ideas about what it could be?  Maybe I'm missing something blindingly obvious?

Any help would be greatly appreciated!

Thanks in advance.
« Last Edit: 22 Feb 2009, 15:53:40 by Spooner »

Offline i0n0s

  • Former Staff
  • ****
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #1 on: 21 Feb 2009, 02:13:42 »
I have nearly the same strange error in my mission: I run the addWeapon locally on each player. But it may happen, that they start with the standard setup.
Happens randomly and I couldn't get a scheme out of it.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #2 on: 21 Feb 2009, 10:04:03 »
Might be related to the locality of the units as the affected units by weapon commands MUST be local. For example, a player is local to himself, never to the server unless it is a non-dedi and the player is who hosts the game.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #3 on: 21 Feb 2009, 15:28:08 »
This is an issue I came across (and overcame) with SPON Kits. Really, for an easy life, just use that script, which does a lot more than make sure you get equipped, the most important being automatic re-equipping on respawn! Still, it has never been very popular for some reason (no-one has ever told me there were problems with it, so I can only assume it works properly).

There are a number of issues to overcome here. The existance and locality of players and AI do change at the start of a mission, depending on SP/hosted/dedicated, and depending on JIP-status they do this at different times. Also, soldiers don't seem to get equipped immediately they are created (I think I wait until the soldier has something in weapons array before re-equipping him). Anyway, it is 18 months since I wrote the script, so I can't really remember what I did and why :whistle: If you find any problems with it in specific circumstances, then tell me and I will fix it.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #4 on: 21 Feb 2009, 16:32:36 »
Thanks for the responses, guys  :)

Might be related to the locality of the units as the affected units by weapon commands MUST be local. For example, a player is local to himself, never to the server unless it is a non-dedi and the player is who hosts the game.
Then why can I equip all players (even non-local ones) from the server on a non-dedi?  I'd have thought if it had to be executed locally, that wouldn't work, either...  Sorry, perhaps I just don't understand?

This is an issue I came across (and overcame) with SPON Kits. Really, for an easy life, just use that script, which does a lot more than make sure you get equipped, the most important being automatic re-equipping on respawn! Still, it has never been very popular for some reason (no-one has ever told me there were problems with it, so I can only assume it works properly).
I'll take a look at it, and if it works, also use it to replace my own script for re-equipping!  :good:  Will let you know!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #5 on: 21 Feb 2009, 16:49:47 »
Then why can I equip all players (even non-local ones) from the server on a non-dedi?  I'd have thought if it had to be executed locally, that wouldn't work, either...  Sorry, perhaps I just don't understand?

Just guessing that these "playable" units are all local to the server for a fraction of second (or even more), till the units become local to their corresponding players.

Offline Rommel92

  • Members
  • *
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #6 on: 21 Feb 2009, 16:52:27 »
setvehicleinit their weapons, and make sure the player has joined, is local and time > 0 (so he is synced) before you do so.

If you addweapons / removeweapons to the player at the server side, he will simply argue at the server and 'respawn' them.

ie:

I did a "removeallweapons m1" on a trigger line executed on a dedicated server, it removed the weapons in my view, but the player instantly got them back (player sent out the message to all the PCs again that it did indeed have the weapons).

This only occurs with weapons, unlike position/damage etc.  ???

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #7 on: 21 Feb 2009, 17:19:37 »
Just guessing that these "playable" units are all local to the server for a fraction of second (or even more), till the units become local to their corresponding players.
Makes sense, thanks  :good:

setvehicleinit their weapons, and make sure the player has joined, is local and time > 0 (so he is synced) before you do so.
Will look into/test this, for future use :)

This is an issue I came across (and overcame) with SPON Kits. Really, for an easy life, just use that script, which does a lot more than make sure you get equipped, the most important being automatic re-equipping on respawn! Still, it has never been very popular for some reason (no-one has ever told me there were problems with it, so I can only assume it works properly).
Got SPON Kits working beautifully.  Will delve into the scripts later, to see why it works, and my solution doesn't (probably just what Mandoble and Rommel said, I'm guessing).  Now I just have to disable the re-giving kit when you die, and use my own script, as SPON Kits gives back your starting kit, not the kit you had when you died!

Excellent script, though... will be using it in future.  Thanks!
« Last Edit: 21 Feb 2009, 17:22:11 by JamesF1 »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #8 on: 22 Feb 2009, 15:50:47 »
I've never understood why people want to respawn with the exact equipment they died with. Just means they have to waste time getting more ammo to replace what they used up before they died! Consider the option of adding actions to your crates that allow you to switch kits entirely, then picking the kit of your choice is even easier for the player and you'd automatically respawn with that kit:
Code: (init.sqf) [Select]
crate addAction ["Switch to Grenadier kit", "switchKitAction.sqf", ["Grenadier_US"]];
crate addAction ["Switch to Rifleman kit", "switchKitAction.sqf", ["Rifleman_US"]];
crate addAction ["Switch to SAW kit", "switchKitAction.sqf", ["AR_US"]];
Code: (switchKitAction.sqf) [Select]
_actor = _this select 1;
_kitName = (_this select 3) select 0;

_kitData = [_kitName] call SPON_findKit;

_actor setVariable ["SPON_kit", _kitData];

[_actor] call SPON_equipWithKit;
This is a script I haven't touched in a very long time, though I have had a lot of ideas for improving it. As I said, people haven't seemed to show a lot of interest in it, so I haven't re-visited it. Either use it as it is, or take some of the techniques from it to suit your own needs.

Note that SPON Kits doesn't take into account the smaller inventory size of the medic, so really, if someone is a medic, they should be denied the action menu.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Dedi Server vs. Non-Dedi Server Script Issue
« Reply #9 on: 22 Feb 2009, 17:39:59 »
I've never understood why people want to respawn with the exact equipment they died with. Just means they have to waste time getting more ammo to replace what they used up before they died!
Well, the point being that we (my squad) basically only include respawns in our missions so that we don't need to keep restarting when we screw something up.  We aim to get to 0 deaths in any one mission, but respawning with the ammo you had means you can't just think "Hmm, nearly out of ammo" toss a grenade at your feet, and pick up with a full kit... you still have to conserve the limited resource you have, or pick up an enemy weapon.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Aha, that particular usage is reasonable. Most people use respawn-with-what-you-died even when they pick all their equipment from a crate and in long missions where you respawn 50 times, so it just means you have to go to the crate to re-equip anyway.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)