Change team of CP via LUA? [Solved]
Moderator: Moderators
- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Change team of CP via LUA? [Solved]
Is it possible to change the starting team of a command post via the mission lua?
If not, how can I do it in ZE?
If not, how can I do it in ZE?
Last edited by commanderawesome on Thu Jun 05, 2014 3:45 pm, edited 2 times in total.
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Another lua question.
Code: Select all
SetObjectTeam("cpname", teamID)- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Re: Another lua question.
Thanks, man.Marth8880 wrote:Code: Select all
SetObjectTeam("cpname", teamID)
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Change team of CP via LUA? [Solved]
A note for the OP or anyone who plans on doing this with a map that will be played online:
Changing CP team via LUA is tricky online. In order the client to see a CP change team, the CP must be taken "naturally", meaning that someone has to stand in the capture region and capture the region manually. If you just do SetObjectTeam("cp_name", 1) or SetProperty("cp_name", "Team", 1) or whatever, the server will change the Cp's team but the clients (the players) won't know about it. If you change the CP team this way and a client tries to change units at a CP that appears to still belong to thier team, they will get stuck. They'll open up the character selection menu on their screen, pick a unit, and click spawn and the menu will disappear. But when they send that information to the server, the server says "This isn't their CP, so they can't actually spawn here". The result is that the client will be unable to do anything, waiting for the server to say that they successfully spawned.
To get around this problem, you could set the neutralize and capture time to 0.0001 using SetProperty, spawn an AI at the position of the cp (or inside the cp capture region), run a timer for 1 second (Optional: set the timer rate to 3 or 4 since we only need it alive for .0002 seconds, not the full 1 second), and on timer elapse kill the bot and set the neuttralize and capture time back to what they were before.
This also applies to things like reinforcement count and object destruction. Figuring out how to sync up the server and clients is a whoooole new side of modding.
Changing CP team via LUA is tricky online. In order the client to see a CP change team, the CP must be taken "naturally", meaning that someone has to stand in the capture region and capture the region manually. If you just do SetObjectTeam("cp_name", 1) or SetProperty("cp_name", "Team", 1) or whatever, the server will change the Cp's team but the clients (the players) won't know about it. If you change the CP team this way and a client tries to change units at a CP that appears to still belong to thier team, they will get stuck. They'll open up the character selection menu on their screen, pick a unit, and click spawn and the menu will disappear. But when they send that information to the server, the server says "This isn't their CP, so they can't actually spawn here". The result is that the client will be unable to do anything, waiting for the server to say that they successfully spawned.
To get around this problem, you could set the neutralize and capture time to 0.0001 using SetProperty, spawn an AI at the position of the cp (or inside the cp capture region), run a timer for 1 second (Optional: set the timer rate to 3 or 4 since we only need it alive for .0002 seconds, not the full 1 second), and on timer elapse kill the bot and set the neuttralize and capture time back to what they were before.
This also applies to things like reinforcement count and object destruction. Figuring out how to sync up the server and clients is a whoooole new side of modding.
- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Re: Change team of CP via LUA? [Solved]
Uh... that's not the kind of mod i'm making. I'm making an era mod.
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Change team of CP via LUA? [Solved]
It was just extra info in case anyone was searching for the topic.
- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Re: Change team of CP via LUA?
Hmm... it's not working for some reason.
My code:
also tried:
My code:
Code: Select all
SetObjectTeam("cp2", 2)Code: Select all
SetObjectTeam("cp2", CIS)-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Change team of CP via LUA?
Make sure you're putting it in ScriptPostLoad.
- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Re: Change team of CP via LUA?
It works, I just need to figure out what all the cp's are.Marth8880 wrote:Make sure you're putting it in ScriptPostLoad.
I've also discovered that you can add a new team with this method.
EDIT
Does anyone know what the central CP on Mygeeto Conquest is called in the Lua?
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Change team of CP via LUA?
Go to BF2_ModTools\assets\worlds and copy MYG into BF2_ModTools\Data_XXX\worlds, then open the Mygeeto world in ZeroEditor and look at the CP names.commanderawesome wrote:Does anyone know what the central CP on Mygeeto Conquest is called in the Lua?
-
ZoomV
- Rebel Warrant Officer

