OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: duckwilliamson on 16 Nov 2003, 23:46:04
-
Does anyone know how to detect if a player was dropped in a game and then became controlled by ai?
-
well as a pointer you cant delete a player, so if you had an array of all players and you kept it updated then simply run a delete vehicle command for every element of the array, every 5 seconds or so. This way you would delete ai controlled player slots
(I take it that is why you want to know how to detect it)
-
well i'm actually trying to detect which one turns ai because i then want it to run a script which controls the ai characters so that they follow through the mission just as the human "would" ...
on my map there is a max of 6 players ... if any slots aren't filled then each ai player of the six runs a separate script that makes them move and do things as necessary ...
if a human drops, i'd like it so that the newly formed ai unit would join his buddies ...
-
ok i would make 2 arrays
arrayA is an array of all units, eg all six of them
arrayB, which needs to be updated every time a player respawns, is an array of players
Subtract all alive elements in array B from array A and voila you should have an array of ai units
Then join these units to a different group
There's probably a damn sight easier way to do it, but at the moment that is all i have to offer
arrayA - arrayB = arrayC
-
This is what I've done:
For each player, give them a name, like w1, w2, etc. Then for each player's initialization field put playerList = playerList + ["w1"]. Match the string w/ the name you gave them. I have found that you need to place an EAST AI somewhere in the ocean & make its initialization be playerList = []. EAST is the first group to be "run"....you want to make sure the array is set to null first before you assign stuff to it.
THEN I have a script that is always running. Something like this:
?not local serverLogicThatIMade : exit
_count = count playerList
#start
~5
_i = 0
#loop
_p = call (playerList select _i)
?not local _p : goto "continue"
?_p == player : goto "continue"
;do whatever you want them to do here
#continue
_i = _i + 1
?_i < _count : goto "loop"
goto "start"
Only the server should run this script!! Now................what this means is...........if any player becomes local to the server then that means they are AI....so when they become local you give them commands to do.
Anyways. This is how I do it...
Doolittle
-
well thanks a lot doolittle! that's exactly what i needed - jsut couldn't get my head around what to do ... forgot about all ai running only on server ...
thanks Terox for your attempts too ...