[19/02/2020 18:12:58] [Error - Npc interface]
[19/02/2020 18:12:58] data/npc/scripts/Blessman.lua
[19/02/2020 18:12:58] Description:
[19/02/2020 18:12:58] data/npc/scripts/Blessman.lua:35: attempt to index global 'parameters' (a nil value)
[19/02/2020 18:12:58] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Blessman.lua
Bom, depois ir tentando algumas coisas eu consegui, apos resolver esse parameters, ele acha um erro de "playergetBlessing" player not found. Mas tbm consegui resolver kkkk, msm assim agradeço a ajuda, o codigo ficou assim, coloquei "elseif(getPlayerBlessing(cid, 1)) then" e funcionou, ele consegue identificar as bless.
local focuses = {}
local function isFocused(cid)
for i, v in pairs(focuses) do
if(v == cid) then
return true
end
end
return false
end
local function addFocus(cid)
if(not isFocused(cid)) then
table.insert(focuses, cid)
end
end
local function removeFocus(cid)
for i, v in pairs(focuses) do
if(v == cid) then
table.remove(focuses, i)
break
end
end
end
local function lookAtFocus()
for i, v in pairs(focuses) do
if(isPlayer(v)) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end
local price = 50000 -- Valor da bless
function onCreatureSay(cid, type, msg)
if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
selfSay("Welcome, ".. getCreatureName(cid) ..". I sell {blessing}.", cid)
addFocus(cid)
elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
selfSay("Would you like buying blessing per ".. (price) .." gold coins?", cid)
elseif((isFocused(cid)) and (msg == "yes")) then
if(getPlayerBlessing(cid, 1)) then
selfSay("Sorry, you already have all the blesses.", cid)
elseif((getPlayerMoney(cid) < price)) then
selfSay("You don't have enough money.", cid)
else
selfSay("Alright.", cid)
doPlayerRemoveMoney(cid, price)
doPlayerAddBlessing(cid, 1)
doPlayerAddBlessing(cid, 2)
doPlayerAddBlessing(cid, 3)
doPlayerAddBlessing(cid, 4)
doPlayerAddBlessing(cid, 5)
doPlayerAddBlessing(cid, 6)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYAREA)
end
elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
selfSay("Goodbye!", cid)
closeShopWindow(cid)
removeFocus(cid)
end
end
function onThink()
for i, focus in pairs(focuses) do
if(not isCreature(focus)) then
removeFocus(focus)
else
local distance = getDistanceTo(focus) or -1
if((distance > 4) or (distance == -1)) then
selfSay("Hey, where you going?")
removeFocus(focus)
end
end
end
lookAtFocus()
end