Page 1 of 1
Change team of CP via LUA? [Solved]
Posted: Tue Jun 03, 2014 9:32 pm
by commanderawesome
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?
Re: Another lua question.
Posted: Tue Jun 03, 2014 9:46 pm
by Marth8880
Re: Another lua question.
Posted: Tue Jun 03, 2014 10:43 pm
by commanderawesome
Re: Change team of CP via LUA? [Solved]
Posted: Wed Jun 04, 2014 2:17 pm
by LRKfm946
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.

Re: Change team of CP via LUA? [Solved]
Posted: Wed Jun 04, 2014 2:31 pm
by commanderawesome
Uh... that's not the kind of mod i'm making. I'm making an era mod.
Re: Change team of CP via LUA? [Solved]
Posted: Wed Jun 04, 2014 3:47 pm
by LRKfm946
It was just extra info in case anyone was searching for the topic.
Re: Change team of CP via LUA?
Posted: Thu Jun 05, 2014 2:39 pm
by commanderawesome
Hmm... it's not working for some reason.
My code:
also tried:
Re: Change team of CP via LUA?
Posted: Thu Jun 05, 2014 3:02 pm
by Marth8880
Make sure you're putting it in ScriptPostLoad.
Re: Change team of CP via LUA?
Posted: Thu Jun 05, 2014 3:44 pm
by commanderawesome
Marth8880 wrote:Make sure you're putting it in ScriptPostLoad.
It works, I just need to figure out what all the cp's are.
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?
Re: Change team of CP via LUA?
Posted: Sun Jun 08, 2014 6:20 pm
by LRKfm946
commanderawesome wrote:Does anyone know what the central CP on Mygeeto Conquest is called in the 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.
Re: Change team of CP via LUA? [Solved]
Posted: Tue Jun 10, 2014 8:27 am
by ZoomV
LRKfm946 wrote:It was just extra info in case anyone was searching for the topic.
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.
Re: Change team of CP via LUA? [Solved]
Posted: Tue Jun 10, 2014 12:35 pm
by LRKfm946
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.
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.
Re: Change team of CP via LUA?
Posted: Tue Jun 10, 2014 1:48 pm
by commanderawesome
LRKfm946 wrote:commanderawesome wrote:Does anyone know what the central CP on Mygeeto Conquest is called in the 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.
I was kinda hoping someone would already know. I'm not good at using ZE.
Re: Change team of CP via LUA? [Solved]
Posted: Tue Jun 10, 2014 5:54 pm
by AQT
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.
Re: Change team of CP via LUA? [Solved]
Posted: Tue Jun 10, 2014 6:45 pm
by commanderawesome
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.
Thanks. Quick Question, can these files be used to modify properties of the map? (I.E command posts, vehicle spawns, etc)
Re: Change team of CP via LUA? [Solved]
Posted: Wed Jun 11, 2014 4:21 pm
by LRKfm946
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.
Re: Change team of CP via LUA? [Solved]
Posted: Wed Jun 11, 2014 4:59 pm
by commanderawesome
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.
Thanks!
Re: Change team of CP via LUA? [Solved]
Posted: Thu Jun 12, 2014 7:52 am
by [RDH]Zerted
Changing CP team via LUA is tricky online. In order the client to see a CP change team, the CP must be taken "naturally"...
Have you ever tried changing both the team and perceived team properties? Example:
Code: Select all
SetProperty("cp1", "Team", 1)
SetProperty("cp1", "PerceivedTeam", 1)
Re: Change team of CP via LUA? [Solved]
Posted: Thu Jun 12, 2014 3:51 pm
by LRKfm946
[RDH]Zerted wrote:Changing CP team via LUA is tricky online. In order the client to see a CP change team, the CP must be taken "naturally"...
Have you ever tried changing both the team and perceived team properties? Example:
Code: Select all
SetProperty("cp1", "Team", 1)
SetProperty("cp1", "PerceivedTeam", 1)
Yep I think so.