• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua What is wrong with it?

andu

Sold 649 scripts, 25 maps and 9 events!
Joined
Aug 7, 2009
Messages
978
Solutions
17
Reaction score
373
GitHub
olrios
Twitch
jamagowy
Here is the script:
LUA:
for _, pid in ipairs(setup) do
	if pid == 200 then
		table.remove(setup, pid)
	end
end

error (wrong #2 argument~) is in line -> table.remove(setup, pid)
 
post the whole script cus i cant see the table

LUA:
local cfg = {
	baseDungeonSetup = {"TANK", "HEALER", "DPS", "DPS", "DPS"},
	...


	...
	local playerRole = {}
	local voc = getPlayerVocation(cid)
	if isInArray(cfg.vocs.tanks, voc) == true then
		table.insert(playerRole, "TANK")
	end
	if isInArray(cfg.vocs.healers, voc) == true then
		table.insert(playerRole, "HEALER")
	end
	if isInArray(cfg.vocs.dps, value) == true then
		table.insert(playerRole, "DPS")
	end

	local roleRand = math.random(1, #playerRole)
	doPlayerSendTextMessage(cid, 25, "You are a " .. playerRole[roleRand] .. ".")

	local setup = cfg.baseDungeonSetup
	for _, pid in ipairs(setup) do
		if pid == playerRole[roleRand] then
			table.remove(setup, pid)
		end
	end
	...
 
try printing pid and playerRole[roleRand]

I solved this problem by changing _ with k and table.remove(setup, pid) with table.remove(setup, k)

LUA:
local setup = cfg.baseDungeonSetup
	for k, pid in ipairs(setup) do
		if pid == playerRole[roleRand] then
			table.remove(setup, k)
		end
	end
 
Back
Top