Home   Help Search Login Register  

Author Topic: Getting rid of ai when someone quits  (Read 509 times)

0 Members and 2 Guests are viewing this topic.

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Getting rid of ai when someone quits
« on: 08 Jan 2004, 15:44:14 »
I am trying to use the following sqf to clear away an ai when someone quits the game in progress:
// BEGIN purge.sqf
// This function receives a list of soldiers as a parameter.
// Any soldier in the list that is not in a vehicle will be deleted.
// Players will not be affected.
_list = _this;
{if ((local _x) && !(_x == player)) then {unassignvehicle _x;_x setpos [0,0,0];deleteVehicle _x}} forEach _list
// END purge.sqf
  I call it and define it this way in the init.sqs:
?(local Server): purgeFunc = preProcessFile "purge.sqf"
aiList = (units GroupWA) + (units GroupWB) + (units GroupWC) + (units GroupWD) + (units GroupWE) + (units GroupWF) + (units GroupWG) + (units GroupWH) + (units GroupWI) + (units GroupWJ) + (units GroupWK) + (units GroupWL)

But, alas again, whenever some quits, the ai is still there to gum up the works.
Ideas?

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Getting rid of ai when someone quits
« Reply #1 on: 08 Jan 2004, 15:52:13 »
First thing m8, its impossible to delete a player unit, which makes things easier for you anyway
Second thing is everytime a player respawns, a new unit is created for the player

So basically what you need to do is keep track of all the units, it doesnt really matter what they are doing, either in a vehicle or whatever, as the main thing i would imagine for you is to get rid of AI created units when a player disconnects
You need to constantly update this list, which would be an array

then simply deletevehicle for each element of the array.
If a player unit, is one of those elements in the array, it will not be deleted

AI units are normally local to the server, therefore its the server that you need to use to delete these units

Hope that helps
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:Getting rid of ai when someone quits
« Reply #2 on: 08 Jan 2004, 19:55:17 »
Ok, got it, think everything is kosher now thanks!