• 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 [Warning - NpcScript::NpcScript] Can not load script:

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
136
Location
Sweden
Hello.

I have some struggle with this script, it gives me the following warning.

Code:
[Warning - NpcScript::NpcScript] Can not load script: mount_master.lua
data/npc/scripts/mount_master.lua:4: function arguments expected near ':'

Script:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() 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 = {{6527,1}}, mountid = 1, level = 10, premium = true},
{"racing bird", items = {{6527,1}}, mountid = 2, level = 15, premium = true},
{"war bear", items = {{6527,1}}, mountid = 3, level = 15, premium = true},
{"black sheep", items = {{6527,1}}, mountid = 4, level = 15, premium = true},
{"midnight panther", items = {{6527,1}}, mountid = 5, level = 15, premium = true},
{"draptor", items = {{6527,1}}, mountid = 6, level = 15, premium = true},
{"titanica", items = {{6527,1}}, mountid = 7, level = 15, premium = true},
{"tin lizzard", items = {{6527,1}}, mountid = 8, level = 15, premium = true},
{"blazebringer", items = {{6527,1}}, mountid = 9, level = 15, premium = true},
{"rapid boar", items = {{6527,1}}, mountid = 10, level = 15, premium = true},
{"stampor", items = {{6527,1}}, mountid = 11, level = 15, premium = true},
{"undead cavebear", items = {{6527,31}}, mountid = 12, 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}"}
}
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())
 
Hello.

I have some struggle with this script, it gives me the following warning.

Code:
[Warning - NpcScript::NpcScript] Can not load script: mount_master.lua
data/npc/scripts/mount_master.lua:4: function arguments expected near ':'

Script:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() 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 = {{6527,1}}, mountid = 1, level = 10, premium = true},
{"racing bird", items = {{6527,1}}, mountid = 2, level = 15, premium = true},
{"war bear", items = {{6527,1}}, mountid = 3, level = 15, premium = true},
{"black sheep", items = {{6527,1}}, mountid = 4, level = 15, premium = true},
{"midnight panther", items = {{6527,1}}, mountid = 5, level = 15, premium = true},
{"draptor", items = {{6527,1}}, mountid = 6, level = 15, premium = true},
{"titanica", items = {{6527,1}}, mountid = 7, level = 15, premium = true},
{"tin lizzard", items = {{6527,1}}, mountid = 8, level = 15, premium = true},
{"blazebringer", items = {{6527,1}}, mountid = 9, level = 15, premium = true},
{"rapid boar", items = {{6527,1}}, mountid = 10, level = 15, premium = true},
{"stampor", items = {{6527,1}}, mountid = 11, level = 15, premium = true},
{"undead cavebear", items = {{6527,31}}, mountid = 12, 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}"}
}
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())

Just chaning what @Ninja said.

Code:
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 = {{6527,1}}, mountid = 1, level = 10, premium = true},
{"racing bird", items = {{6527,1}}, mountid = 2, level = 15, premium = true},
{"war bear", items = {{6527,1}}, mountid = 3, level = 15, premium = true},
{"black sheep", items = {{6527,1}}, mountid = 4, level = 15, premium = true},
{"midnight panther", items = {{6527,1}}, mountid = 5, level = 15, premium = true},
{"draptor", items = {{6527,1}}, mountid = 6, level = 15, premium = true},
{"titanica", items = {{6527,1}}, mountid = 7, level = 15, premium = true},
{"tin lizzard", items = {{6527,1}}, mountid = 8, level = 15, premium = true},
{"blazebringer", items = {{6527,1}}, mountid = 9, level = 15, premium = true},
{"rapid boar", items = {{6527,1}}, mountid = 10, level = 15, premium = true},
{"stampor", items = {{6527,1}}, mountid = 11, level = 15, premium = true},
{"undead cavebear", items = {{6527,31}}, mountid = 12, 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}"}
}
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())
 
@Ninja @Cornex

Allright, thanks but wtf happened now :p

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/mount_master.lua:onCreatureSay
data/npc/lib/npcsystem/npchandler.lua:310: bad argument #1 to 'gsub' (string exp
ected, got nil)
stack traceback:
        [C]: ?
        [C]: in function 'gsub'
        data/npc/lib/npcsystem/npchandler.lua:310: in function 'parseMessage'
        data/npc/lib/npcsystem/modules.lua:52: in function 'callback'
        data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessag
e'
        data/npc/lib/npcsystem/keywordhandler.lua:136: in function 'processNodeM
essage'
        data/npc/lib/npcsystem/keywordhandler.lua:111: in function 'processMessa
ge'
        data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
        data/npc/scripts/mount_master.lua:6: in function <data/npc/scripts/mount
_master.lua:6>

PHP:
function getItemsFromList(items) 
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[2] .. ' ' .. getItemNameById(items[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[1]) >= items[2] then
count = count + 1 end end end
if count == table.maxn(items) then
for i = 1, table.maxn(items) do doPlayerRemoveItem(cid,items[1],items[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
 
Back
Top