Jump to content
Sign in to follow this  
meatball

Get clientID for use with setOwner

Recommended Posts

I'm having a bear of a time trying to hand off some AI to a headless client using setOwner. I know setOwner needs to be run on the server and I've tried running this on the server as it creates the AI units in script:

unit setOwner (owner hcName);

Where hcName is the actual name of the headless client I create during init using:

if (!hasInterface && !isServer) then{
hcName = name player;
   publicVariable "hcName";
};

I've found a few threads about clientID and setowner that don't pertain to what I'm doing. And I've also previously tried to actually spawn the AI directly on the HC and can't seem to get that working, so I've dropped back to try using setOwner.

Share this post


Link to post
Share on other sites

unit setOwner (owner hcUnit);

if (!hasInterface && !isDedicated) then{
   hcUnit = player;
   publicVariable "hcUnit";
}; 

Share this post


Link to post
Share on other sites

If you use setOwner units won't follow waypoints at all. It is best to make the enemies in .sqf file and have only the Headless client exec the file.

Share this post


Link to post
Share on other sites

@Naught, I'll try that, must be the fact I used name in the in the init.

@Johnson11B2P, I've already tried that. The HC executes the script file with all the AI script calls, but the AI script uses createUnit and I'm guessing there's some sort of locality problem with that. I can watch the HC run the script and actually create the groups for the units, but the units themselves never spawn on the dedicated server/connected clients.

Share this post


Link to post
Share on other sites

createUnit is a global command it will spawn units. Did you create a Center and a group before you tried to create the units?

Share this post


Link to post
Share on other sites
createUnit is a global command it will spawn units. Did you create a Center and a group before you tried to create the units?

Yes, I'm actually using spunFin's AI Spawn script pack, the militarize script in particular. This will create both a center and the groups before the createUnit is run. Though some creative use of hints, variables and radio triggers I've been able to actually watch the headless client run the militarize scripts, create the groups, but it just doesn't create the units, or it's creating them and not synchronizing them off the HC for some reason. Meanwhile the exact same setup works perfectly fine if I run the AI calls from a dedicated server or locally hosted server.

---------- Post added at 00:02 ---------- Previous post was at 23:42 ----------

Think I got it. It's a mess, but it's working. Basically I had to throw a bunch of if/thens into init.sqf to check whether or not there was a HC, etc., and it seems to be working now. Thanks everybody for the help!

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  

×