• 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 Help, Character Creation and Lua Script error

furmanss

New Member
Joined
May 14, 2013
Messages
125
Reaction score
0
the only error left is this one

[18/05/2013 18:51:45] Lua Script Error: [Npc interface]
[18/05/2013 18:51:45] data/npc/scripts/buymount.lua
[18/05/2013 18:51:45] data/npc/scripts/buymount.lua:60: attempt to call global 'getItemsFromList' (a nil value)
[18/05/2013 18:51:45] stack traceback:
[18/05/2013 18:51:45] [C]: in function 'getItemsFromList'
[18/05/2013 18:51:45] data/npc/scripts/buymount.lua:60: in main chunk
[18/05/2013 18:51:45] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/buymount.lua



and another question, i was using account manager/database sample or whatever they are called when i created my characters in 8.6, i thought it was easy and simple to setup starting position/items/lvl etc etc, but now in 9.86 i got the samples but they are not being used instead the creaturescripts is enabled and i have to get scripts for eveything but is there any way i can enable the samples again instead of the scripts?
 
eys but i dont know what to change there :(it looks like this,

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function AddMount(cid, message, keywords, parameters, node) --by vodka
if(not npcHandler:isFocused(cid)) then
return false
end
if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
npcHandler:say('You must reach level ' .. parameters.level .. ' to buy this mount.', cid)
elseif canPlayerRideMount(cid, parameters.mountid) then
npcHandler:say('you already have this mount!', cid)
elseif not doRemoveItemsFromList(cid,parameters.items) then
npcHandler:say('Sorry You need '..getItemsFromList(parameters.items)..' to buy this mount!', cid)
else
doPlayerAddMount(cid, parameters.mountid)
npcHandler:say('Here is your mount!', cid)
npcHandler:resetNpc()
end
else
npcHandler:say('I can only allow premium players to buy this mount.', cid)
end
npcHandler:resetNpc()
return true
end

local mounts = {
{"widow queen", items = {{2160,1}}, mountid = 1, level = 10, premium = false},
{"racing bird", items = {{2160,2}}, mountid = 2, level = 15, premium = false},
{"war bear", items = {{2160,3}}, mountid = 3, level = 15, premium = false},
{"black sheep", items = {{2160,4}}, mountid = 4, level = 15, premium = false},
{"midnight panther", items = {{2160,5}}, mountid = 5, level = 10, premium = false},
{"draptor", items = {{2160,1}}, mountid = 6, level = 15, premium = true},
{"titanica", items = {{2160,2}}, mountid = 7, level = 15, premium = true},
{"tin lizzard", items = {{2160,2}}, mountid = 8, level = 15, premium = true},
{"blazebringer", items = {{2160,3}}, mountid = 9, level = 10, premium = true},
{"rapid boar", items = {{2160,3}}, mountid = 10, level = 15, premium = true},
{"stampor", items = {{2160,4}}, mountid = 11, level = 15, premium = true},
{"undead cavebear", items = {{2160,4}}, mountid = 12, level = 15, premium = true},
{"donkey", items = {{2160,3}}, mountid = 13, level = 10, premium = true},
{"tiger slug", items = {{2160,4}}, mountid = 14, level = 15, premium = true},
{"uniwheel", items = {{2160,5}}, mountid = 15, level = 15, premium = true},
{"crystal wolf", items = {{2160,5}}, mountid = 16, level = 15, premium = true},
{"war horse", items = {{2160,3}}, mountid = 17, level = 10, premium = true},
{"kingly deer", items = {{2160,6}}, mountid = 18, level = 15, premium = true},
{"tamed panda", items = {{2160,2}}, mountid = 19, level = 15, premium = true},
{"dromedary", items = {{2160,3}}, mountid = 20, level = 15, premium = true},
{"sandstone scorpion", items = {{2160,6}}, mountid = 21, level = 10, premium = true},
{"fire war horse", items = {{2160,7}}, mountid = 23, level = 15, premium = true},
{"shadow draptor", items = {{2160,8}}, mountid = 24, level = 15, premium = true},
{"ladybug", items = {{2160,9}}, mountid = 27, level = 15, premium = true},
{"mounts", text = "I sell these mounts: {widow queen}, {racing bird}, {war bear}, {black sheep}, {midnight panther}, {draptor}, {titanica}, {tin lizzard}, {blazebringer}, {rapid boar}, {stampor}, {undead cavebear}, {donkey}, {tiger slug}, {uniwheel}, {crystal wolf}, {war horse}, {kingly deer}, {tamed panda}, {sandstone scorpion}, {dromedary}, {fire war horse}, {shadow draptor} or {ladybug}!"}
}

for i = 1, #mounts do local get = mounts if type(get.items) == "table" then
local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You want to buy the mount " .. get[1] .. " for "..getItemsFromList(get.items).." ?"})
node:addChildKeyword({"yes"}, AddMount, {items = get.items,mountid = get.mountid, level = get.level, premium = get.premium})
node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Ok, then.", reset = true})
else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end
mounts = nil npcHandler:addModule(FocusModule:new())
 
In the future please use
LUA:
[[I]/[/I]lua] tags in order to post your scripts. 
Do not use quote or code tags.[/SIZE]

[quote="Sirion_Mido, post: 1594055"]
lib Part
Go To Data / lib And Open File Name 050-function
And Paste The Following:
[code=lua]function getItemsFromList(items) 
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end
function doRemoveItemsFromList(cid,items) 
local count = 0
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
if getPlayerItemCount(cid,items[i][1]) >= items[i][2] then
count = count + 1 end  end  end
if count == table.maxn(items) then
for i = 1, table.maxn(items) do doPlayerRemoveItem(cid,items[i][1],items[i][2]) end
else return false end
return true end
function doPlayerGiveItem(cid, itemid, amount, subType)
	local item = 0
	if(isItemStackable(itemid)) then
		item = doCreateItemEx(itemid, amount)
		if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
			return false
		end
	else
		for i = 1, amount do
			item = doCreateItemEx(itemid, subType)
			if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
				return false
			end
		end
	end
[/QUOTE]
 
Back
Top