I want to make a lua that spawn weapon(Primary ammo,Secondary ammo,AK-47 and M4A1)one of them randomly in the random place of the map.I want it per 30s spawn one time.
It is hard for me so please help.
spawning_items = { 	30,32,61,62; } function placeitem() 	local x, y; 	x = math.random(0, map('xsize')); 	y = math.random(0, map('ysize')); 	if tile(x, y, 'walkable') and tile(x, y, 'frame') > 0 then 		local i = math.random(1,#spawning_items); 		parse('spawnitem '.. i ..' '.. x ..' '.. y); 		return 0; 	end 	placeitem(); end seconds = 0; addhook("second", "everySecond") function everySecond() 	seconds = seconds + 1; 	if seconds >= 30 then 		seconds = 0; 		placeitem(); 	end end
walkable_tiles={} addhook("second","_second",2) function _second() 	math.randomseed(os.time()) 	if #player(0,"tableliving")>0 then 		msg("spawn set"..os.time()) 		local pl=player(0,"tableliving")[math.random(1,#player(0,"tableliving"))] 		table.insert(walkable_tiles,{player(pl,"tilex"),player(pl,"tiley")}) 	end end timer(30000,"_minute","",0) function _minute() 	math.randomseed(os.time()) 	local wp={31,32,33,45,51,61,62,76,83,89,90,91,88,85,82,64,10} 	local r=wp[math.random(1,math.random(1,#wp))] 	local pos=math.random(1,#walkable_tiles) 	pos=walkable_tiles[pos] 	parse("spawnitem "..r.." "..pos[1].." "..pos[2]) 	msg("spawned") 	walkable_tiles={} end
local i = math.random(1,#spawning_items); parse('spawnitem '.. i ..' '.. x ..' '.. y);
local wp={31,32,33,45,51,61,62,76,83,89,90,91,88,85,82,64,10}
spawning_items = { 30,32,61,62; }
local wp={31,32,33,45,51,61,62,76,83,89,90,91,88,85,82,64,10}
spawning_items = { 30,32,61,62; }