~Flood Mod 2.0 Programming Guide!~
Ever wonder How I am making Flood Mod 2.0? In this guide I will show you all of the tricks and coding I used, so you may learn a little about lua, and be able to make a custom Version of Flood!
~Before We get Started!~
~Adding Weapons!~
Ever wanted to have a certain weapon, but it wasn't there? Here is how to add your own!
At the bottom of cl_init.lua, add this to the weapon info array.Code:
WeaponInfo[6] = {
MDL = "models/weapons/w_mach_m249para.mdl",
Weapon = "weapon_para",
Tip = "Name: Para\nCost: $20000\nDamage: 9\nAmmo: 180 - Uses TMP\nInfo: Spawns with you every round."
}
Head to init.lua, look for this.Code:
function GM:EntityTakeDamage( ent, inflictor, attacker, amount )
if TimerStatus == 1 or TimerStatus == 4 then
return false
else
if ent:IsPlayer() then
--Rawr
else
if attacker:IsPlayer() then
if attacker:GetActiveWeapon() != NULL then
if attacker:GetActiveWeapon():GetClass() == "weapon_pistol" then
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - 1)
elseif attacker:GetActiveWeapon():GetClass() == "weapon_crossbow" then
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - 10)
elseif attacker:GetActiveWeapon():GetClass() == "weapon_para" then
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - 7)
elseif attacker:GetActiveWeapon():GetClass() == "weapon_rpg" then
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - 30)
elseif attacker:GetActiveWeapon():GetClass() == "weapon_deagle" then
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - 3)
elseif attacker:GetActiveWeapon():GetClass() == "weapon_357" then
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - 4)
elseif attacker:GetActiveWeapon():GetClass() == "weapon_tmp" then
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - 3)
end
end
else
if attacker:GetClass() == "entityflame" then
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - .5)
else
ent:SetNWInt("PropHealth", ent:GetNWInt("PropHealth") - 1)
end
end
if ent:GetNWInt("PropHealth") <= 0 and ent:IsValid() then
ent:Remove()
end
end
end
end
On players.lua, goto line with the Purchase function. Add a entry like this.Code:
elseif Weapon == "weapon_para" then
if pl:GetNWInt("Cash") >= 20000 then
pl:SetNWInt("Cash", pl:GetNWInt("Cash") - 20000)
DoIt(pl, Weapon)
pl:ChatPrint("Para Purchased")
else
pl:ChatPrint("You do not have enough cash for this!")
end
And finally, still in the Players.lua, scroll down until you get to the GivePistols Function, (Should look like this:)
function GivePistols()
for k,v in pairs(player.GetAll()) do
if v:Alive() then
if v.Weapons then
for key, wep in pairs(v.Weapons) do
v:Give(wep)
v:GiveAmmo(9999, "Pistol")
v:GiveAmmo(9999, "357")
if wep == "weapon_crossbow" then
v:GiveAmmo(9999, "XBowBolt")
elseif wep == "weapon_tmp" or wep == "weapon_para" then
v:RemoveAmmo(9999, "SMG1")
v:GiveAmmo(155, "SMG1")
elseif wep == "weapon_rpg" then
v:RemoveAmmo(9999, "weapon_rpg")
v:GiveAmmo(3, "weapon_rpg")
end
end
else
v:Give("weapon_pistol")
v:GiveAmmo(999999, "Pistol")
end
end
end
end
Note: The Code I made shares the Para Ammo with the TMP ammo...