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

[HELP] Get a random mount when create chart

huhuhuhu

New Member
Joined
May 17, 2008
Messages
38
Reaction score
0
Hello, I've trying to add that new player get a random mount (1 of 4 horse) but I fail, so I'm here hoping someone can give me a hand with this mod.

My last try was using this:
Lua:
local mount = {
	[1] = {22, 421}, -- Rented Horse
	[2] = {32, 437}, -- Rented Horse
	[3] = {33, 438}  -- Rented Horse
	[4] = {23, 426}  -- War Horse
}

local number = math.random(1, 4)
doPlayerAddMount(cid, mount[number])
but just bug the login for new players xD



Well this is the first item mod that I'm using, I guess this is where can be added:
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
        	<config name="firstitems_config"><![CDATA[
        		STORAGE = 70004
        		commonItems = {
        			{itemid=2160, count=3, inContainer = true}, -- 3 crystal coins
        			{itemid=2789, count=10, inContainer = true}, -- 10 brown mushroom
        			{itemid=7731}, -- elvenhair rope
        			{itemid=11303}, -- zaoan shoes
        			{itemid=2173} -- amulet of loss
        		}
        		firstItems = {
        			{ -- Sorcerer
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=10, inContainer = true}, -- 10 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=2175}, -- spellbook
        				{itemid=2190}, -- wand of vortex
        				{itemid=8870}, -- spirit cloak
        				{itemid=2457}, -- steel helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Druid
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=10, inContainer = true}, -- 10 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=2175}, -- spellbook
        				{itemid=2182}, -- snakebite rod
        				{itemid=8870}, -- spirit cloak
        				{itemid=2457}, -- steel helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Paladin
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=7, inContainer = true}, -- 7 health potion
        				{itemid=7620, count=7, inContainer = true}, -- 7 mana potion
        				{itemid=2515}, -- guardian shield
        				{itemid=2389, count=10}, -- 10 spears
        				{itemid=8872}, -- Belted Cape
        				{itemid=7462}, -- ragnir helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Knight
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=20, inContainer = true}, -- 20 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=8601, inContainer = true}, -- steel axe
        				{itemid=2439, inContainer = true}, -- daramanian mace 
        				{itemid=2515}, -- guardian shield
        				{itemid=8602}, -- jagged sword
        				{itemid=7463}, -- mammoth fur cape
        				{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>


Also if isn't much to ask there is a way to put % in the random? so the all the rented horse get 32% and the fire horse just 4%?

Anyway thanks in advanced for who can be kind enough to help =)
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
        	<config name="firstitems_config"><![CDATA[
        		STORAGE = 70004
        		commonItems = {
        			{itemid=2160, count=3, inContainer = true}, -- 3 crystal coins
        			{itemid=2789, count=10, inContainer = true}, -- 10 brown mushroom
        			{itemid=7731}, -- elvenhair rope
        			{itemid=11303}, -- zaoan shoes
        			{itemid=2173} -- amulet of loss
        		}
        		firstItems = {
        			{ -- Sorcerer
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=10, inContainer = true}, -- 10 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=2175}, -- spellbook
        				{itemid=2190}, -- wand of vortex
        				{itemid=8870}, -- spirit cloak
        				{itemid=2457}, -- steel helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Druid
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=10, inContainer = true}, -- 10 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=2175}, -- spellbook
        				{itemid=2182}, -- snakebite rod
        				{itemid=8870}, -- spirit cloak
        				{itemid=2457}, -- steel helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Paladin
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=7, inContainer = true}, -- 7 health potion
        				{itemid=7620, count=7, inContainer = true}, -- 7 mana potion
        				{itemid=2515}, -- guardian shield
        				{itemid=2389, count=10}, -- 10 spears
        				{itemid=8872}, -- Belted Cape
        				{itemid=7462}, -- ragnir helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Knight
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=20, inContainer = true}, -- 20 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=8601, inContainer = true}, -- steel axe
        				{itemid=2439, inContainer = true}, -- daramanian mace 
        				{itemid=2515}, -- guardian shield
        				{itemid=8602}, -- jagged sword
        				{itemid=7463}, -- mammoth fur cape
        				{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
					local mount = {
							[1, 32] = {22, 421}, -- Rented Horse 32%
							[33, 64] = {32, 437}, -- Rented Horse 32%
							[65, 96] = {33, 438} -- Rented Horse 32%
							[97, 100] = {23, 426} -- War Horse 4%
							}
					local mntStore = 5678
					local number = math.random(1, 100)
						if getCreatureStorage(cid, mntStore) == nil then	
							for i, v in pairs(mount) do
								if number >= i[1] and number <= i[2] then
									doPlayerAddMount(cid, v[1])
									doCreatureStorage(cid, mntStore, 1)
								end
							end
						end	
        			return true
        		end
        	]]></event>
        </mod>

