Jump to content
gc8

addItem on dedicated

Recommended Posts

HI

I'm making my mission multiplayer compatible and problem I found was that addItem command doesn't seem to be able to give weapon clips to player when ran from server. So I did this to fix it:

 

[_man,"11Rnd_45ACP_Mag"] remoteExecCall ["addItem",_man];

But my question is will it work properly when more players join the server than just me? Will everything be synced?

 

Also my question is, is there a list or something where you can tell what's the proper way to call these commands such as addItem, addvest etc?

 

thx!

Share this post


Link to post
Share on other sites

Looking at the biki for addItem, the command should allow for a remote argument with global effect. You should not have to use remoteExec. I am curious if anyone is knows this to be, and if the biki should be updated. Or perhaps there is just some user error. Check your syntax! Also, note the inventory space requirements, and consider using some of the related commands (such as to Vest).

 

Regarding other players seeing the effect of this command, because it is considered to have global effect they should. But if you are truly required to remoteExec it to the machine local to the unit, then that may not necessarily be true. 

 

Regarding your request for a "list", see the above hyper link for the biki and go explore!

Share this post


Link to post
Share on other sites

@KC Grimes Thanks for your reply. What I'm most concerned is what is the best place to call addVest, removeAllWeapons, removeAllItems etc. the wiki does not tell. should I call them where object is local? or server? or all clients?

 

thx

Share this post


Link to post
Share on other sites
25 minutes ago, gc8 said:

@KC Grimes Thanks for your reply. What I'm most concerned is what is the best place to call addVest, removeAllWeapons, removeAllItems etc. the wiki does not tell. should I call them where object is local? or server? or all clients?

 

thx

 

The the top of all of the command pages, including addItem, you will see one or two icons indicating the locality of the argument and locality of the effect. 

 

If a command requires the argument to be local, the command must be executed where the unit is local. This can be accomplished by either directly executing the command on the local machine, or having a remote machine remoteExec the command to the local machine. 

 

If a command allow for a remote (global) argument, then it can be executed from any machine.

 

Keep in mind that effect can also be local or global, separate from the locality requirement of the argument. 

  • Thanks 1

Share this post


Link to post
Share on other sites
13 minutes ago, KC Grimes said:

The the top of all of the command pages, including addItem, you will see one or two icons indicating the locality of the argument and locality of the effect. 

 

Ah I didn't know that! This is very useful, thanks :)

 

But not every page has that info, like https://community.bistudio.com/wiki/addVest page

 

However seems like I got my scripts working

Share this post


Link to post
Share on other sites

To sum up what @KC Grimes stated:

//argument global, effect global:
_unit addItem "SomeItem";
//unit will receive item visible for any player on the server, no need for remoteExec, no matter on which client this command is called

//argument local, effect global:
[_truck,1] remoteExec ["setFuel",_truck];
//_truck will have 100% fuel for every client when command is executed where _truck is local

//argument global, effect local:
[_unit,"Test"] remoteExec ["sideChat",0];
//_unit will only sidechat for everyone when executed on every client (0), does not have to be executed where _unit is local

//effect local
["Another test only visible to blufor"] remoteExec ["hint",allPlayers select {side _x isEqualTo west}];
//will show the hint only on clients where it is executed (every west player in this case), no matter where the remoteExec is coming from

Please correct me if I missed something.

Happy brain melting.

 

Cheers

Share this post


Link to post
Share on other sites
12 minutes ago, gc8 said:

 

Ah I didn't know that! This is very useful, thanks :)

 

But not every page has that info, like https://community.bistudio.com/wiki/addVest page

 

However seems like I got my scripts working

 

Fixed! At least for that page and a few pages it links to. 

Share this post


Link to post
Share on other sites
3 minutes ago, KC Grimes said:

 

Fixed! At least for that page and a few pages it links to. 

 

How did you figure it was non local command?

 

Share this post


Link to post
Share on other sites
Just now, gc8 said:

 

How did you figure it was non local command?

 

 

Just tested it myself. Launched the game twice, resulting in two "players" that are not local to each other. Using the debug console, I executed the command locally while using the remote player as an argument. If it works (in this case, a vest showing up on the other guy), then the argument can be global. If the other guy can also see this change, then the effect is global. 

  • Thanks 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

×