There are the two functions in shared.lua that rely on events.lua
function chooseEvent()
eventType = 0
eventID = math.random(0,3)
PrintMessage(HUD_PRINTTALK,typeName(eventType) .. ": " .. eventName(eventID,eventType))
end
function runEvent(players)
for i=1,players do
local ply = table.Random(team.GetPlayers(1)) --player.GetAll()[math.random(1,player.GetCount())]
PrintMessage(HUD_PRINTTALK, "Plate Affected: " .. ply:GetName())
if eventID == 0 then evPlatformSize(ply, 1.1)
elseif eventID == 1 then evPlatformSize(ply, 0.9)
elseif eventID == 2 then evPlatformBarrel(ply)
elseif eventID == 3 then evPlatformSpin(ply)
end
end
end
and this is events.lua:
function eventName(id,type)
if type == 0 then
if id == 0 then return "Platform Growth (10%)"
elseif id == 1 then return "Platform Shrink (10%)"
elseif id == 2 then return "Explosive Barrel"
elseif id == 3 then return "Spinning Plate"
else return "ERROR" end
else return "ERROR" end
end
function typeName(type)
if type == 0 then return "Platform Event"
elseif type == 1 then return "Player Event"
elseif type == 2 then return "World Event"
else return "ERROR" end
end
function evPlatformSize(ply, percent)
local platform = platforms[numbers[ply:AccountID()]]
if platform ~= nil then
local offset = (3.5 * platform:GetModelScale() * percent) - (3.5 * platform:GetModelScale())
if offset > 0 then platform:SetPos(Vector(platform:GetPos().x,platform:GetPos().y,platform:GetPos().z-offset)) end
platform:SetModelScale(platform:GetModelScale() * percent, 0)
--ply:SetPos(Vector(ply:GetPos().x,ply:GetPos().y,ply:GetPos().z+0.1))
platform:Activate()
else print("PLATFORM NOT FOUND") end
end
function evPlatformBarrel(ply)
local platform = platforms[numbers[ply:AccountID()]]
if platform ~= nil then
local xx = platform:GetPos().x + math.random(-(platform:GetModelScale()*238)/2,(platform:GetModelScale()*238)/2)
local yy = platform:GetPos().y + math.random(-(platform:GetModelScale()*238)/2,(platform:GetModelScale()*238)/2)
local barrel = ents.Create("prop_physics")
barrel:SetModel("models/props_c17/oildrum001_explosive.mdl")
barrel:Ignite(15)
barrel:SetPos(Vector(xx,yy,1000))
barrel:SetVelocity(Vector(0,0,-100))
barrel:Spawn()
local phys = barrel:GetPhysicsObject()
phys:ApplyForceCenter(Vector(0,0,-1000))
end
end
function evPlatformSpin(ply)
spinning[#spinning+1] = platforms[numbers[ply:AccountID()]]
end
Most of the variables that events.lua calls upon are found in shared.lua which i thought might have been the problem at first but it worked perfectly fine beforehand so I’m not quite sure