Two NPC questions and: How do I create a money system?

I have three questions; it’s up to you to answer however many you want. Thank you very much!

How do I set up a money system for changing the model of your weapons, playermodel and upgrading speed and damage? Thank you!

Okay, so I want two teams of NPCs that are supposed to run towards each other and then fight.
I also want the players to be able to press a button that allows NPCs damage/health to go up.

  1. How do I make the NPCs ignore/follow the players on their team but make them target the players on the other team?

  2. How do I make a button that allows NPCs damage/health to go up?

Thanks!

For the first question, I use a handy function that makes my npcs love me and my allies, but hate everyone else.

[lua]local function MakeFriendly(ply,npc)
npc:AddEntityRelationship(ply,3,99)
for ,v in ipairs(ents.FindByClass("npc*")) do if v:Disposition(ply) == 3 then
npc:AddEntityRelationship(v,3,99)
v:AddEntityRelationship(npc,3,99)
else npc:AddEntityRelationship(v,1,99) end
end
end[/lua]

And you can modify that however you want.

For the second question, you would just make a button entity with the ENT:Use() function doing NPC:SetHealth().

For the money system, it depends on how you want to do it. For most money systems, people use networked integers; i.e. player:SetNWInt(“Cash”,1000)

Then to check whether someone could buy something it would be:

[lua]function CanBuy(ply,amt)
if ply:GetNWInt(“Cash”) < amt then return false
else return true
end[/lua]

And one last thing: if you want the NPCs to attack a specific point or NPC (if they’re combine or rebel), use npc:Fire(“Assault”,“point of interest”,0).

For example, I have a function that makes an npc assault the enemy they’re already attacking after a given amount of time:

[lua]local function DoAssault(time)
timer.Simple(time,function()
if npc:IsValid() and npc:GetEnemy() then
npc:GetEnemy():SetName(ply:SteamID()…“assault”)
npc:Fire(“Assault”,ply:SteamID()…“assault”,0)
end
end)
end[/lua]

However, using Assault effectively requires NPCs be in the same squad. To do this, you use npc:SetKeyValue(“squadname”,“combinesquad”) or “rebelsquad” or whatever you want.

For more info on the inputs/outputs of combine/rebel NPCs, refer here:

npc_combine_s is the combine guard, soldier, and super soldier (use npc_metropolice for the metrocops).

npc_citizen is pretty much every human NPC except the special characters (alyx, kleiner, barney, etc).

Thank you very much! You are one of the most helpful people I’ve ever come across in my life so far!
I have another question about this function:

How would I change all the NPCs to a certain kind of them, and how would I define which NPCs liked either team one or team two?

Erm, I’m not entirely sure what you’re asking. “change all the NPCs to a certain kind of them” - do you mean change their class? Or do you mean only make them hate/like certain other npcs?

Like, what this does is it finds all other npcs and checks if they’re friendly; if not, it hates them.

To change that, you would have to change the “for _,v in ipairs(ents.FindByClass(etc.))” part to whatever entities you needed.

Yes I meant that one.
Please excuse my bad English!