Jump to content
Sign in to follow this  
Antorugby

Multiplayer Coding

Recommended Posts

Hello guys, I'm sorry if in these days I opened different threads, but I'm fixing a mission and I'm trying everything, but sometimes I need to ask for help.

Anyway, I got a script that spawn randomly the players around the map, with the possibility to spawn two o more people togheter, I call the script in every unit's init, it works fine in the editor and it works fine when I host the mission, but not when it's running on a dedicated, this is the script:

Private ["_unit","_target"];
_unit = _this select 0; //player unit
call compile preprocessfile "SHK_pos\shk_pos_init.sqf";
_pos = ["mrkGreen",0,["mrkRed","mrkYellow"]] call SHK_pos;
_unit setposATL _pos;
sleep 1;
if (random 1 < 0.30) then {

_target = (playableunits + switchableunits) call bis_fnc_selectrandom;
_unit setposATL (_target modeltoworld [0,-3,0]); //spawn behind the unit - avoid friendly fire incidents.
};

I tried with isserver and isdedicated, but without luck, could someone help me out?

Share this post


Link to post
Share on other sites

How does it behave on a dedicated server then? Nothing happens?

You should put an isServer there in any case because random and BIS_fnc_selectRandom come up with different results on each client running them, and setPosATL is global, so the end result is pointless warping at the beginning, and potentially a reset to the starting position if a join-in-progress player enters the server. But it not working on a dedicated server might be related to something that's in shk_pos_init.sqf. Can you paste the contents of that file?

Share this post


Link to post
Share on other sites
How does it behave on a dedicated server then? Nothing happens?

You should put an isServer there in any case because random and BIS_fnc_selectRandom come up with different results on each client running them, and setPosATL is global, so the end result is pointless warping at the beginning, and potentially a reset to the starting position if a join-in-progress player enters the server. But it not working on a dedicated server might be related to something that's in shk_pos_init.sqf. Can you paste the contents of that file?

That file it's working fine when I tested it alone, so it's not that.

Actually now I can't test nothing, because I don't know why my mission wont load on the server anymore, wtf.

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  

×