Did not understand this:
Lua:
local mount = {
	[1] = {22, 421}, -- Rented Horse
	[2] = {32, 437}, -- Rented Horse
	[3] = {33, 438} -- Rented Horse
	[4] = {23, 426} -- War Horse
}
why 22 and 421? same goes for the others.
 
Well I put those number 'cuz of this

Code:
	<mount id="22" clientid="421" name="Rented Horse" speed="20" premium="no"/>
	<mount id="23" clientid="426" name="Fire War Horse" speed="20" premium="no"/>
	<mount id="32" clientid="437" name="Rented Horse" speed="20" premium="no" />
	<mount id="33" clientid="438" name="Rented Horse" speed="20" premium="no" />

Idk if those are needed. I'll test your code to see if work.

Edit; Don't work, just shutdown the console when is loading the mod.
 
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
        	<config name="firstitems_config"><![CDATA[
        		STORAGE = 70004
			mount = {
				[1, 32] = {22}, -- Rented Horse 32%
				[33, 64] = {32}, -- Rented Horse 32%
				[65, 96] = {33} -- Rented Horse 32%
				[97, 100] = {23} -- War Horse 4%
			}
        		commonItems = {
        			{itemid=2160, count=3, inContainer = true}, -- 3 crystal coins
        			{itemid=2789, count=10, inContainer = true}, -- 10 brown mushroom
        			{itemid=7731}, -- elvenhair rope
        			{itemid=11303}, -- zaoan shoes
        			{itemid=2173} -- amulet of loss
        		}
        		firstItems = {
        			{ -- Sorcerer
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=10, inContainer = true}, -- 10 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=2175}, -- spellbook
        				{itemid=2190}, -- wand of vortex
        				{itemid=8870}, -- spirit cloak
        				{itemid=2457}, -- steel helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Druid
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=10, inContainer = true}, -- 10 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=2175}, -- spellbook
        				{itemid=2182}, -- snakebite rod
        				{itemid=8870}, -- spirit cloak
        				{itemid=2457}, -- steel helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Paladin
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=7, inContainer = true}, -- 7 health potion
        				{itemid=7620, count=7, inContainer = true}, -- 7 mana potion
        				{itemid=2515}, -- guardian shield
        				{itemid=2389, count=10}, -- 10 spears
        				{itemid=8872}, -- Belted Cape
        				{itemid=7462}, -- ragnir helmet
        				{itemid=2647} -- plate legs
        			},
        			{ -- Knight
        				{itemid=9774}, -- backpack
        				{itemid=7618, count=20, inContainer = true}, -- 20 health potion
        				{itemid=7620, count=20, inContainer = true}, -- 20 mana potion
        				{itemid=8601, inContainer = true}, -- steel axe
        				{itemid=2439, inContainer = true}, -- daramanian mace 
        				{itemid=2515}, -- guardian shield
        				{itemid=8602}, -- jagged sword
        				{itemid=7463}, -- mammoth fur cape
        				{itemid=2457}, -- steel helmet
        				{itemid=2647} -- plate legs
        			}
        		}
        	]]></config>
        	<event type="login" name="FirstItems" event="script"><![CDATA[
        		domodlib('firstitems_config')
 
        		for _, items in pairs(firstItems) do
        			for _, item in pairs(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 pairs(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
        				
					local number = math.random(1, 100)
					if getCreatureStorage(cid, STORAGE) < 1 then	
						for i, e in pairs(mount) do
							if number >= i[1] and number <= i[2] then
								doPlayerAddMount(cid, e)
							end
						end
					end
					setPlayerStorageValue(cid, STORAGE, 1)
        			end	
        			return true
        		end
        	]]></event>
        </mod>

Edited
 
Last edited:
I Try it and give me this error in console.

Code:
[6/8/2011 18:12:50] [Error - Test Interface] 
[6/8/2011 18:12:50] 		domodlib('firstitems_config')
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:12:50]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:12:50]         				table.insert(items, item)
[6/8/2011 18:12:50]         			end
[6/8/2011 18:12:50]         		end
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50]         		function onLogin(cid)
[6/8/2011 18:12:50]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:12:50]         				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:12:50]         					if isItemContainer(v.itemid) then
[6/8/2011 18:12:50]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:12:50]         					elseif v.inContainer then
[6/8/2011 18:12:50]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:12:50]         					else
[6/8/2011 18:12:50]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:12:50]         					end
[6/8/2011 18:12:50]         				end
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50] 					local number = math.random(1, 100)
[6/8/2011 18:12:50] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:12:50] 						for i, e in pairs(mount) do
[6/8/2011 18:12:50] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:12:50] 								doPlayerAddMount(cid, e)
[6/8/2011 18:12:50] 							end
[6/8/2011 18:12:50] 						end
[6/8/2011 18:12:50] 					end
[6/8/2011 18:12:50] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:12:50]         			end	
[6/8/2011 18:12:50]         			return true
[6/8/2011 18:12:50]         		end
[6/8/2011 18:12:50]         	
[6/8/2011 18:12:50] Description: 
[6/8/2011 18:12:50] [string "		STORAGE = 70004..."]:3: ']' expected near ','

