Jump to content
Sign in to follow this  
Horrace

Questions about eventhanders and MP scripting

Recommended Posts

Hi,

I have a WIP DM mission that I'm having a few problems with.

My init.sqf looks like this

_units = [s1,s2,s3,s4,s5,s6];

// 1st
// add "killed" event handlers to each unit
{ _x addEventHandler ["killed", {nul=_this execVM "scripts\respawn.sqf"}]; } forEach _units;

// 2nd
// give random weapons to each unit
{ nul=[_x] execVM "scripts\randomweapons.sqf"; } forEach _units;

I have read through some things in the BIKI about MP scripting and also 6thSense page on the BIKI but still need a few things clearing up.

My questions are :

1. Is it correct that that init.sqf runs on the server and then on each client and then for each JIP player?

2. If so will the first piece of code add an extra event hander to every player/AI everytime someone JIPs? ( not good if true )

3. Is it possible / are you supposed to add event handlers from the server?

4. If I add an event handler to a unit that is initially controlled by AI and then a player JIPs and takes over that AI unit, will the player take on that eventhandler or will it be lost?

5. When a player JIPs and takes over an AI unit. Is there an initial moment where (isPlayer unit) will return false?

6. Can you check for (isPlayer unit) on the server?

7. When you addWeapon to a player are you supposed to do that from the client or from the server?

8. When you add a trigger in the editor. Does this trigger fire on the server aswell as each client? If so is it ok to use isServer in the condition field?

Many thanks!

Share this post


Link to post
Share on other sites
Hi,

1. Is it correct that that init.sqf runs on the server and then on each client and then for each JIP player?

2. If so will the first piece of code add an extra event hander to every player/AI everytime someone JIPs? ( not good if true )

3. Is it possible / are you supposed to add event handlers from the server?

4. If I add an event handler to a unit that is initially controlled by AI and then a player JIPs and takes over that AI unit, will the player take on that eventhandler or will it be lost?

5. When a player JIPs and takes over an AI unit. Is there an initial moment where (isPlayer unit) will return false?

6. Can you check for (isPlayer unit) on the server?

7. When you addWeapon to a player are you supposed to do that from the client or from the server?

8. When you add a trigger in the editor. Does this trigger fire on the server aswell as each client? If so is it ok to use isServer in the condition field?

Many thanks!

1. Yes. But there seems to be a problem with many players on a server. With many peaople the init dont seems to be exec in JIP players.

2. Its true. Just add a killed handler to "player" in init... so everybody has just ONE (local) killedhandler. For AI just make a killed-handler in the init line (just for not playable units)

3.Its possible but tricky. You need a publicvariableeventhandler that can exec a "addeventhandler" or code.

See this: http://community.bistudio.com/wiki/publicVariable and this http://community.bistudio.com/wiki/addPublicVariableEventHandler

4. The server will keep the handler on this unit, that is now a player. But the handler is NOT on the players client. For example: If you give the unti a "killed"-handler with the command "this setpos [0,0,0]"; The player who take over the ai will be teleported to [0,0,0] if he dies, the server will tele the unit. If you use this code: "hint "Blah";" Just the server/host can see a massage if the hanbdler gets fired, the player wont.

5. Until the player can control the unit.... after the briefing and BEFORE the loadin screen dissapears.

6. Yes, you should be able to check this on server. Local you can just use the var "player" (this==player for boolrequests)

7. Uhm.... dont know this yet. In ArmA1 there was a problem in adding a weapon local. I think in ArmA2 the best way is to let the server add a weapon (for the shake of anticheating too)

8. The trigger gets streamed in the engine.... they get fired on server every time but on clients they get only fired if the trigger is in range to the player (this was in ArmA1, dont know the triggerbehaviour in ArmA2 yet. Just test it with a friend and a trigger with a bell or music.)

Sry for my bad english. I hope my answers are helpful

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  

×