• 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 npc travel

Ezeq

New Member
Joined
Nov 23, 2010
Messages
45
Reaction score
1
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:
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:
I''m new to Lua, but this maybe? o.0

Lua:
if getPlayerStorageValue == blah then
   doPlayerSendCancel(cid,21, "Sorry, I cannot sail you at this time, try again later."
 
Lua:
local ID_STORAGE = XXXX
if getPlayerStorageValue(cid, ID_STORAGE) == -1 then
   doPlayerSendCancel(cid, 21, "Sorry, I cannot sail you at this time, try again later."
return true
end
 
ye, but how do you combine it with normal travel script like this:
Lua:
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


      	local travelNode = keywordHandler:addKeyword({'port hope'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'text'})
        travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 100, destination = {x=2222, y=1759, z=6} })
       	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'text'})


        keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'sail'})
        keywordHandler:addKeyword({'map'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'map'})
        keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'sail'})

npcHandler:addModule(FocusModule:new())
I want to implement a check player storage value function :S

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:
Lua:
if getPlayerStorageValue(cid, 300) == 1 then
       doTeleportThing(cid, {x=1338, y=1337, z=6})
else
       doPlayerSendCancel(cid, "Yeye no travel 4 u")
end
 
Lua:
if getPlayerStorageValue(cid, 300) == 1 then
       doTeleportThing(cid, {x=1338, y=1337, z=6})
else
       doPlayerSendCancel(cid, "Yeye no travel 4 u")
end

People, stop trolling me, I can script such a basic scripts. Your one doesnt even remove gold, checks if premium etc. I need better help :S

Updated first post!
 
Back
Top