Jump to content

Photo
- - - - -

Get clientID for use with setOwner


  • Please log in to reply
5 replies to this topic
Thread Starter
Meatball
Meatball

    Master Sergeant

  • Members
  • 733 posts

#1

Posted 01 January 2014 - 21:31

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.

Naught
Naught

    Corporal

  • Members
  • 98 posts

#2

Posted 01 January 2014 - 21:37

unit setOwner (owner hcUnit);

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


Johnson11B2P
Johnson11B2P

    Staff Sergeant

  • Members
  • 332 posts

#3

Posted 01 January 2014 - 21:44

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.

Thread Starter
Meatball
Meatball

    Master Sergeant

  • Members
  • 733 posts

#4

Posted 01 January 2014 - 22:44

@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.

Johnson11B2P
Johnson11B2P

    Staff Sergeant

  • Members
  • 332 posts

#5

Posted 01 January 2014 - 23:28

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

Thread Starter
Meatball
Meatball

    Master Sergeant

  • Members
  • 733 posts

#6

Posted 02 January 2014 - 00:02

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!