vitorelias1
New Member
- Joined
- Sep 27, 2022
- Messages
- 27
- Reaction score
- 2
hello guys!
I have this travel npc script
I changed the version of my otserv and some traveling NPCs have the option of traveling without money in the backpack it removes the money from the bank I would like to modify this script to work if the player does not have money in the backpack it removes it from the bank
I have this travel npc script
I changed the version of my otserv and some traveling NPCs have the option of traveling without money in the backpack it removes the money from the bank I would like to modify this script to work if the player does not have money in the backpack it removes it from the bank
Lua:
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)
function lowerTable(tabela) -- by vodkart
local tab = {}
for var, ret in next, tabela do
tab[var:lower()] = ret
end
return tab
end
if not npcHandler:isFocused(cid) then
return false
end
local talkUser,msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, msg:lower()
local viagens = {
['Dark City'] = {premium = false, level = 0, cost = 200, destination = {x=766, y=1090, z=6}},
}
local magician_pos = {x=1249, y=783, z=6}
local travel = lowerTable(viagens)
if travel[msg] then
local var = travel[msg]
if var.level > 0 and getPlayerLevel(cid) < var.level then
npcHandler:say("Sorry but you must be level ".. var.level .." to travel to this place.", cid) return true
elseif var.premium and not isPremium(cid) then
npcHandler:say("Sorry, to go to "..msg.." it is necessary to be VIP.", cid) return true
elseif not doPlayerRemoveMoney(cid, var.cost) then
npcHandler:say("Sorry, you don't have enough GPS. Is required ".. var.cost .."gps to go to "..msg..".", cid) return true
end
if var.chance ~= nil and var.chance > 0 then
if getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid == 10219 then
mychance = 100
else
mychance = var.chance
end
end
npcHandler:say("Bon voyage!", cid)
npcHandler:releaseFocus(cid)
if var.chance ~= nil and var.chance > 0 then
if mychance > math.random(1, 100) then
doTeleportThing(cid, garath_pos)
npcHandler:say("The boat lost its way and stopped in Magician, Careful!", cid)
else
doTeleportThing(cid, var.destination)
end
else
doTeleportThing(cid, var.destination)
end
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
else
selfSay("I don't sail to this city...", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())