Can anyone provide me an example script which shows how to make npc check certain player storage value before sailing with you? If value is -1 he will refuse to sail.
EDIT: Can anyone tell me if its going to work if I rework travel function in npc modules like this:
and in travel.lua add this:
EDIT: Can anyone tell me if its going to work if I rework travel function in npc modules like this:
Lua:
function StdModule.travel(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if(npcHandler == nil) then
error("StdModule.travel called without any npcHandler instance.")
end
if(not npcHandler:isFocused(cid)) then
return false
end
if(isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
if(isPlayerPzLocked(cid)) then
npcHandler:say("First get rid of those blood stains! You are not going to ruin my vehicle!", cid)
elseif(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
npcHandler:say("You must reach level " .. parameters.level .. " before I can let you go there.", cid)
elseif(doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE) then
npcHandler:say("You don't have enough money.", cid)
-- New Function
elseif(parameters.storage ~= nil and getPlayerStorageValue(parameters.storage) == -1) then
npcHandler:say("First you have to travel to this city and ask captain to mark its destination on map.", cid)
-- End
else
npcHandler:say(parameters.msg or "Set the sails!", cid)
npcHandler:releaseFocus(cid)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
doTeleportThing(cid, parameters.destination)
doSendMagicEffect(parameters.destination, CONST_ME_TELEPORT)
end
else
npcHandler:say("I'm sorry, but you need a premium account in order to travel onboard our ships.", cid)
end
npcHandler:resetNpc()
return true
end
and in travel.lua add this:
Lua:
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 100, storage = 1000, destination = {x=2222, y=1759, z=6} })
Last edited: