• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Public entrance and private entrances.

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
Hello!
I was playing a game to complete missions, however there were two types of entrances for places. Private entrance and the public entrance, in which the private entrance only players in party can enter.

Has two vacancies for private entrance. If both are busy you will compulsorily public entrance.
Or if you want you can join a party to join the private entrances.

I want this NPC to my server ...

Code:
local public = doTeleportThing(cid, x=100, y=100, z=7)
local private1 = doTeleportThing(cid, x=200, y=200, z=7)
local private2 = doTeleportThing(cid, x=300, y=300, z=7)

    if msgcontains(msg, "public entrance") then
      talkState[talkUser] = 1
      selfSay("You want to go to the mountains in the public mode?", cid)
        if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
          selfSay("Good luck!", cid)
          doTeleportThing(cid, publicEntrande)
        elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
          selfSay("I would do the same as you!", cid)
        end
    elseif msgcontains(msg, "private entrance") then
      talkState[talkUser] = 1
      selfSay("You want to go to the mountains in party mode?", cid)
        if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
            if isInParty(cid) == TRUE then
                if getCreaturePosition(getPartyLeader(cid)) == {fromx=200, fromy=200, fromz=7, tox=299, toy=299, toz=7} then
                  doTeleportThing(cid, private1)
                  selfSay("Good luck!", cid)
                elseif getCreaturePosition(getPartyLeader(cid)) == {fromx=300, fromy=300, fromz=7, tox=399, toy=399, toz=7} then
                  doTeleportThing(cid, private2)
                  selfSay("Good luck!", cid)
                else
                  selfSay("The leader of your group is not in any of the two entrances.", cid)
                end
            else
              selfSay("You are not in a party.", cid)
            end
        elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
          selfSay("I would do the same as you!", cid)
        end
    end

I started the script, but I'm newbie :(
 
Code:
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 onPlayerEndTrade(cid)                npcHandler:onPlayerEndTrade(cid)            end
function onPlayerCloseChannel(cid)            npcHandler:onPlayerCloseChannel(cid)        end

local public = doTeleportThing(cid, {x=100, y=100, z=7})
local private1 = doTeleportThing(cid, {x=200, y=200, z=7})
local private2 = doTeleportThing(cid, {x=300, y=300, z=7})
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, "public entrance") then
      talkState[talkUser] = 1
      selfSay("You want to go to the mountains in the public mode?", cid)
        if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
          selfSay("Good luck!", cid)
          doTeleportThing(cid, publicEntrande)
        elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
          selfSay("I would do the same as you!", cid)
        end
    elseif msgcontains(msg, "private entrance") then
      talkState[talkUser] = 1
      selfSay("You want to go to the mountains in party mode?", cid)
        if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
            if isInParty(cid) then
                if isInRange(getCreaturePosition(getPartyLeader(cid)), {x=200, y=200, z=7},{x=299, y=299, z=7}) then
                  doTeleportThing(cid, private1)
                  selfSay("Good luck!", cid)
                elseif isInRange(getCreaturePosition(getPartyLeader(cid)),{x=300,y=300,z=7}, {x=399, y=399,z=7}) then
                  doTeleportThing(cid, private2)
                  selfSay("Good luck!", cid)
                else
                  selfSay("The leader of your group is not in any of the two entrances.", cid)
                end
            else
              selfSay("You are not in a party.", cid)
            end
        elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
          selfSay("I would do the same as you!", cid)
        end
    end
end
 
I changed the script.
But I need it to be sure it is empty, if have someone there he go to another private entrance.
And if the other private entrance is with some group already hunting will come a message saying that the two private entrances are occupied.

Code:
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 public = {x=7488, y=7513, z=8}
local private1 = {x=7371, y=7514, z=8}
local private2 = {x=7241, y=7514, z=8}

function publicEntrance(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
      return false
    end
    if getPlayerStorageValue(cid, HEYTON_REST) <= 0 then
      selfSay("Good luck!", cid)
      doTeleportThing(cid, public)
    else
      selfSay("You have already completed this mission.", cid)
    end
   return true
end

function checkEntrance(cid, message, keywords, parameters, node)
    -- if the entrance(private1) are not full then teleport the player(leader)
         doTeleportThing(cid, private1)
    -- elseif the entrance(private1) are full then teleport the player(leader) to another entrance
         doTeleportThing(cid, private2)
    -- elseif the another entrance(private2) are full then teleport to the public entrance
         doTeleportThing(cid, public)
    end
   return true
end

function privateEntrance(cid, message, keywords, parameters, node)
    if getPlayerStorageValue(cid, HEYTON_REST) <= 0 then
        if isInParty(cid) == true then
            if getPartyLeader(cid) == true then
              doTeleportThing({cid=cid, message=message, keywords=keywords, parameters=parameters, node=node}, checkEntrance)
              selfSay("Good luck!", cid)
            else
                if isInRange(getCreaturePosition(getPartyLeader(cid)), mission.HEYTON_REST_PVT1_FROM, mission.HEYTON_REST_PVT1_TO) then
                  doTeleportThing(cid, private1)
                  selfSay("Good luck!", cid)
                elseif isInRange(getCreaturePosition(getPartyLeader(cid)), mission.HEYTON_REST_PVT2_FROM, mission.HEYTON_REST_PVT2_TO) then
                  doTeleportThing(cid, private2)
                  selfSay("Good luck!", cid)
                else
                  selfSay("The leader of your party is not in any of the two entrances.", cid)
                end
            end
        else
          selfSay("You are not in a party.", cid)
        end
    else
      selfSay("You have already completed this mission.", cid)
    end
   return true
end


keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can guide you to the Heyton's Rest. You want to go in {public entrance} or {private entrance}?"})

local node1 = keywordHandler:addKeyword({'public entrance'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you want to go to the Heyton's Rest in the public mode?"})
    node1:addChildKeyword({'yes'}, publicEntrance, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I would do the same as you!", reset = true})

local node2 = keywordHandler:addKeyword({'private entrance'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you want to go to the Heyton's Rest in party mode?"})
    node2:addChildKeyword({'yes'}, privateEntrance, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I would do the same as you!", reset = true})

npcHandler:addModule(FocusModule:new())
npcHandler:setMessage(MESSAGE_GREET, "Hello, can I {help} you?")

Look:
Code:
function checkEntrance(cid, message, keywords, parameters, node)
    -- if the entrance(private1) are not full then teleport the player(leader)
        doTeleportThing(cid, private1)
    -- elseif the entrance(private1) are full then teleport the player(leader) to another entrance
        doTeleportThing(cid, private2)
    -- elseif the another entrance(private2) are full then teleport to the public entrance
        doTeleportThing(cid, public)
    end
  return true
end
 
Last edited:
Back
Top