[6/8/2011 18:12:50] [Error - Test Interface] 
[6/8/2011 18:12:50] 		domodlib('firstitems_config')
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:12:50]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:12:50]         				table.insert(items, item)
[6/8/2011 18:12:50]         			end
[6/8/2011 18:12:50]         		end
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50]         		function onLogin(cid)
[6/8/2011 18:12:50]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:12:50]         				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:12:51]         					if isItemContainer(v.itemid) then
[6/8/2011 18:12:51]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:12:51]         					elseif v.inContainer then
[6/8/2011 18:12:51]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:12:51]         					else
[6/8/2011 18:12:51]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:12:51]         					end
[6/8/2011 18:12:51]         				end
[6/8/2011 18:12:51]  
[6/8/2011 18:12:51] 					local number = math.random(1, 100)
[6/8/2011 18:12:51] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:12:51] 						for i, e in pairs(mount) do
[6/8/2011 18:12:51] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:12:51] 								doPlayerAddMount(cid, e)
[6/8/2011 18:12:51] 							end
[6/8/2011 18:12:51] 						end
[6/8/2011 18:12:51] 					end
[6/8/2011 18:12:51] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:12:51]         			end	
[6/8/2011 18:12:51]         			return true
[6/8/2011 18:12:51]         		end
[6/8/2011 18:12:51]         	
[6/8/2011 18:12:51] Description: 
[6/8/2011 18:12:51] [string "LuaInterface::loadBuffer"]:3: bad argument #1 to 'ipairs' (table expected, got nil)
[6/8/2011 18:12:51] [Error - Event::checkScript] Cannot load script (		domodlib('firstitems_config')
[6/8/2011 18:12:51]  
[6/8/2011 18:12:51]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:12:51]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:12:51]         				table.insert(items, item)
[6/8/2011 18:12:51]         			end
[6/8/2011 18:12:51]         		end
[6/8/2011 18:12:51]  
[6/8/2011 18:12:51]         		function onLogin(cid)
[6/8/2011 18:12:51]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:12:51]         				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:12:51]         					if isItemContainer(v.itemid) then
[6/8/2011 18:12:51]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:12:51]         					elseif v.inContainer then
[6/8/2011 18:12:51]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:12:51]         					else
[6/8/2011 18:12:51]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:12:51]         					end
[6/8/2011 18:12:51]         				end
[6/8/2011 18:12:51]  
[6/8/2011 18:12:51] 					local number = math.random(1, 100)
[6/8/2011 18:12:51] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:12:51] 						for i, e in pairs(mount) do
[6/8/2011 18:12:51] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:12:51] 								doPlayerAddMount(cid, e)
[6/8/2011 18:12:51] 							end
[6/8/2011 18:12:51] 						end
[6/8/2011 18:12:51] 					end
[6/8/2011 18:12:51] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:12:51]         			end	
[6/8/2011 18:12:51]         			return true
[6/8/2011 18:12:51]         		end
[6/8/2011 18:12:51]         	)


