local COIN_ID = 6535 -- DexSoft Coin ID
local COIN_AMOUNT = 1 -- Amount of DexSoft Coins the player will need to revive
local MAGIC_EFFECT_TELEPORT = 65 -- Effect that will appear when the player is teleported
local PLAYER_REBORN_POSITION_X = 66541
local PLAYER_REBORN_POSITION_Y = 66542
local PLAYER_REBORN_POSITION_Z = 66543
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'revive') then
selfSay('You need ' .. COIN_AMOUNT .. ' DexSoft Coin(s) to resurrect at the location where you recently died.', cid)
talkState[talkUser] = 1
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if getPlayerItemCount(cid, COIN_ID) >= COIN_AMOUNT then
doPlayerRemoveItem(cid, COIN_ID, COIN_AMOUNT)
if teleportPlayerToPositionReborn(cid) then
doTeleportThing(cid, {x = PLAYER_REBORN_POSITION_X, y = PLAYER_REBORN_POSITION_Y, z = PLAYER_REBORN_POSITION_Z})
doSendMagicEffect(getCreaturePosition(cid), MAGIC_EFFECT_TELEPORT)
selfSay('Ok, you have been resurrected.', cid)
end
else
selfSay('Sorry, but you do not have enough DexSoft Coins.', cid)
end
talkState[talkUser] = 0
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
talkState[talkUser] = 0
selfSay('Ok, goodbye.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
function teleportPlayerToPositionReborn(cid)
local playerRebornPositionX = getPlayerStorageValue(cid, PLAYER_REBORN_POSITION_X)
local playerRebornPositionY = getPlayerStorageValue(cid, PLAYER_REBORN_POSITION_Y)
local playerRebornPositionZ = getPlayerStorageValue(cid, PLAYER_REBORN_POSITION_Z)
if playerRebornPositionX == -1 or playerRebornPositionY == -1 or playerRebornPositionZ == -1 then
selfSay('You have not died yet.', cid)
return false
end
doTeleportThing(cid, {x = playerRebornPositionX, y = playerRebornPositionY, z = playerRebornPositionZ})
return true
end
[13/09/2024 14:16:35] [Error - Npc interface] [13/09/2024 14:16:35] data/npc/scripts/reviver.lua:onThink [13/09/2024 14:16:35] Description: [13/09/2024 14:16:35] (luaGetCreatureName) Creature not found [13/09/2024 14:16:35] [Error - Npc interface] [13/09/2024 14:16:35] data/npc/scripts/reviver.lua:onThink [13/09/2024 14:16:35] Description: [13/09/2024 14:16:35] data/npc/lib/npcsystem/npchandler.lua:301: bad argument #3 to 'gsub' (string/function/table expected) [13/09/2024 14:16:35] stack traceback: [13/09/2024 14:16:35] [C]: in function 'gsub' [13/09/2024 14:16:35] data/npc/lib/npcsystem/npchandler.lua:301: in function 'parseMessage' [13/09/2024 14:16:35] data/npc/lib/npcsystem/npchandler.lua:538: in function 'onWalkAway' [13/09/2024 14:16:35] data/npc/lib/npcsystem/npchandler.lua:473: in function 'onThink' [13/09/2024 14:16:35] data/npc/scripts/reviver.lua:26: in function <data/npc/scripts/reviver.lua:25>