• 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!

[Mods] First Items bugged

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="1.0" author="Darkhaos" contact="None" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		local items =
		{
			voc =
			{
				{
				{2190}, -- wand of vortex
				{2175}, -- spellbook
				{8820}, -- mage hat
				{8819}, -- mage robe
				{2464} -- chain armor
				},
				{
				{2182}, -- snakebite rod
				{2175}, -- spellbook
				{8820}, -- mage hat
				{8819}, -- mage robe
				{2464} -- chain armor
				},
				{
				{2455}, -- crossbow
				{2544}, -- arrow
				{2463}, -- plate armor
				{2647}, -- plate legs
				{2457} -- steel helment
				},
				{
				{2383}, -- spike sword
				{2525}, -- dwarven shield
				{2463}, -- plate armor
				{2647} -- plate legs
				}
			},
			all = {
				{item = 2152, count = 25},
				{item = 2643} -- leather boots
			}
		}
 
		local storage = 67777
		local c = nil
	]]></config>
	<event type="login" name="FirstItems" event="script"><![CDATA[
		domodlib('firstitems_config')
 
	function onLogin(cid)
 
		if(getCreatureStorage(cid, storage) < 1 then
			for i = 1, 4 do
				if getPlayerVocation(cid) == i then
					for t = 1, table.maxn(items.voc[i]) do
						c = 1
						if tonumber(items.voc[i][t].count) then
							c = items.voc[i][t].count
						end
						doPlayerAddItem(cid, items.voc[i][t].item, c)
					end
				end
			end
 
			for i = 1, table.maxn(items.all) do
				c = 1
				if tonumber(items.all[i].count) then
					c = items.all[i].count
				end
				doPlayerAddItem(cid, items.all[i].item, c)
			end
 
			end
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have received the " .. getVocationInfo(getPlayerVocation(cid)).name .. "'s first items.")
			doCreatureSetStorage(cid, storage, 1)
		end
		return true
	end
	]]></event>
</mod>

thx all '-'

Error:
Assertion failed: m_scriptEnvIndex >= 0 && m_scriptEnvIndex <21, file ../luascript.h line 264
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		STORAGE = 30001
		commonItems = {
			{itemid=2160, count=3, inContainer = true}, -- 2 platinum coins
			{itemid=2643} -- leather boots
		}
		firstItems = {
			{ -- Sorcerer	
				{itemid=1988}, -- backpack
				{itemid=2521}, -- dark shield
				{itemid=2190}, -- wand of vortex
				{itemid=8819}, -- magician's robe
				{itemid=8820}, -- mage hat
				{itemid=7730}  -- blue legs
			},
			{ -- Druid
				{itemid=1988}, -- backpack
				{itemid=2521}, -- dark shield
				{itemid=2182}, -- snakebite rod
				{itemid=8819}, -- magician's robe
				{itemid=8820}, -- mage hat
				{itemid=7730}  -- blue legs
			},
			{ -- Paladin
				{itemid=1988}, -- backpack
				{itemid=2521}, -- dark shield
				{itemid=2389, count=3}, -- 3 spears
				{itemid=2463}, -- plate armor
				{itemid=2457}, -- steel helmet
				{itemid=2647}  -- plate legs
			},
			{ -- Knight
				{itemid=1988}, -- backpack
				{itemid=2521}, -- dark shield
				{itemid=2394}, -- morning star
				{itemid=2463}, -- plate armor
				{itemid=2457}, -- steel helmet
				{itemid=2647}  -- plate legs
			}
		}
	]]></config>
	<event type="login" name="FirstItems" event="script"><![CDATA[
		domodlib('firstitems_config')

		for _, items in ipairs(firstItems) do
			for _, item in ipairs(commonItems) do
				table.insert(items, item)
			end
		end

		function onLogin(cid)
			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
					if isItemContainer(v.itemid) then
						backpack = doPlayerAddItem(cid, v.itemid, 1)
					elseif v.inContainer then
						doAddContainerItem(backpack, v.itemid, v.count or 1)
					else
						doPlayerAddItem(cid, v.itemid, v.count or 1)
					end
				end
				setPlayerStorageValue(cid, STORAGE, 1)
			end
			return true
		end
	]]></event>
</mod>
!!!
 
Last edited:
Back
Top