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

RevScripts Private Spawn - Teleport - Tile - Issue with party

endziu2222

Active Member
Joined
Nov 2, 2010
Messages
167
Solutions
1
Reaction score
44
I was trying to create private teleport for party or single players but it seem I have problem to manage it.. So far script does allow party to enter teleport however if players are not member from any party they won't be allowed inside. If there is one party inside the privatespawn another party can just join as well... This is wrong only one party should be allowed...

Now question How do I go around this to sort it out?? do i need edit in source??

I am using Canary. Anybody???

Lua:
local specialTeleport = MoveEvent()

-- Constants for positions
local privateSpawn = Position(2491, 2875, 7)
local privateSpawnFrom = Position(2491, 2868, 7)
local privateSpawnTo = Position(2513, 2889, 7)
local requiredItemID = 3043
local requiredItemCount = 10

-- Custom function to check if a position is within an area
local function isInArea(position, fromPos, toPos)
    return (
        position.x >= fromPos.x and position.y >= fromPos.y and
        position.x <= toPos.x and position.y <= toPos.y and
        position.z == fromPos.z
    )
end

function specialTeleport.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    -- Check if the player is in a party
    local inParty = player:getParty() ~= nil

    -- Check if the player's position is within the private spawn zone area
    if not isInArea(player:getPosition(), privateSpawnFrom, privateSpawnTo) then
        if inParty then
            -- If the player is in a party, they are allowed to enter the private spawn
            if player:getItemCount(requiredItemID) < requiredItemCount then
                -- The player does not have enough of the required item
                player:sendCancelMessage("You do not have enough of Item ID " .. requiredItemID .. " to enter the private zone.")
            else
                -- Remove the required items
                player:removeItem(requiredItemID, requiredItemCount)

                -- Teleport the player to the private spawn
                player:teleportTo(privateSpawn)
                privateSpawn:sendMagicEffect(CONST_ME_TELEPORT)

                -- Send a welcome message
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Welcome to the private spawn area.")
            end
        else
            player:sendCancelMessage("You are not in a party. Only party members can enter this area.")
        end
    end

    return true
end

specialTeleport:type("stepin")
specialTeleport:aid(38551)
specialTeleport:register()
 
Back
Top