Jump to content
Sign in to follow this  
Hotfixx

A question about if statements and execution of code.

Recommended Posts

I am trying to learn SQF as fast as I can, and I'm making a script which uses as many constructs as I think of. I am trying to make a script which communicates between two multiplayer players. I am making a script on where one player puts the items in a crate, they click send, then it spawns in front of the other player. However, I was considering the logic of the code and I can't test it under a multiplayer environment, so I was wondering if somebody could consult with me here.

 

if (getPlayerUID player != tradingPerson ) then {
    hint "Trade Finished!";
  } else {
    supplyBoxGiveBack = "DSR_Object_Storage_Small" createVehicleLocal position player;

 

The reason I doubt the logic of this code, is that it is executed via addAction and I believe the code is only going to check if that individuals players UID and proceed with the if statement accorindgly. In other words, I don't think the crate will spawn in front of the other player because the script has only been executed by one player, and it is checking whether that player has that UID or not? 

 

Any solicitation would be great on how to move forward on this, if I am wrong. I am very interested in making scripts for Arma 3, as I have put 1500 hours into the game now. I am sorry if this bothers anybody by this question!

 

 Hotfix = ) 

Share this post


Link to post
Share on other sites

You have to store the other player (Object) into a variable. 

There are multiple ways to get this object. 

An easy way could be for example to use nearestObject on the "Man" class to get the nearest player and then create the box next to him

A harder way could be to use a dialog, and a ListBox inside which contains the name of all players (or near players) 

I don't understand why you want to use a if/then/else statement. What is "tradingPerson" for you ?

 

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
Sign in to follow this  

×