- Posts: 308
- Joined: Thu Aug 15, 2013 11:27 am
- Projects :: Old Republic Map pack
- xbox live or psn: No gamertag set
- Location: Belsavis, Maximum Security Ward
Re: Change team of CP via LUA? [Solved]
questionLRKfm946 wrote:It was just extra info in case anyone was searching for the topic.
if you use lua to set a command post at the very beginning of the match would it still work for multiplayer? The reason I'm asking is I have a map where in one era one of the command post is supposed to start off with a locals team, but not in the other, and I would like to avoid having to set a bunch of different layers to the map just for it.
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Change team of CP via LUA? [Solved]
Yes, just do what I said above. Set the neutralize and capture time to .0001, spawn in a bot at the CP capture region, kill it a second later, then either reset the capture/neutralize time or remove the capture region, depending on whether or not you want the CP to belong to the locals for the whole round.ZoomV wrote:question
if you use lua to set a command post at the very beginning of the match would it still work for multiplayer? The reason I'm asking is I have a map where in one era one of the command post is supposed to start off with a locals team, but not in the other, and I would like to avoid having to set a bunch of different layers to the map just for it.
- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Re: Change team of CP via LUA?
I was kinda hoping someone would already know. I'm not good at using ZE.LRKfm946 wrote:Go to BF2_ModTools\assets\worlds and copy MYG into BF2_ModTools\Data_XXX\worlds, then open the Mygeeto world in ZeroEditor and look at the CP names.commanderawesome wrote:Does anyone know what the central CP on Mygeeto Conquest is called in the Lua?
-
AQT
- Gametoast Staff

- Posts: 4910
- Joined: Sat Nov 03, 2007 4:55 pm
- Location: SoCal, USA
Re: Change team of CP via LUA? [Solved]
Just open up the conquest .lyr file in a text editor, and do a search for com_bldg_control_zone. That should give you the name of most CPs.
P.S. You don't have to always quote someone before replying to them. Only do so if the post won't be directly above yours, or if you are referring to something specific.
P.S. You don't have to always quote someone before replying to them. Only do so if the post won't be directly above yours, or if you are referring to something specific.
- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Re: Change team of CP via LUA? [Solved]
Thanks. Quick Question, can these files be used to modify properties of the map? (I.E command posts, vehicle spawns, etc)AQT wrote:Just open up the conquest .lyr file in a text editor, and do a search for com_bldg_control_zone. That should give you the name of most CPs.
P.S. You don't have to always quote someone before replying to them. Only do so if the post won't be directly above yours, or if you are referring to something specific.
-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Change team of CP via LUA? [Solved]
I've used them to do those kinds of things with mixed results. You can change the placement and class of an object, but you can't add or delete objects. This has something to do with the SequenceNo. but I haven't quite figured out how it works.
- commanderawesome
- Field Commander

- Posts: 971
- Joined: Tue Aug 13, 2013 11:58 pm
- Projects :: Skin Changer - Warfront - Other stuff
- xbox live or psn: AaTc_CmdrAwesome
- Location: The Universe
Re: Change team of CP via LUA? [Solved]
Thanks!LRKfm946 wrote:I've used them to do those kinds of things with mixed results. You can change the placement and class of an object, but you can't add or delete objects. This has something to do with the SequenceNo. but I haven't quite figured out how it works.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Change team of CP via LUA? [Solved]
Have you ever tried changing both the team and perceived team properties? Example:Changing CP team via LUA is tricky online. In order the client to see a CP change team, the CP must be taken "naturally"...
Code: Select all
SetProperty("cp1", "Team", 1)
SetProperty("cp1", "PerceivedTeam", 1)-
LRKfm946
- Master Sergeant

- Posts: 163
- Joined: Sun Feb 02, 2014 6:13 pm
- Projects :: Battlefront II Hunger Games
- Contact:
Re: Change team of CP via LUA? [Solved]
Yep I think so.[RDH]Zerted wrote:Have you ever tried changing both the team and perceived team properties? Example:Changing CP team via LUA is tricky online. In order the client to see a CP change team, the CP must be taken "naturally"...Code: Select all
SetProperty("cp1", "Team", 1) SetProperty("cp1", "PerceivedTeam", 1)