Shinmaru I think might be better if is used in a login script? without the mod?
 
I Try it and give me this error in console.

Code:
[6/8/2011 18:12:50] [Error - Test Interface] 
[6/8/2011 18:12:50] 		domodlib('firstitems_config')
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:12:50]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:12:50]         				table.insert(items, item)
[6/8/2011 18:12:50]         			end
[6/8/2011 18:12:50]         		end
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50]         		function onLogin(cid)
[6/8/2011 18:12:50]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:12:50]         				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:12:50]         					if isItemContainer(v.itemid) then
[6/8/2011 18:12:50]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:12:50]         					elseif v.inContainer then
[6/8/2011 18:12:50]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:12:50]         					else
[6/8/2011 18:12:50]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:12:50]         					end
[6/8/2011 18:12:50]         				end
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50] 					local number = math.random(1, 100)
[6/8/2011 18:12:50] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:12:50] 						for i, e in pairs(mount) do
[6/8/2011 18:12:50] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:12:50] 								doPlayerAddMount(cid, e)
[6/8/2011 18:12:50] 							end
[6/8/2011 18:12:50] 						end
[6/8/2011 18:12:50] 					end
[6/8/2011 18:12:50] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:12:50]         			end	
[6/8/2011 18:12:50]         			return true
[6/8/2011 18:12:50]         		end
[6/8/2011 18:12:50]         	
[6/8/2011 18:12:50] Description: 
[6/8/2011 18:12:50] [string "		STORAGE = 70004..."]:3: ']' expected near ','

[6/8/2011 18:12:50] [Error - Test Interface] 
[6/8/2011 18:12:50] 		domodlib('firstitems_config')
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:12:50]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:12:50]         				table.insert(items, item)
[6/8/2011 18:12:50]         			end
[6/8/2011 18:12:50]         		end
[6/8/2011 18:12:50]  
[6/8/2011 18:12:50]         		function onLogin(cid)
[6/8/2011 18:12:50]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:12:50]         				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:12:51]         					if isItemContainer(v.itemid) then
[6/8/2011 18:12:51]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:12:51]         					elseif v.inContainer then
[6/8/2011 18:12:51]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:12:51]         					else
[6/8/2011 18:12:51]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:12:51]         					end
[6/8/2011 18:12:51]         				end
[6/8/2011 18:12:51]  
[6/8/2011 18:12:51] 					local number = math.random(1, 100)
[6/8/2011 18:12:51] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:12:51] 						for i, e in pairs(mount) do
[6/8/2011 18:12:51] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:12:51] 								doPlayerAddMount(cid, e)
[6/8/2011 18:12:51] 							end
[6/8/2011 18:12:51] 						end
[6/8/2011 18:12:51] 					end
[6/8/2011 18:12:51] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:12:51]         			end	
[6/8/2011 18:12:51]         			return true
[6/8/2011 18:12:51]         		end
[6/8/2011 18:12:51]         	
[6/8/2011 18:12:51] Description: 
[6/8/2011 18:12:51] [string "LuaInterface::loadBuffer"]:3: bad argument #1 to 'ipairs' (table expected, got nil)
[6/8/2011 18:12:51] [Error - Event::checkScript] Cannot load script (		domodlib('firstitems_config')
[6/8/2011 18:12:51]  
[6/8/2011 18:12:51]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:12:51]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:12:51]         				table.insert(items, item)
[6/8/2011 18:12:51]         			end
[6/8/2011 18:12:51]         		end
[6/8/2011 18:12:51]  
[6/8/2011 18:12:51]         		function onLogin(cid)
[6/8/2011 18:12:51]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:12:51]         				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:12:51]         					if isItemContainer(v.itemid) then
[6/8/2011 18:12:51]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:12:51]         					elseif v.inContainer then
[6/8/2011 18:12:51]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:12:51]         					else
[6/8/2011 18:12:51]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:12:51]         					end
[6/8/2011 18:12:51]         				end
[6/8/2011 18:12:51]  
[6/8/2011 18:12:51] 					local number = math.random(1, 100)
[6/8/2011 18:12:51] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:12:51] 						for i, e in pairs(mount) do
[6/8/2011 18:12:51] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:12:51] 								doPlayerAddMount(cid, e)
[6/8/2011 18:12:51] 							end
[6/8/2011 18:12:51] 						end
[6/8/2011 18:12:51] 					end
[6/8/2011 18:12:51] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:12:51]         			end	
[6/8/2011 18:12:51]         			return true
[6/8/2011 18:12:51]         		end
[6/8/2011 18:12:51]         	)


