Author Topic: Error and need help  (Read 1866 times)

0 Members and 2 Guests are viewing this topic.

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Error and need help
« on: September 28, 2014, 12:15:42 PM »
So im coding a TTT Event gamemode and im gettin really pissed when i see this and cant fix it: http://gyazo.com/fa00a8cc3eb41cdb83de93ff22b6c761

Heres my code
Code: [Select]
local EVENT = {}

if SERVER then

function EVENT:Prepare()
self:EventNotification()

self:SmallNotification(_, {
"Juggernauts Have alot of health but only crowbars",
"Innocents know who Juggernuts are and must kill them",
"Innocents spawn with a HUGE with 1000 bullets",
}, 15)
end

function EVENT:GiveKnife(ply)
local wep = ply:Give("weapon_zm_improvised")
wep.AllowDrop = false
wep.OnDrop = function(self) -- Remove H.U.G.E on drop
self:Remove()
end
wep.SecondaryAttack = function() end
self:ModWepToPushVisOnAtck(wep)

timer.Simple(0.1, function()
if not IsValid(ply) then return end
ply:SelectWeapon("weapon_zm_improvised") -- meh
end)
end

local allowed_weapons = {
"weapon_zm_carry",
"weapon_zm_improvised"
}

function EVENT:Begin()
for _,ply in pairs(player.GetAll()) do
ply:Flashlight( false )
if ply:GetRole() == ROLE_TRAITOR then

ply:SetHealth(500)
ply:SetColor(Color(0, 0, 255))

ply:StripWeapons()

if ply:GetRole() == ROLE_INNOCENT then
for _,aw in pairs(allowed_weapons) do
if aw ~= "weapon_zm_sledge" then -- Handled in self.GiveKnife
local wep = ply:Give(aw)
if IsValid(wep) then self:ModWepToPushVisOnAtck(wep) end
end
end
end
end

function DrawJuggernutIndicator(ply)
local zOffset = 50
local x = ply:GetPos().x //Get the X position of our player
local y = ply:GetPos().y //Get the Y position of our player
local z = ply:GetPos().z //Get the Z position of our player
local pos = Vector(x,y,z+zOffset) //Add our offset onto the Vector
local pos2d = pos:ToScreen() //Change the 3D vector to a 2D one
draw.DrawText("Juggernut","Default",pos2d.x,pos2d.y,Color(255,255,255,255),TEXT_ALIGN_CENTER) //Draw the indicator
end

function LoopThroughPlayers()
for k,v in(player.GetAll()) do //Loop through all the players
if ply:GetRole() == ROLE_TRAITOR then //Check if they're a Traitor
DrawJuggernutIndicator(v) //Call our draw "Juggernut" func
end
end
end

hook.Add("HUDPaint", "LoopThroughPlayers", LoopThroughPlayers) //Add our function to the HUDPaint hook


self:AddHook("WyoziTEVPlayerSpeed", self.ModifyStalkersSpeed)
self:AddHook("PlayerSwitchWeapon", self.PreventStalkerWepSwitch)
self:AddHook("Think")
self:AddHook("EntityTakeDamage")
self:AddHook("KeyPress")
end

function EVENT:End()
self:CleanUpHooks()
for _,ply in pairs(player.GetAll()) do
ply.PushPlayerVis = nil
self:SetPlayerInvisibility(ply, false)
ply:SetColor(Color(255, 255, 255))
end
end

function EVENT:ModifyStalkersSpeed(ply)
return ply:GetRole() == ROLE_TRAITOR and 1.45 or 1
end

function EVENT:PreventStalkerWepSwitch(ply, oldwep, newwep)
if ply:GetRole() == ROLE_TRAITOR and not table.HasValue(allowed_weapons, newwep:GetClass()) then
timer.Simple(0, function()
if not IsValid(ply) then return end
ply:SelectWeapon("weapon_zm_improvised")
end)
end
end

-- Longjump stuff
function EVENT:KeyPress(ply, key)
if (ply:Alive() && key == IN_JUMP && ply:WaterLevel() <= 1 && ply:IsOnGround()) then
if (ply:GetRole() == ROLE_TRAITOR and ply:KeyDown(IN_DUCK) && ply:KeyDown(IN_FORWARD) && ply:GetVelocity():Length() >= 200) then
ply:SetVelocity((ply:GetUp() * 300) + (ply:GetForward() * 425))
end
end
end

function EVENT:Think()
for _,ply in pairs(player.GetAll()) do
if ply:GetRole() == ROLE_TRAITOR and not ply:HasWeapon("weapon_zm_improvised") then
self:GiveKnife(ply)
end
end
end

function EVENT:EntityTakeDamage(targ, dmginfo)
if (targ:IsPlayer() and targ:GetRole() == ROLE_TRAITOR ) then
if (dmginfo:IsDamageType(DMG_FALL)) then
dmginfo:ScaleDamage(0.3)
else
end
end
end

end
if CLIENT then

local wtev_halos = CreateConVar("wyozitev_stalker_halos", "0", FCVAR_ARCHIVE)

function EVENT:Begin()
self:AddHook("PreDrawHalos", self.DrawStalkerWH)
end

function EVENT:DrawStalkerWH()
if not wtev_halos:GetBool() then return end

local me = LocalPlayer()
if me:IsActiveTraitor() then

local reds = {}
local greens = {}
for _,ply in pairs( player.GetAll() ) do
if not ply:IsTerror() or not ply:Alive() then continue end

if ply:IsActiveTraitor() then
table.insert(reds, ply)
else
table.insert(greens, ply)
end
end

effects.halo.Add( reds, COLOR_RED, _, _, _, true, true )
effects.halo.Add( greens, COLOR_GREEN, _, _, _, true, true )

end
end

end

EVENT.RequireClientside = true

wyozitev.RegisterEvent("juggernut", EVENT)
Newb Coder. Soon to get better

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: Error and need help
« Reply #1 on: September 28, 2014, 01:50:03 PM »
Nevermind. I messed around and fixed.
Newb Coder. Soon to get better