• 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!

Boat NPC

Alaa Adel

Basic Mapper
Joined
Mar 2, 2014
Messages
231
Reaction score
8
I've been looking for a tutorial that shows the boat npc script but i never found a script that works!
So, if anyone knows a working script please post it here!
 
Code:
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)
       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

You can find this function on line 153. On line 166 you have to change the doPlayerRemoveMoney line for the doPlayerRemoveItem line.
 
[23/06/2014 12:54:08] Lua Script Error: [Npc interface]
[23/06/2014 12:54:08] data/npc/scripts/travel.lua
[23/06/2014 12:54:08] data/npc/scripts/travel.lua:3: attempt to index global 'NpcSystem' (a nil value)
[23/06/2014 12:54:08] stack traceback:
[23/06/2014 12:54:08] [C]: in function '__index'
[23/06/2014 12:54:08] data/npc/scripts/travel.lua:3: in main chunk
[23/06/2014 12:54:08] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/travel.lua

any help?
 
Last edited by a moderator:
Just use your original modules (unedited version) and only change that line on line 166, you probable accidentally removed something.
 
ok now i have the unedited cuz i have 2 servers .. the other one i have cuz if i lost something i can re-get it again...
so now i have to count the whole modules until i find 166 lines ???! LOL :D
 
Use notepad ++, if you open the script there, you see the line numbers, just like pastebin. You can also use ctrl f and go to function StdModule.travel, it's the line under/in that function.
 
Hey Limos :D, sorry for alot of questions but, do you know how to make a spawn for only 1hour? i mean the player get kicked to the temple when 1hour pass?
 
action door
Code:
local config = {
   storage = 8034,
   time = 3600,
   fromPos = {x=92, y=114, z=7},
   toPos = {x=98, y=120, z=7},
   backPos = {x=94, y=122, z=7}
}

local function doKickPlayer(cid)
   if not isPlayer(cid) then
     return true
   end
   if isInRange(getPlayerPosition(cid), config.fromPos, config.toPos) then
     doTeleportThing(cid, config.backPos)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"Time is up!")
   end
   return true
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
  
   if getPlayerStorageValue(cid, config.storage) >= os.time() then
     doTransformItem(item.uid, item.itemid + 1)
     doTeleportThing(cid, toPosition)
     local m = math.floor((getPlayerStorageValue(cid, config.storage) - os.time()) / 60) > 0 and math.floor((getPlayerStorageValue(cid, config.storage) - os.time()) / 60) or 1
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You have "..m.." "..(m == 1 and "minute" or "minutes").." left to hunt in the spawn.")
     addEvent(doKickPlayer, m * 60 * 1000, cid)
   elseif doPlayerRemoveItem (cid, 2160, 1) then
     doTransformItem(item.uid, item.itemid + 1)
     doTeleportThing(cid, toPosition)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You have now entered some spawn, you can hunt here for 1 hour.")
     addEvent(doKickPlayer, config.time * 1000, cid)
     setPlayerStorageValue(cid, config.storage, os.time() + config.time)
   else
     doPlayerSendCancel(cid, "You need 1 cc to enter.")
   end
   return true
end

Add to login.lua or other login script.
Code:
local config = {
   storage = 8034,
   time = 3600,
   fromPos = {x=92, y=114, z=7},
   toPos = {x=98, y=120, z=7},
   backPos = {x=94, y=122, z=7}
}

local function doKickPlayer(cid)
   if not isPlayer(cid) then
     return true
   end
   if isInRange(getPlayerPosition(cid), config.fromPos, config.toPos) then
     doTeleportThing(cid, config.backPos)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"Time is up!")
   end
   return true
end

if isInRange(getPlayerPosition(cid), config.fromPos, config.toPos) then
   if getPlayerStorageValue(cid, config.storage) < os.time() then
     doTeleportThing(cid, config.backPos)
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING,"Time is up!")
   else
     local m = math.floor((getPlayerStorageValue(cid, config.storage) - os.time()) / 60) > 0 and math.floor((getPlayerStorageValue(cid, config.storage) - os.time()) / 60) or 1
     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"You have "..m.." "..(m == 1 and "minute" or "minutes").." left to hunt in the spawn.")
     addEvent(doKickPlayer, m * 60 * 1000, cid)
   end
end
 
Oh! :) thank you i didn't test it for all but the message worked xD.
I'm waiting for the time :D
But really thank you, you helped me very much rep+
 
Ok i have to tell you some bugs, when i enter the door with my 1cc... i stand on the door's square... and when i stand on it, i can use the door (close it and open it) when i use it, it changes the door's looktype and when i keep using for some seconds it turns to a wall! so i can no longer use it or any other player who wants to hunt in the spawn for 1h wont find the door and cant use or anything! so need to fix this. And also i don't understand that frompos and backpos ... does frompos means he gets teleported from this position {x=92, y=114, z=7} to the topos position??? only teleports from 1 place?
And how is the 1hour = time = 3600 ? xD
anyway it didn't get teleported to the topos position but im not very sure... but just i need more information about this script.
thanks!
 
Use a gate of expertise door.

Time is in seconds, so 3600 seconds is 1 hour.

fromPos and toPos are the positions in the spawn.
fromPos is the left upper corner of the spawn, toPos is the right lower corner of the spawn.
This is to check if the player is in the spawn.

The backPos is the position it should be teleported to if the time is up, this can be the temple or infront of the door to enter the spawn.
 
Last edited:
Yes, I tested the action script on Mystic Spirit.
I didn't test the login part, but thats just a copy from script parts of the action script, so pretty sure I didn't make type mistakes there :p
 
Use an uniqueid, in doors.lua gate of expertise doors already work with actionids, so that would conflict.
Which uniqueid doesn't matter, add same uniqueid in the door as in actions.xml.
 
Back
Top