Tech Lounge > Programming
~Flood Mod 2.0 Programming Guide!~
(1/1)
Krasher:
~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!~Download Flood from http://www.garrysmod.org/downloads/?a=view&id=56601, put it in the gamemodes folder at
C:\Program Files\Steam\steamapps\<*your steam name*>\garrysmod\garrysmod\gamemodes
~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:
--- 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."
}
--- End code ---
Head to init.lua, look for this.
Code:
--- 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
--- End code ---
On players.lua, goto line with the Purchase function. Add a entry like this.
Code:
--- 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
--- End code ---
And finally, still in the Players.lua, scroll down until you get to the GivePistols Function,
(Should look like this:)
--- Code: ---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
--- End code ---
Note: The Code I made shares the Para Ammo with the TMP ammo...
L:
wow itz acually like e2 :D
Krasher:
--- Quote from: xXTheStrikerXx on February 14, 2010, 07:17:18 PM ---wow itz acually like e2 :D
--- End quote ---
Its LUA
... -___- so is e2
lol
Frank:
xfire :/
Boat Sinker:
cool man
Navigation
[0] Message Index
Go to full version