Jump to content

Recommended Posts

Hi I have been trying to create a Attack and Defend so far I things have been moving along nicely but I have been having issues with spawning Ifirts for the Attackers. When I am just testing the script by myself it will only spawn one ifirt because there is only one Opfor player. But if someone else is playing with me it will spawn two Ifirts. Even though there will still only be one Opfor Player.

 

TL;DR

Trying to use allPlayers select {side _x == east};

to count the number of players on OPFOR to then spawn Ifirts for them.

For some reason it always spawns one extra then what it actually needs?

 

 

TeleportArea.Sqf

This at the moment is mostly pointless but in the future will hold all the different areas for spawning.

 

TeleportArea = "TeleportArea\TestArea.sqf";

NatoUnits = allPlayers select {side _x == west}; 

OpforUnits = allPlayers select {side _x == east}; 

 

execVM "RoundStartTimer.sqf";

 

TestArea.Sqf

player removeAction weaponSafety;

NatoUnits = allPlayers select {side _x == west}; 

OpforUnits = allPlayers select {side _x == east};

_Pos = [11362,11442];

{

_x setpos [11682 + random [-5,0,5],11917 + random [-5,0,5],1]

} forEach NatoUnits;


 

{

_x setpos [11362 + 10,11442 + 10,1];

GetinVechicle = VechicleSpawn createVehicle [11362 + 10, 11442 +10];

_x MoveInDriver GetinVechicle;

 

} forEach OpforUnits;

 

[300] execVM "GameTimer.sqf";

 

The highlighted areas in TestArea is what I belive is causing the issue. But I don't know why. 

 

I am fairly new to Arma 3 mission File scripting... Infact this is my first Mission file. So I do apologize if this may seem trival.

 

 

Thanks,

JarrodsC

Share this post


Link to post
Share on other sites

That's because you are running your script on each PC. A spawning enemy AIs should run on server only (or locally).

Trying to script for MP demands a minimum of knowledge:

https://community.bistudio.com/wiki/Multiplayer_Scripting

https://community.bistudio.com/wiki/Initialization_Order

https://community.bistudio.com/wiki/Code_Best_Practices

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, pierremgi said:

That's because you are running your script on each PC. A spawning enemy AIs should run on server only (or locally).

Trying to script for MP demands a minimum of knowledge:

https://community.bistudio.com/wiki/Multiplayer_Scripting

https://community.bistudio.com/wiki/Initialization_Order

https://community.bistudio.com/wiki/Code_Best_Practices

Hi Pierremgi, I am not running any AI on the server. I am trying to account for only actual players?

 

Within saying that it doesn't seem that explains why this script is spawning a extra ifrit? If it is running on each PC the total should still be 1?

 

Thanks,

JarrodsC

Share this post


Link to post
Share on other sites

if you run a script on one machine which spawns exactly one ifrit then you ll have one ifrit spawned.

if you execute the same script on all connected machines then you have as many ifrits as many machines are connected...

thats what @pierremgi is talking about and what has to be in mind if you want to create scripts for multiplayer.

there is one more important link you should use:

https://community.bistudio.com/wiki/Event_Scripts

these are one tool for controling where/when a script gets executed.

Share this post


Link to post
Share on other sites
1 hour ago, sarogahtyp said:

if you run a script on one machine which spawns exactly one ifrit then you ll have one ifrit spawned.

if you execute the same script on all connected machines then you have as many ifrits as many machines are connected...

thats what @pierremgi is talking about and what has to be in mind if you want to create scripts for multiplayer.

there is one more important link you should use:

https://community.bistudio.com/wiki/Event_Scripts

these are one tool for controling where/when a script gets executed.

 

Hi Sarogahtyp, Thanks for explaining that for me I appericate it.

If you don't mind I have a question for you.

 

Looking at the 'Event Scripts' none of these seem to do what I need it to do.

 

I need to check for how many players are on in each side at random intervals in the match.

 

I plan to have 'Rounds' per say after a set time the script needs to tally up the total players spwan blufor players in a certain area and spwan Opfor Players at a location with Ifrits as well.

 

Is there prehpas a way I can get my pre-existing script to only run on the server?

 

Thanks,

JarrodC

 

Share this post


Link to post
Share on other sites

initServer.sqf should be the right place for it.

Share this post


Link to post
Share on other sites
18 minutes ago, sarogahtyp said:

initServer.sqf should be the right place for it.

Hi Sarogahtyp, thanks for your prompt response.

 

initServer.sqf Executed only on server when mission is started as per the wiki. I want the mission to be already started. Players can join in and leave the script is ran on a timer 30 seconds before the round starts and then that will run until either all players are killed or 300 seconds have passed.

 

Thanks,

JarrodC

Share this post


Link to post
Share on other sites

you can do this with a script which is executed one time by initServer.sqf

All other things you mentioned have to be handled by your script...

Share this post


Link to post
Share on other sites
_Pos = [11362,11442];

{

_x setpos [11682 + random [-5,0,5],11917 + random [-5,0,5],1]

} forEach NatoUnits;

same as

private _base_pos = [11682, 11917, 0];
private "_rnd_pos";

{

 _rnd_pos = _base_pos getPos [ (random 5), (random 360) ];
 _x setPos _rnd_pos;

} forEach NatoUnits;

but faster and better readable, at least for me.

 

Quote

Result:
0.0027 ms

Cycles:
10000/10000

Code:
_posi = [ 11682 + random [-5,0,5], 11917 + random [-5,0,5] ,1];

 

Quote

Result:
0.0024 ms

Cycles:
10000/10000

Code:
_posi = [11682, 11917, 0] getPos [ (random 5), (random 360) ];

 

ok, the speed advantage is negligible. I thought it would be more.

Share this post


Link to post
Share on other sites
4 hours ago, sarogahtyp said:

_Pos = [11362,11442];

{

_x setpos [11682 + random [-5,0,5],11917 + random [-5,0,5],1]

} forEach NatoUnits;

same as


private _base_pos = [11682, 11917, 0];
private "_rnd_pos";

{

 _rnd_pos = _base_pos getPos [ (random 5), (random 360) ];
 _x setPos _rnd_pos;

} forEach NatoUnits;

but faster and better readable, at least for me.

 

 

 

ok, the speed advantage is negligible. I thought it would be more.

 

 

Hi sarogathyp, 

 

Thanks for you help, I will make note of the above script and adjust it.

 

Thanks,

 

JarrodsC

Share this post


Link to post
Share on other sites

{ _x setpos [11682 + random [-5,0,5],11917 + random [-5,0,5],1] } forEach NatoUnits; // gaussian distribution in randomization

or

_pos getPos [random 5, random 360] // returning any position within 5m, with squared chance to be close to center.

 

seems to me a vaste of code as you are scripting with createVehicle first syntax . That means your vehicle will spawn in an accurate place, regardless of your 5m (max) offset. The speed advantage is for no code at all.

 

To my list of things to be read, above, I add a link for all commands you are using. Syntax is paramount. You can't script if you don't read and apply the syntax of each commands.

See also how command works in MP with its Argument Local or Global (where/how the command must run) and the Effect, Local or Global

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
5 hours ago, pierremgi said:

seems to me a vaste of code as you are scripting with createVehicle first syntax . That means your vehicle will spawn in an accurate place, regardless of your 5m (max) offset. The speed advantage is for no code at all.

 

those random getpos has no relation to the vehicle spawn. its his way to teleport nato players to starting area after the round ended. At least is that what I guess here 🙂

Edited by sarogahtyp
  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×