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

Lua Check this please!

Ghazer

Member
Joined
Mar 13, 2009
Messages
350
Reaction score
6
Can you check my script I have "Advanced First Item", but I have problems with knights...

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="2.0" author="J.Dre" contact="[email protected]" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		commonItems = {
			{itemid=6103, count=1, useMessage=true}, -- a book (or whatever) with a message
			{itemid=2789, count=100, inContainer = true}, -- 100 brown mushrooms
			{itemid=2160, count=1, inContainer = true}, -- 1 crystal coin
			{itemid=2442, inContainer = true}, -- heavy machete
			{itemid=2661, count=1}, -- scarf
			{itemid=2195} -- boots of haste
		}
		firstItems = {
			{ -- Sorcerer	
				{itemid=2002}, -- blue backpack
				{itemid=2520}, -- demon shield
				{itemid=2187}, -- wand of inferno
				{itemid=8871}, -- focus cape
				{itemid=2323}, -- hat of the mad
				{itemid=7730}, -- blue legs
				{itemid=7590, count=1, inContainer=true} -- great mana potion
			},
			{ -- Druid
				{itemid=2002}, -- blue backpack
				{itemid=2520}, -- demon shield
				{itemid=2183}, -- hailstorm rod
				{itemid=8871}, -- focus cape
				{itemid=2323}, -- hat of the mad
				{itemid=7730}, -- blue legs
				{itemid=7590, count=1, inContainer=true} -- great mana potion
			},
			{ -- Paladin
				{itemid=1999}, -- yellow backpack
				{itemid=2520}, -- demon shield
				{itemid=7368}, -- assassin star
				{itemid=2492}, -- dragon scale mail
				{itemid=2498}, -- royal helmet
				{itemid=7730}, -- blue legs
				{itemid=8472, count=1, inContainer=true}, -- spirit great potion				
			},
			{ -- Knight
				{itemid=2003}, -- grey backpack
				{itemid=2520}, -- demon shield
				{itemid=2400}, -- magic sword
				{itemid=2492}, -- dragon scale mail
				{itemid=2498}, -- royal helmet
				{itemid=7730}, -- blue legs
				{itemid=2431, inContainer=true}, -- stonecutter axe
				{itemid=2421, inContainer=true}, -- thunder hammer
				{itemid=8473, count=1, inContainer=true} -- ultimate health potion
			}
		}
	]]></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(getPlayerAccess(cid) < 4 and (getPlayerLastLoginSaved(cid) < 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, false)
					elseif v.inContainer then
						doAddContainerItem(backpack, v.itemid, v.count or 1)
					elseif v.useSlot then
						doPlayerAddItem(cid, v.itemid, v.count, false, v.slotType)
					elseif v.useMessage then
						local t, k = {
							writer = "Server Staff", date = os.time(),
							text = "Welcome " .. getCreatureName(cid) .. ".\n\nOur community would like to welcome you to " .. getConfigValue('serverName') .. ". If you need help with anything, please refer to the help channel.\n\nEnjoy your time!"
						}, doPlayerAddItem(cid, v.itemid, v.count or 1, false)
						doSetItemText(k, t.text, t.writer, t.date)
					else
						doPlayerAddItem(cid, v.itemid, v.count or 1)
					end
				end
			end
 
			return true
		end
	]]></event>
</mod>

