Jump to content
Sign in to follow this  
Vincent Edwards

Trigger that fires when somebody enters the server

Recommended Posts

Hey guys, I wanna add ad trigger to a mission, that will fire, if a new player joins the server.

Aim of the trigger is to play a short music jingle, that he can hear, when he enters the server. But only he shall hear the sound, not the other players.

How can I manage that? Any suggestions?

Share this post


Link to post
Share on other sites

onPlayerConnected "[_id, _name] execVM ""PlayerConnected.sqf"""; so where does this go? in your init file? that wiki seems to have everything i would ever need but i don't quite understand where i need to be putting these "codes"

Share this post


Link to post
Share on other sites

I have wondered what it means on the Wiki with the server having a player names __server__ that also runs the script every time a player runs it.

Would you do a quick

_plName = _this select 1;if (_plName == __server__) then {exitwith};

at the start of the called code from the onPlayerConnected?

also from what I read it runs on the server. So will it also run on all clients?

Share this post


Link to post
Share on other sites

Says how it works right in the comments for the function! :confused:

The statement is executed only on the server, not on the joining player's computer, nor on any other client.

This happens even if onPlayerConnected was issued on all machines.

Note that there is a player with the _name called __SERVER__ which will also connect to a multiplayer game, executing statement.

Share this post


Link to post
Share on other sites
Says how it works right in the comments for the function! :confused:

Yeah, I read that, but what does it mean - I understand locality of running a script.

But can't see how a player connecting can have a script run using this.

It makes more sense to run it with !isserver than the onPlayer Connected.

Share this post


Link to post
Share on other sites

I'm not sure I understand what you want. If you want all players to execute a script whenever a player connects to the server, then you can have the server initiate it via a public variable that is set via onPlayerConnected "[_id, _name] execVM ""PlayerConnected.sqf""";. The idea is that the server will execute the command, the clients will not, regardless if it exists in a client script.

Share this post


Link to post
Share on other sites

i'm trying to understand the use of onplayerconnected.

It runs on the server a script when a player connects to the server.

Can that script run something that will only affect the client joining or will it affect all clients no matter when they joined?

The only use i can see is to check the connecting player against a list for a numder of reasons: custom loadout, virtual bans (auto-kick with list on server side database)

I would assume thescript run should avoid use of 'player' or the like so it doesn't affect all others.

Would this manage a JIP check dependent on the content of the script run?

i think I might have to find a script that has this command in to see how it peforms in game.

thanks for your help in trying to help me understand this.

Share this post


Link to post
Share on other sites

Can that script run something that will only affect the client joining or will it affect all clients no matter when they joined?

as far as im aware and how ive been using it, yes, allows a script to be run on the newly connected client. im assuming the server executes it for that specific player by factor of their uid.

The way i use it is to set Marker for JIP players. i use onplayerconnected to execute the said sqf. then in that sqf i move the marker to position marker. That in turn when the player gets into the game has and update marker pos.

hope this help a little.

Share this post


Link to post
Share on other sites

Thanks Milkie,

Helps my understanding a bit more.

Cheers Jacmac for you help also, it was like trying to give info to a rock at the start there.

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  

×