Areas are not territory Script Names.
Create new areas by the Map Editor (you will find the option for it).
About removing human players from game... Did you check if there's no other option that would cause resign-alike behavior?
I would simply kill all units and buildings of the selected player.
Something like this (replace iPLAYER1 with player numbers):
Code: Select all
CreateNamedGroup("KillUnitsOfPlayer1");
AddUnitsByTypeToGroup("KillUnitsOfPlayer1", "Everything", iPLAYER1, kPlayerMode_Self, NULL);
or:
AddUnitsByAttributeToGroup("KillUnitsOfPlayer1", "Everything", iPLAYER1, kPlayerMode_Self, NULL);
if(NumUnitsInGroup("KillUnitsOfPlayer1") > 0){
SelectGroupForPlayer("KillUnitsOfPlayer1", iPLAYER1);
KillSelection();
ClearSelection();
}
I'm not sure if Type or Attribute "Everything" is correct.
You can check in file: zips\dbunittypeattributes.ddf
UnitTypeAttribute "MobileUnits" seems to contain everything except Projectiles.
Same for buildings, I think "BareBoneBuilding" would select them all.
So finally it could look like this:
Code: Select all
AddUnitsByAttributeToGroup("KillUnitsOfPlayer1", "MobileUnits", iPLAYER1, kPlayerMode_Self, NULL);
AddUnitsByTypeToGroup("KillUnitsOfPlayer1", "BareBoneBuilding", iPLAYER1, kPlayerMode_Self, NULL);
Remember that AddUnitsByAttributeToGroup and AddUnitsByTypeToGroup can be used as many times as you like, to make sure everything is added to that group.
Also don't forget to use:
Code: Select all
PrintMessage("Player 1 has been eliminated - removing all units!");
to know if script works correctly. PrintMessage is very useful when scripting, and at the end, when your script is ready you could remove all those messages.
To prevent your previous error, there is a function called: IsPlayerHumanControlled().
So it could look like this to prevent debug message displaying:
Code: Select all
if(!IsPlayerHumanControlled(US_ARMY)){
ForceSurrenderOffer(..., ...);
}
The " ! " before function name, means to execute it when it's FALSE.
So same effect as:
Code: Select all
if(IsPlayerHumanControlled(US_ARMY)){
//do nothing
}
else {
ForceSurrenderOffer(..., ...);
}