Hey guys, so I’m a little new to the forums, as well as lua, although i’ve done a little bit of java and lua before. Anyway, I found a game mode base that im working on to play with friends, but I hit a little bit of a rut with the elseif statements, can someone help me out?
-- Check 'em against max amounts. local zombiespawn = (#zombies < maxzombies) local fastzomspawn = (#fastzoms < maxfastzoms) local poisonzomspawn = (#poisonzoms < maxpoisonzoms) local antlionspawn = (#antlions < maxantlions) local antguardspawn = (#antguards < maxantguards) if zombiespawn or fastzomspawn or poisonzomspawn or antlionspawn or antguardspawn then -- Add 'em to a table with how much they need. if zombiespawn then rng1 = math.random(150) if rng1 >= 5 then spawnables["npc_vj_mwjuggernaut"] = maxzombies - #zombies end elseif rng1 >= 6 and rng1 =< 10 then spawnables["npc_loner_exo_unit"] = maxzombies - #zombies end elseif rng1 >= 11 and rng1 =< 20 then spawnables["npc_uar_veteran"] = maxzombies - #zombies end elseif rng1 >= 21 and rng1 =< 35 then spawnables["npc_monolith_s"] = maxzombies - #zombies end elseif rng1 >= 36 and rng1 =< 50 then spawnables["npc_winter_s"] = maxzombies - #zombies end elseif rng1 >= 51 and rng1 =< 65 then spawnables["npc_mil_stalker"] = maxzombies - #zombies end elseif rng1 >= 66 and rng1 =< 80 then spawnables["npc_st_bandit_master"] = maxzombies - #zombies end elseif rng1 >= 81 and rng1 =< 110 then spawnables["npc_st_bandit"] = maxzombies - #zombies end elseif rng1 >= 111 then spawnables["npc_fastzombie"] = maxzombies - #zombies end if fastzomspawn then spawnables["npc_fastzombie"] = maxfastzoms - #fastzoms end if poisonzomspawn then spawnables["npc_poisonzombie"] = maxpoisonzoms - #poisonzoms end if antlionspawn then spawnables["npc_antlion"] = maxantlions - #antlions end if antguardspawn then if math.random(1,10) == 1 then spawnables["npc_antlionguard"] = 1 end end
Right, so the spawn table fine when it can only spawn one npc all the time (etc. if I had instead of that big list just spawnables[“npc_loner_exo_unit”] would work and spawn that unit each time no problem) but what im trying to do is make the call spawn a random npc from a list of predetermined npcs, they’re all set up and work, and there arent any errors showing up in console, my biggest problem is the elseifs are connecting to the wrong ifs and causing end statements to go willy nilly everywhere. the fastzom/poisonzom/etc spawns are disabled as well, so every time it checks it should only do zombiespawn. Is there any command or something I can put in that will do what im trying to do here a little bit better?
edit: completely off topic, but I forgot an extra K in my name and I cant seem to be able to change my username, idk if I can fix that or just have to deal with the ocd all my time here, but if someone could help me fix that that would be great!