Author Topic: Last Prop Standing  (Read 2006 times)

0 Members and 1 Guest are viewing this topic.

Offline ? Dilly ?

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Last Prop Standing
« on: June 30, 2015, 05:28:14 PM »
So, a friend and myself have been trying to get last prop standing to work, (for those who dont know, it gives the last prop alive a weapon to kill hunters.) We can't manage to figure out how to allow the damage to hunters, by props... here what we have so far;
For the init.lua file, on line 76, we have the following

function GM:PlayerCanPickupWeapon(pl, ent)
local prop_alive = {}
for k,pl in pairs( team.GetPlayers(TEAM_PROPS) ) do
if pl:Alive() then table.insert( prop_alive, pl ) end
end
if pl:Team() == TEAM_PROPS && table.Count(prop_alive) == 1 then
return true
end

if pl:Team() == TEAM_HUNTERS then
return true
end

return false
end

and for class_prop we have;
-- Called by spawn and sets loadout
function CLASS:Loadout(pl)
--Last Prop Standing
pl.IsLastProp = true // Setting the variable for the player.
pl:Give("m9k_winchester73")
pl:CrosshairEnable()
end


now, we saw that on line 63 of the Init file, we have

-- Called when an entity takes damage
function EntityTakeDamage(ent, dmginfo)
    local att = dmginfo:GetAttacker()
   if GAMEMODE:InRound() && ent && (ent:GetClass() != "ph_prop" && ent:GetClass() != "func_breakable" && ent:GetClass() != "prop_door_rotating" && ent:GetClass() != "prop_dynamic*") && !ent:IsPlayer() && att && att:IsPlayer() && att:Team() == TEAM_HUNTERS && att:Alive() then
      att:SetHealth(att:Health() - HUNTER_FIRE_PENALTY)
      if att:Health() <= 0 then
         MsgAll(att:Name() .. " felt guilty for hurting so many innocent props and committed suicide\n")
         att:Kill()
      end
   end
end
hook.Add("EntityTakeDamage", "PH_EntityTakeDamage", EntityTakeDamage)



We figure this is where we'd put it.....yet we cant figure out what to do to allow the props to kill the hunters...

This is the last spot i know to check, and it may be a long shot, but id greatly appreciate any, and all the help you guys can give me, thank you in advance, and have a good day/night.
ill check on this periodically for any responses.