I only have problems with knights, error
Code:
[14/8/2012 10:57:1] [Error - CreatureScript Interface] 
[14/8/2012 10:57:1] 		domodlib('firstitems_config')
[14/8/2012 10:57:1]  
[14/8/2012 10:57:1] 		for _, items in ipairs(firstItems) do
[14/8/2012 10:57:1] 			for _, item in ipairs(commonItems) do
[14/8/2012 10:57:1] 				table.insert(items, item)
[14/8/2012 10:57:1] 			end
[14/8/2012 10:57:1] 		end
[14/8/2012 10:57:1]  
[14/8/2012 10:57:1] 		function onLogin(cid)
[14/8/2012 10:57:1] 			if(getPlayerAccess(cid) < 4 and (getPlayerLastLoginSaved(cid) < 1) and firstItems[getPlayerVocation(cid)]) then
[14/8/2012 10:57:1] 				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
[14/8/2012 10:57:1] 					if isItemContainer(v.itemid) then
[14/8/2012 10:57:1] 						backpack = doPlayerAddItem(cid, v.itemid, 1, false)
[14/8/2012 10:57:1] 					elseif v.inContainer then
[14/8/2012 10:57:1] 						doAddContainerItem(backpack, v.itemid, v.count or 1)
[14/8/2012 10:57:1] 					elseif v.useSlot then
[14/8/2012 10:57:1] 						doPlayerAddItem(cid, v.itemid, v.count, false, v.slotType)
[14/8/2012 10:57:1] 					elseif v.useMessage then
[14/8/2012 10:57:1] 						local t, k = {
[14/8/2012 10:57:1] 							writer = "Server Staff", date = os.time(),
[14/8/2012 10:57:1] 							text = "Welcome " .. getCreatureName(cid) .. ".\n\nOur community would like to welcome you to " .. getConfigValue('serverName') .. ". If you need help with anything, please refer to the help channel.\n\nEnjoy your time!"
[14/8/2012 10:57:1] 						}, doPlayerAddItem(cid, v.itemid, v.count or 1, false)
[14/8/2012 10:57:1] 						doSetItemText(k, t.text, t.writer, t.date)
[14/8/2012 10:57:1] 					else
[14/8/2012 10:57:1] 						doPlayerAddItem(cid, v.itemid, v.count or 1)
[14/8/2012 10:57:1] 					end
[14/8/2012 10:57:1] 				end
[14/8/2012 10:57:1] 			end
[14/8/2012 10:57:1]  
[14/8/2012 10:57:1] 			return true
[14/8/2012 10:57:1] 		end
[14/8/2012 10:57:1] 	:onLogin
[14/8/2012 10:57:1] Description: 
[14/8/2012 10:57:1] (luaGetThing) Thing not found
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="2.0" author="J.Dre" contact="[email protected]" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		commonItems = {
			{itemid=6103, count=1, useMessage=true}, -- a book (or whatever) with a message
			{itemid=2789, count=100, inContainer = true}, -- 100 brown mushrooms
			{itemid=2160, count=1, inContainer = true}, -- 1 crystal coin
			{itemid=2442, inContainer = true}, -- heavy machete
			{itemid=2661, count=1}, -- scarf
			{itemid=2195} -- boots of haste
		}
		firstItems = {
			{ -- Sorcerer	
				{itemid=2002}, -- blue backpack
				{itemid=2520}, -- demon shield
				{itemid=2187}, -- wand of inferno
				{itemid=8871}, -- focus cape
				{itemid=2323}, -- hat of the mad
				{itemid=7730}, -- blue legs
				{itemid=7590, count=1, inContainer=true} -- great mana potion
			},
			{ -- Druid
				{itemid=2002}, -- blue backpack
				{itemid=2520}, -- demon shield
				{itemid=2183}, -- hailstorm rod
				{itemid=8871}, -- focus cape
				{itemid=2323}, -- hat of the mad
				{itemid=7730}, -- blue legs
				{itemid=7590, count=1, inContainer=true} -- great mana potion
			},
			{ -- Paladin
				{itemid=1999}, -- yellow backpack
				{itemid=2520}, -- demon shield
				{itemid=7368}, -- assassin star
				{itemid=2492}, -- dragon scale mail
				{itemid=2498}, -- royal helmet
				{itemid=7730}, -- blue legs
				{itemid=8472, count=1, inContainer=true} -- spirit great potion				
			},
			{ -- Knight
				{itemid=2003}, -- grey backpack
				{itemid=2520}, -- demon shield
				{itemid=2400}, -- magic sword
				{itemid=2492}, -- dragon scale mail
				{itemid=2498}, -- royal helmet
				{itemid=7730}, -- blue legs
				{itemid=2431, inContainer=true}, -- stonecutter axe
				{itemid=2421, inContainer=true}, -- thunder hammer
				{itemid=8473, count=1, inContainer=true} -- ultimate health potion
			}
		}
	]]></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(getPlayerAccess(cid) < 4 and (getPlayerLastLoginSaved(cid) < 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, false)
					elseif v.inContainer then
						doAddContainerItem(backpack, v.itemid, v.count or 1)
					elseif v.useSlot then
						doPlayerAddItem(cid, v.itemid, v.count, false, v.slotType)
					elseif v.useMessage then
						local t, k = {
							writer = "Server Staff", date = os.time(),
							text = "Welcome " .. getCreatureName(cid) .. ".\n\nOur community would like to welcome you to " .. getConfigValue('serverName') .. ". If you need help with anything, please refer to the help channel.\n\nEnjoy your time!"
						}, doPlayerAddItem(cid, v.itemid, v.count or 1, false)
						doSetItemText(k, t.text, t.writer, t.date)
					else
						doPlayerAddItem(cid, v.itemid, v.count or 1)
					end
				end
			end
 
			return true
		end
	]]></event>
