10-10-2014, 07:06 AM
Im trying to create a plugin that spawns a mob via command, having downloaded the newest version from the website this is the error message I am receiving and my code.
Code:
Warn [15:45:42] LUA: Plugins/mine/spawnmob.lua:30: error in function 'SpawnMob'.
argument #-1806946488 is array of '[no object]'; array of 'H‹\$@¸' expected.
Warn [15:45:42] Stack trace:
Warn [15:45:42] [C](-1): SpawnMob
Warn [15:45:42] Plugins/mine/spawnmob.lua(30): (no name)
Warn [15:45:42] Stack trace end
Warn [15:45:42] Error in plugin mine calling function <callback>()function HandleSpawnMobCommand(Split, Player)
-- Make sure there are a correct number of arguments.
if ((#Split ~= 2) and (#Split ~=3)) then
Player:SendMessage("Usage: /spawnmob <mobname> [number]" )
return true
end
-- Mob name as typed in by the player
local MobName = Split[2]
-- Mob Type based
local MobType = cMonster:StringToMobType(Split[2])
if MobType == -1 then
Player:SendMessage("Mob " .. MobName .. " not found")
return true
end
if Split[3] ~= nil then
-- Don't allow more then 10 mobs to be spawned at once.
local ammount = tonumber(Split[3])
if ammount > 10 then
Player:SendMessage("Max mob spawn is 10.")
ammount = 10
end
for i=0,ammount do
Player:GetWorld():SpawnMob(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ(), MobType)
end
Player:SendMessage("Spawned " .. ammount .. " " .. MobName .. "s")
return true
else
Player:GetWorld():SpawnMob(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ(), MobType)
Player:SendMessage("Spawned 1 " .. MobName)
end
return true;
end


)