View unanswered posts | View active topics It is currently Sat Oct 19, 2019 1:40 pm



Reply to topic  [ 10 posts ] 
 A quick question.. 
Author Message

Joined: Sun Dec 16, 2012 8:33 pm
Posts: 6
Reply with quote
Post A quick question..
Hello, is there a way to make it so that your mod is only available to a certain team? I swore I had seen some variable related but I can't find it now. Thanks for any replies!


Sun Dec 16, 2012 8:35 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: A quick question..
Define 'team'. Do you mean as in the red/green/blue/yellow teams, or as in a mod 'faction'?


Mon Dec 17, 2012 12:02 am
Profile YIM

Joined: Sun Dec 16, 2012 8:33 pm
Posts: 6
Reply with quote
Post Re: A quick question..
I mean team as in the different colors. Say I am playing with my brother. He makes his own modded weapons, and I make mine. What line of code can I add so that my weapons are only available in the Drop menu to my team (Red) and not his team (Blue) and vise-versa.


Mon Dec 17, 2012 2:49 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: A quick question..
I don't think that's possible to do.

Well, at least not in an easy way. You could add a script to all of the things belonging to that faction and make them gib if they are part of another team.


Mon Dec 17, 2012 3:01 am
Profile

Joined: Sun Dec 16, 2012 8:33 pm
Posts: 6
Reply with quote
Post Re: A quick question..
It is like four different objects.. Would it be a lot of code to make them gib if it isn't held by the right team? That sounds very interesting


Mon Dec 17, 2012 3:41 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 661
Location: Halifax, Canada
Reply with quote
Post Re: A quick question..
Try this, it should delete the actor if it's not on the desired team and refund its cost. Note that it won't work for items like guns or bombs, as that'd probably be a bit more difficult (I guess you'd need to find the team of the delivery craft).

You'll need to manually set the team, either directly in the script or by replacing the number with some ini writable, lua readable value (e.g. sharpness). Also, if it works but is only refunding the cost of the actor, not any items he's holding, try changing self:GetGoldValue(0 , 1); to self:GetTotalValue(0 , 1);. I'm not entirely sure if goldvalue also includes inventory items.

Note that it's untested so I can't guarantee it'll work. Enjoy.
Code:
function Create(self)
   self.DesiredTeam = 0;
   self.Refund = self:GetGoldValue(0 , 1);
end
function Update(self)
   if not self.Team == self.DesiredTeam then
      ActivityMan:GetActivity():SetTeamFunds(ActivityMan:GetActivity():GetTeamFunds(self.Team) + self.Refund , self.Team);
      self.ToDelete = true;
   end
end


Mon Dec 17, 2012 4:21 am
Profile

Joined: Sun Dec 16, 2012 8:33 pm
Posts: 6
Reply with quote
Post Re: A quick question..
Well, I've never used lua before haha. If it is going to be a struggle to do it I'll just not bother really. Thanks for the tips. Also, what I was referring to seeing once is "Team = 0" That I found in the Silver Man actor code. I thought maybe it would be what I was asking about.


Mon Dec 17, 2012 10:21 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: A quick question..
Ah, that, if I recall correctly, it makes an actor to always be part of a team.

I remember the old AAL marine that jumped out from the escape pods contained in the crafts had that line in it's code, but I can't tell if it will work on bought actors.

You can give it a try, set Team = 0 for team 1 (red team), Team = 1 for team 2(green team) and so on.


Mon Dec 17, 2012 11:22 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 661
Location: Halifax, Canada
Reply with quote
Post Re: A quick question..
It won't be trouble at all. Attach it to the actor using ScriptPath = whateveryoucallthefile.lua and change desired team to whatever team you want it for. As asklar said, 0 is red, 1 is green, etc in order.
I just took a look at the ai initialization and updating stuff and it's easy to include so here's a version that'll do everything for you. Just copy it into a text file and rename that file's extension as .lua, then attach it to your actor as mentioned above.
Code:
require("Actors/AI/NativeHumanAI")
function Create(self)
   self.AI = NativeHumanAI:Create(self)
   self.DesiredTeam = 0;
   self.Refund = self:GetGoldValue(0 , 1);
end
function Update(self)
   if not self.Team == self.DesiredTeam then
      ActivityMan:GetActivity():SetTeamFunds(ActivityMan:GetActivity():GetTeamFunds(self.Team) + self.Refund , self.Team);
      self.ToDelete = true;
   end
end
function UpdateAI(self)
   self.AI:Update(self)
end


Edit: Oh yeah, you'll need to change the two lines that say HumanAI to CrabAI and TurretAI if you're also using this for turrets or crabs. Probably the same deal with rockets or dropships.


Tue Dec 18, 2012 4:07 am
Profile
User avatar

Joined: Fri Jun 10, 2011 4:37 am
Posts: 201
Location: Oregon, USA
Reply with quote
Post Re: A quick question..
why not just make something buyable = 0 and use AddHDFirearm to add it directly to the unit, so only the unit has it use it, it may not be as magical as LUA but it sure is a hell of a lot easier.


Fri Dec 21, 2012 6:20 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.019s | 15 Queries | GZIP : Off ]