Author Topic: ~Flood Mod 2.0 Programming Guide!~  (Read 706 times)

0 Members and 1 Guest are viewing this topic.

Offline Krasher

  • -=RND Help Center=-
  • WaffleBBQrz
  • ******
  • Posts: 2764
  • Karma: +75/-47
  • Gender: Male
  • PM me if you have questions.
    • View Profile
    • Forum Page
~Flood Mod 2.0 Programming Guide!~
« on: January 30, 2010, 07:19:38 PM »
~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: [Select]
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:
Code: [Select]
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:
Code: [Select]
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:)
Code: [Select]
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...
-Admin Application-

Follow the rules or I will you.

Offline L

  • aka Striker
  • Sr. Member
  • ****
  • Posts: 494
  • Karma: +18/-12
  • Gender: Male
  • Yes, i know dat im still Übermensch!!
    • View Profile
    • My Steam-Profile :D
Re: ~Flood Mod 2.0 Programming Guide!~
« Reply #1 on: February 14, 2010, 07:17:18 PM »
wow itz acually like e2 :D



yes, of course a german server....

Offline Krasher

  • -=RND Help Center=-
  • WaffleBBQrz
  • ******
  • Posts: 2764
  • Karma: +75/-47
  • Gender: Male
  • PM me if you have questions.
    • View Profile
    • Forum Page
Re: ~Flood Mod 2.0 Programming Guide!~
« Reply #2 on: February 14, 2010, 07:25:44 PM »
wow itz acually like e2 :D
Its LUA


... -___- so is e2
lol
-Admin Application-

Follow the rules or I will you.

Offline Frank

  • No.
  • WaffleBBQrz
  • ******
  • Posts: 4058
  • Karma: +94/-45
  • Gender: Male
    • View Profile
Re: ~Flood Mod 2.0 Programming Guide!~
« Reply #3 on: February 14, 2010, 07:32:44 PM »
xfire :/

Offline Boat Sinker

  • Buddhist
  • Übermensch
  • *****
  • Posts: 827
  • Karma: +30/-40
  • Gender: Male
  • Ohai
    • View Profile
    • youtube.com/bowlingfreak218
Re: ~Flood Mod 2.0 Programming Guide!~
« Reply #4 on: February 15, 2010, 06:55:29 PM »
cool man