Shinmaru I think might be better if is used in a login script? without the mod?

Try the script again I edited my last post.
 
Code:
[6/8/2011 18:57:31] [Error - Test Interface] 
[6/8/2011 18:57:31] 		domodlib('firstitems_config')
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:57:31]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:57:31]         				table.insert(items, item)
[6/8/2011 18:57:31]         			end
[6/8/2011 18:57:31]         		end
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31]         		function onLogin(cid)
[6/8/2011 18:57:31]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:57:31]         				for _, v in pairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:57:31]         					if isItemContainer(v.itemid) then
[6/8/2011 18:57:31]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:57:31]         					elseif v.inContainer then
[6/8/2011 18:57:31]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:57:31]         					else
[6/8/2011 18:57:31]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:57:31]         					end
[6/8/2011 18:57:31]         				end
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31] 					local number = math.random(1, 100)
[6/8/2011 18:57:31] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:57:31] 						for i, e in pairs(mount) do
[6/8/2011 18:57:31] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:57:31] 								doPlayerAddMount(cid, e)
[6/8/2011 18:57:31] 							end
[6/8/2011 18:57:31] 						end
[6/8/2011 18:57:31] 					end
[6/8/2011 18:57:31] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:57:31]         			end	
[6/8/2011 18:57:31]         			return true
[6/8/2011 18:57:31]         		end
[6/8/2011 18:57:31]         	
[6/8/2011 18:57:31] Description: 
[6/8/2011 18:57:31] [string "		STORAGE = 70004..."]:3: ']' expected near ','

[6/8/2011 18:57:31] [Error - Test Interface] 
[6/8/2011 18:57:31] 		domodlib('firstitems_config')
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:57:31]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:57:31]         				table.insert(items, item)
[6/8/2011 18:57:31]         			end
[6/8/2011 18:57:31]         		end
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31]         		function onLogin(cid)
[6/8/2011 18:57:31]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:57:31]         				for _, v in pairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:57:31]         					if isItemContainer(v.itemid) then
[6/8/2011 18:57:31]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:57:31]         					elseif v.inContainer then
[6/8/2011 18:57:31]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:57:31]         					else
[6/8/2011 18:57:31]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:57:31]         					end
[6/8/2011 18:57:31]         				end
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31] 					local number = math.random(1, 100)
[6/8/2011 18:57:31] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:57:31] 						for i, e in pairs(mount) do
[6/8/2011 18:57:31] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:57:31] 								doPlayerAddMount(cid, e)
[6/8/2011 18:57:31] 							end
[6/8/2011 18:57:31] 						end
[6/8/2011 18:57:31] 					end
[6/8/2011 18:57:31] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:57:31]         			end	
[6/8/2011 18:57:31]         			return true
[6/8/2011 18:57:31]         		end
[6/8/2011 18:57:31]         	
[6/8/2011 18:57:31] Description: 
[6/8/2011 18:57:31] [string "LuaInterface::loadBuffer"]:3: bad argument #1 to 'ipairs' (table expected, got nil)
[6/8/2011 18:57:31] [Error - Event::checkScript] Cannot load script (		domodlib('firstitems_config')
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31]         		for _, items in ipairs(firstItems) do
[6/8/2011 18:57:31]         			for _, item in ipairs(commonItems) do
[6/8/2011 18:57:31]         				table.insert(items, item)
[6/8/2011 18:57:31]         			end
[6/8/2011 18:57:31]         		end
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31]         		function onLogin(cid)
[6/8/2011 18:57:31]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 18:57:31]         				for _, v in pairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 18:57:31]         					if isItemContainer(v.itemid) then
[6/8/2011 18:57:31]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 18:57:31]         					elseif v.inContainer then
[6/8/2011 18:57:31]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 18:57:31]         					else
[6/8/2011 18:57:31]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 18:57:31]         					end
[6/8/2011 18:57:31]         				end
[6/8/2011 18:57:31]  
[6/8/2011 18:57:31] 					local number = math.random(1, 100)
[6/8/2011 18:57:31] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 18:57:31] 						for i, e in pairs(mount) do
[6/8/2011 18:57:31] 							if number >= i[1] and number <= i[2] then
[6/8/2011 18:57:31] 								doPlayerAddMount(cid, e)
[6/8/2011 18:57:31] 							end
[6/8/2011 18:57:31] 						end
[6/8/2011 18:57:31] 					end
[6/8/2011 18:57:31] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 18:57:31]         			end	
[6/8/2011 18:57:31]         			return true
[6/8/2011 18:57:31]         		end
[6/8/2011 18:57:31]         	)

