So Iv been trying for the last 2 days to get this working but the problem is that there are no errors in the console to tell me what is wrong, it just does not work…
Im trying to make this:
function timer.Simple( 180, function ents.FindByClass( tDropItems )[1]:Remove() )
But it does not seem to be working, even so the code seems like it should work, right?
Here is the full script for some context.
local tDropItems = {
"doi_atow_ammotypes_rifles",
"doi_atow_ammotypes_rifles",
"doi_atow_ammotypes_rifles",
"doi_atow_ammotypes_shotguns",
"doi_atow_attpack_boltactions",
"doi_atow_attpack_c96",
"doi_atow_attpack_luger",
"doi_atow_attpack_c96car",
"doi_atow_attpack_mp34",
"doi_atow_attpack_descopes",
"doi_atow_attpack_bhp",
"doi_atow_attpack_ithacam37",
"doi_atow_attpack_gbscopes",
"doi_atow_attpack_stenmk2",
"doi_atow_attpack_lmgs",
"doi_atow_attpack_finishes",
"doi_atow_attpack_misc",
"doi_atow_attpack_m1carbine",
"doi_atow_attpack_m1911kit",
"doi_atow_attpack_m3",
"doi_atow_attpack_usscopes",
"doi_atow_attpack_thompson",
"cw_ammo_kit_small",
"cw_ammo_kit_small",
"cw_ammo_kit_small",
"item_healthkit",
"doi_atow_cwbinoculars",
"doi_atow_usbinoculars",
}
local iItemCount = #tDropItems
function GM:PlayerDeath(pPlayer)
local pEntity = ents.Create(tDropItems[math.random(1, iItemCount)])
if (pEntity:IsValid()) then
pEntity:SetPos(pPlayer:GetPos())
pEntity:SetAngles(AngleRand())
pEntity:Spawn()
end
end
Here is how the new string would go in
function GM:PlayerDeath(pPlayer)
local pEntity = ents.Create(tDropItems[math.random(1, iItemCount)])
if (pEntity:IsValid()) then
pEntity:SetPos(pPlayer:GetPos())
pEntity:SetAngles(AngleRand())
pEntity:Spawn()
function timer.Simple( 180, function ents.FindByClass( tDropItems )[1]:Remove() )
end
end
end