</mod>

Try that, there was a comma at the wrong place. Might not solve the problem, but it certainly shouldn't be there.
 
I continue with the error

Code:
[14/8/2012 12:48:51] [Error - CreatureScript Interface] 
[14/8/2012 12:48:51] 		domodlib('firstitems_config')
[14/8/2012 12:48:51]  
[14/8/2012 12:48:51] 		for _, items in ipairs(firstItems) do
[14/8/2012 12:48:51] 			for _, item in ipairs(commonItems) do
[14/8/2012 12:48:51] 				table.insert(items, item)
[14/8/2012 12:48:51] 			end
[14/8/2012 12:48:51] 		end
[14/8/2012 12:48:51]  
[14/8/2012 12:48:51] 		function onLogin(cid)
[14/8/2012 12:48:51] 			if(getPlayerAccess(cid) < 4 and (getPlayerLastLoginSaved(cid) < 1) and firstItems[getPlayerVocation(cid)]) then
[14/8/2012 12:48:51] 				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
[14/8/2012 12:48:51] 					if isItemContainer(v.itemid) then
[14/8/2012 12:48:51] 						backpack = doPlayerAddItem(cid, v.itemid, 1, false)
[14/8/2012 12:48:51] 					elseif v.inContainer then
[14/8/2012 12:48:51] 						doAddContainerItem(backpack, v.itemid, v.count or 1)
[14/8/2012 12:48:51] 					elseif v.useSlot then
[14/8/2012 12:48:51] 						doPlayerAddItem(cid, v.itemid, v.count, false, v.slotType)
[14/8/2012 12:48:51] 					elseif v.useMessage then
[14/8/2012 12:48:51] 						local t, k = {
[14/8/2012 12:48:51] 							writer = "Server Staff", date = os.time(),
[14/8/2012 12:48:51] 							text = "Welcome " .. getCreatureName(cid) .. ".\n\nOur community would like to welcome you to " .. getConfigValue('serverName') .. ". If you need help with anything, please refer to the help channel.\n\nEnjoy your time!"
[14/8/2012 12:48:51] 						}, doPlayerAddItem(cid, v.itemid, v.count or 1, false)
[14/8/2012 12:48:51] 						doSetItemText(k, t.text, t.writer, t.date)
[14/8/2012 12:48:51] 					else
[14/8/2012 12:48:51] 						doPlayerAddItem(cid, v.itemid, v.count or 1)
[14/8/2012 12:48:51] 					end
[14/8/2012 12:48:51] 				end
[14/8/2012 12:48:51] 			end
[14/8/2012 12:48:51]  
[14/8/2012 12:48:51] 			return true
[14/8/2012 12:48:51] 		end
[14/8/2012 12:48:51] 	:onLogin
[14/8/2012 12:48:51] Description: 
[14/8/2012 12:48:51] (luaGetThing) Thing not found

Any idea?
 
The problem occurs when you don't have enough capacity, I've tested it.
You will have to increase the capacity.
 
Back
Top