[6/8/2011 18:57:31]  done.

Error again.
 
Code:
[6/8/2011 19:23:46] [Error - Test Interface] 
[6/8/2011 19:23:46] 		domodlib('firstitems_config')
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46]         		for _, items in pairs(firstItems) do
[6/8/2011 19:23:46]         			for _, item in pairs(commonItems) do
[6/8/2011 19:23:46]         				table.insert(items, item)
[6/8/2011 19:23:46]         			end
[6/8/2011 19:23:46]         		end
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46]         		function onLogin(cid)
[6/8/2011 19:23:46]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 19:23:46]         				for _, v in pairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 19:23:46]         					if isItemContainer(v.itemid) then
[6/8/2011 19:23:46]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 19:23:46]         					elseif v.inContainer then
[6/8/2011 19:23:46]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 19:23:46]         					else
[6/8/2011 19:23:46]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 19:23:46]         					end
[6/8/2011 19:23:46]         				end
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46] 					local number = math.random(1, 100)
[6/8/2011 19:23:46] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 19:23:46] 						for i, e in pairs(mount) do
[6/8/2011 19:23:46] 							if number >= i[1] and number <= i[2] then
[6/8/2011 19:23:46] 								doPlayerAddMount(cid, e)
[6/8/2011 19:23:46] 							end
[6/8/2011 19:23:46] 						end
[6/8/2011 19:23:46] 					end
[6/8/2011 19:23:46] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 19:23:46]         			end	
[6/8/2011 19:23:46]         			return true
[6/8/2011 19:23:46]         		end
[6/8/2011 19:23:46]         	
[6/8/2011 19:23:46] Description: 
[6/8/2011 19:23:46] [string "		STORAGE = 70004..."]:3: ']' expected near ','

[6/8/2011 19:23:46] [Error - Test Interface] 
[6/8/2011 19:23:46] 		domodlib('firstitems_config')
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46]         		for _, items in pairs(firstItems) do
[6/8/2011 19:23:46]         			for _, item in pairs(commonItems) do
[6/8/2011 19:23:46]         				table.insert(items, item)
[6/8/2011 19:23:46]         			end
[6/8/2011 19:23:46]         		end
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46]         		function onLogin(cid)
[6/8/2011 19:23:46]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 19:23:46]         				for _, v in pairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 19:23:46]         					if isItemContainer(v.itemid) then
[6/8/2011 19:23:46]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 19:23:46]         					elseif v.inContainer then
[6/8/2011 19:23:46]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 19:23:46]         					else
[6/8/2011 19:23:46]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 19:23:46]         					end
[6/8/2011 19:23:46]         				end
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46] 					local number = math.random(1, 100)
[6/8/2011 19:23:46] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 19:23:46] 						for i, e in pairs(mount) do
[6/8/2011 19:23:46] 							if number >= i[1] and number <= i[2] then
[6/8/2011 19:23:46] 								doPlayerAddMount(cid, e)
[6/8/2011 19:23:46] 							end
[6/8/2011 19:23:46] 						end
[6/8/2011 19:23:46] 					end
[6/8/2011 19:23:46] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 19:23:46]         			end	
[6/8/2011 19:23:46]         			return true
[6/8/2011 19:23:46]         		end
[6/8/2011 19:23:46]         	
[6/8/2011 19:23:46] Description: 
[6/8/2011 19:23:46] [string "LuaInterface::loadBuffer"]:3: bad argument #1 to 'pairs' (table expected, got nil)
[6/8/2011 19:23:46] [Error - Event::checkScript] Cannot load script (		domodlib('firstitems_config')
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46]         		for _, items in pairs(firstItems) do
[6/8/2011 19:23:46]         			for _, item in pairs(commonItems) do
[6/8/2011 19:23:46]         				table.insert(items, item)
[6/8/2011 19:23:46]         			end
[6/8/2011 19:23:46]         		end
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46]         		function onLogin(cid)
[6/8/2011 19:23:46]         			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
[6/8/2011 19:23:46]         				for _, v in pairs(firstItems[getPlayerVocation(cid)]) do
[6/8/2011 19:23:46]         					if isItemContainer(v.itemid) then
[6/8/2011 19:23:46]         						backpack = doPlayerAddItem(cid, v.itemid, 1)
[6/8/2011 19:23:46]         					elseif v.inContainer then
[6/8/2011 19:23:46]         						doAddContainerItem(backpack, v.itemid, v.count or 1)
[6/8/2011 19:23:46]         					else
[6/8/2011 19:23:46]         						doPlayerAddItem(cid, v.itemid, v.count or 1)
[6/8/2011 19:23:46]         					end
[6/8/2011 19:23:46]         				end
[6/8/2011 19:23:46]  
[6/8/2011 19:23:46] 					local number = math.random(1, 100)
[6/8/2011 19:23:46] 					if getCreatureStorage(cid, STORAGE) < 1 then	
[6/8/2011 19:23:46] 						for i, e in pairs(mount) do
[6/8/2011 19:23:46] 							if number >= i[1] and number <= i[2] then
[6/8/2011 19:23:46] 								doPlayerAddMount(cid, e)
[6/8/2011 19:23:46] 							end
[6/8/2011 19:23:46] 						end
[6/8/2011 19:23:46] 					end
[6/8/2011 19:23:46] 					setPlayerStorageValue(cid, STORAGE, 1)
[6/8/2011 19:23:46]         			end	
[6/8/2011 19:23:46]         			return true
[6/8/2011 19:23:46]         		end
[6/8/2011 19:23:46]         	)

