Jump to content
Sign in to follow this  
alleycat

Delay a script without blocking the parent script?

Recommended Posts

How to start a script inside OnPlayerConnected that runs its contents after some delay (game is running)?

I want to add a pistol to the player from a script that is called by OnPlayerConnected but the default gear always steps over it. I assume that is because the default gear is loaded some time after OnPlayerConnected. So I was thinking to delay my script into the game. I dont know which delay techniques work for that.

Share this post


Link to post
Share on other sites

You'd just use an execVM in the onPlayerConnected.

But why not just do this from init.sqf? I don't see why you would have to use onPlayerConnected to add a pistol.

Share this post


Link to post
Share on other sites
You'd just use an execVM in the onPlayerConnected.

Do you mean in the script call (see below), or inside the script (a new execVM inside pistol.sqf)?

Init.sqf

onPlayerConnected "[_name, _id] execVM ""pistol.sqf""";

If I do anything with gear it gets stepped over by the default gear in there.

Share this post


Link to post
Share on other sites

Why use onplayerconnected? The init.sqf runs even when JIP players connect, then something like this:

[player] execVM "pistol.sqf";

in the init.sqf. That should work just fine, although I'm not sure how player will be affected. Should work on a dedi server.

Share this post


Link to post
Share on other sites
Do you mean in the script call (see below), or inside the script (a new execVM inside pistol.sqf)?

Init.sqf

onPlayerConnected "[_name, _id] execVM ""pistol.sqf""";

If I do anything with gear it gets stepped over by the default gear in there.

Then don't do it in onPlayerConnected.sqf

Most people run their gear scripts either from editor inits or init.sqf. Both will give the unit his new gear and not use the default.

Share this post


Link to post
Share on other sites

The problem is that I need it to be server-side for anti cheat and stuff. Init.sqf runs locally for each client. That is why I am looking for a way to add gear server side

Share this post


Link to post
Share on other sites

Is addweapon even possible to call on the server and affect a client? I am thinking now that it only works locally

Share this post


Link to post
Share on other sites

According to wiki the effects are global but arguments passed have to be local, so you need to execute addWeapon locally.

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  

×