NPC and LOOT spawners.

I’m making a server (involving NPCs and finding items), but my knowledge of lua is little. So is somebody able to make a script where I can set a npc to spawn at a certain POS. Same with loot but having random drops like.

LIST AT POS -11044.439453 237.821014 240.474350
cstm_rif_ak47cstm
cstm_rif_ak74
cstm_rif_ak74u

Script will pick one at random and spawn it there at random times, If the entity is still there not have been picked up it wont spawn a pile of guns or something.
Same goes for npcs

I can think of several recent topics in this very section that would address most if not all of your questions. If you plan to open a server it would be a good idea to, rather than ask other people to do something for you, get better at researching these things and doing it yourself.

Just to make sure I’m not misunderstood: I’m not trying to be rude, just trying to give advice.

Inb4 gmod dayz, just look at jackools gamemode, it’s not the best example but it’s public and free, check my latest threads.

Ok my friend gave me this he says he has an idea of how its done he said dont test it untill i can find sombody to say it works



 //-4540.921875 -2186.748535 136.045258
 itemsTable = {"item_healthkit", "sent_siku_crate", "item_ammo_357", "item_ammo_ar2", "item_ammo_ar2_altfire", "combine_mine", "item_ammo_crossbow", "item_healthvial", "item_ammo_pistol", "item_rpg_round", "item_box_buckshot", "item_ammo_smg1", "item_battery", "weapon_bfg_beta_spas", "weapon_bfg_assasin_pistols", "weapon_bfg_hmg", "weapon_bfg_iceaxe", "weapon_bfg_oicw", "weapon_bfg_mp7", "weapon_bfg_smg2", "weapon_bfg_hl2_sniper", "weapon_bfg_ar1"}

 function DoSpawnItem()
 
 for i = 1, 1 do
	local item = ents.Create( table.Random( itemsTable ) )
	
	item:SetPos( Vector( -5154.091797, -2324.860596, 163.884003) )
	item:Spawn()
	
end
end
timer.Create("Spawnitem", 280, 0, DoSpawnItem)


Ew hard coded

So its harder to use as it is?

Well yes, it’s going to be hard to setup the spawn points(assuming there are many) by manually inputting the cords for each one. I again recommend looking at my latest threads and finding jackools gamemode.(http://forum.facepunch.com/showthread.php?t=1310494) it’s again not the best but you can get the idea.

i did this for a now defunct zombieRP server back in the day, my method was similar to the code that you posted but instead of having hardcoded spawns i used invisible entities that would spawn loot and npcs. I then made an admin only console command that would allow you to go into ‘edit mode’ where you were able to see the spawns and move them, delete them etc

[lua]
//-4540.921875 -2186.748535 136.045258
itemsTable = {“item_healthkit”, “sent_siku_crate”, “item_ammo_357”, “item_ammo_ar2”, “item_ammo_ar2_altfire”, “combine_mine”, “item_ammo_crossbow”, “item_healthvial”, “item_ammo_pistol”, “item_rpg_round”, “item_box_buckshot”, “item_ammo_smg1”, “item_battery”, “weapon_bfg_beta_spas”, “weapon_bfg_assasin_pistols”, “weapon_bfg_hmg”, “weapon_bfg_iceaxe”, “weapon_bfg_oicw”, “weapon_bfg_mp7”, “weapon_bfg_smg2”, “weapon_bfg_hl2_sniper”, “weapon_bfg_ar1”}

local poses = {Vector(228,134,135), Vector(1337,1337,1337), Vector(666,666,666)}//Fucken poses where ur weps will spawn
local itemstospawnpertime = 2//how many gyns will spawn per time
local timebetweenspawns = 280//difference in time between spawns

function DoSpawnItem()

for i = 1, itemstospawnpertime do
local item = ents.Create( table.Random( itemsTable ) )

item:SetPos( table.Random(poses) )
item:Spawn()

end
end
timer.Create(“Spawnitem”, timebetweenspawns, 0, DoSpawnItem)
[/lua]

Just added some fucking variables