Custom gamemode help

Hello everyone! I am looking to create a custom gamemode and I was wondering if someone could help me to be able to help me to be able to spawn weapons into maps for my gamemode. Sort of like looting in DayZ so the items in said spawn points are randomized and spawned on a timer. Also if possible a way to configure a text file for each map to place each spawn coordinate for the maps. Thank you for your time and understanding!

I just tried this


function GameInitialize()
	timer.Create( "SpawnWeapon", 5, 0, InitPostEntity )
end

function GM:InitPostEntity( )

	local items = {"m9k_ak47", "m9k_deagle"}
	--items[1] = "m9k_ak47"
	--items[2] = "m9k_deagle"
	
	local ent1 = ents.Create(table.Random(items))
		ent1:SetPos( Vector( 490.336029, 19.894241, -85.017136 ) );
		ent1:Spawn()
end

The error I recieve is this


attempt to call field 'Create' (a nil value)


By your description, you clearly know what you want to do, so these pages should help you put it together:

For the co-ordinates, you could store Vectors/Angles in a Table, then save it to a txt file named after the map, with file.Write

Thank you for pointing me in the right direction! I’ll see what I can do :).

Unfortunately I have not figured this out. Im pretty new to lua and am still trying to learn. Im lost on this part.