local entType = entType || “logic_case” // logic_case, info_player_start, npc_, etc…
local spawn = ents.FindByClass(entType)
for i=1,100 do
if spawn==nil then
if i==1 then
player.GetByID(1):ChatPrint(“Entity Count: 0”)
print(spawn*:GetClass(), " ["…i…"] located at: ", spawn*:GetPos())
The previous code is in the shared.lua file of a gamemode. I want to be able to call this function via console command (hence line 16), and be able to give it arguments to change the value of entType to whatever string I give it. However, for some reason, entType is ALWAYS auto-initialized to my player. Not only that, but it ignores any arguments I try to give it from the console (by typing “fbctest “npc_*””), and continues to force entType to my player.
I need entType to be a string so I can plug it in to FindByClass. However, whenever I try to run the function, it gives me the error: **gamemodes
eospacebuild\gamemode\shared.lua:12: bad argument #1 to ‘FindByClass’ (string expected, got Player)
Can anybody tell me why 1) entType is initialized to my player, and 2) how to get this function to accept arguments from the console?
Thanks in advance.