[6/8/2011 19:23:46]  done.

again xD

the 3time show the same error

Code:
[6/8/2011 19:23:46] [string "LuaInterface::loadBuffer"]:3: bad argument #1 to 'pairs' (table expected, got nil)
 
Ya, dont need a big code only use this part:

Lua:
local number = math.random(1, 4)
doPlayerAddMount(cid,number)
 
Lua:
local mount = {
	[1] = {22, 421}, -- Rented Horse
	[2] = {32, 437}, -- Rented Horse
	[3] = {33, 438}, -- Rented Horse
	[4] = {23, 426} -- War Horse
}

function onLogin(cid)
	if(getPlayerStorageValue(cid, 1000) < 1) then
		doPlayerAddMount(cid, mount[math.random(1, #mount)][1])
		setPlayerStorageValue(cid, 1000, 1)
	end
	return true
end
 
Last edited:
@teckman

The code work but then can't login again, the chart got bug and no error in console.

Also, this warning me about a missing ")".

I put a comma after:

Code:
	[1] = {22, 421}, -- Rented Horse
	[2] = {32, 437}, -- Rented Horse
	[3] = {33, 438}[COLOR="#FF0000"],[/COLOR] -- Rented Horse
	[4] = {23, 426} -- War Horse

and move the missing ) next to:

(doPlayerAddMount(cid, mount[math.random(1, #mount)][1])[ToHere], setPlayerStorageValue(cid, 1000, 1))[FromHere]

The script work, but can't relog again, any way to fix?
 
Lua:
local mount = {
	[1] = {22, 421}, -- Rented Horse
	[2] = {32, 437}, -- Rented Horse
	[3] = {33, 438}, -- Rented Horse
	[4] = {23, 426} -- War Horse
}

function onLogin(cid)
	if(getPlayerStorageValue(cid, 1000) < 1) then
		doPlayerAddMount(cid, mount[math.random(1, #mount)][1])
		setPlayerStorageValue(cid, 1000, 1)
	end
	return true
end

It was returnvalue bug. Fixed.
 
Can someone edit this to get an item inside your backpack ?
but verry rare... ? Thanks :)

Sth like this?
Lua:
function onLogin(cid)
	if(not(getPlayerStorageValue(cid, 1))) then
		if(math.random(100) == 1) then
			doPlayerAddItem(2160, 1)
		end
		setPlayerStorageValue(cid, 1, 1)
	end
	return true
end
 
Back
Top