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

Frag Door

semary

[BB] OTland
Joined
May 3, 2009
Messages
813
Reaction score
18
Location
E G Y P T
i have idea i hope some one can help me in it

i want if player have more than 100 frag he can pass the door


SolvedThanks Cybershot
 
Last edited:
try this

Code:
local config = {
    uniqueid = 1000, -- action id that the door needs to have
    frags = 100, --- how many frags to enter
    direction = 1 --- 1 = up, 2 = right, 3 = down, 4 = left
    }

function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = getThingPos(cid)
    if item.uniqueid == config.uniqueid then
        if getPlayerFrags(cid) >= config.frags then
        local pos = {{x=v.x,y=v.y-2,z=v.z},{x=v.x+2,y=v.y,z=v.z},{x=v.x,y=v.y+2,z=v.z},{x=v.x-2,y=v.y,z=v.z}}
            doTeleportThing(cid,pos[config.direction],false)
            return doSendMagicEffect(pos[config.direction],10)
        else
            doPlayerSendTextMessage(cid,20,'You need '..config.frags' frags to enter this door.')
            return doSendMagicEffect(v,2)
        end
    end
end
what happened with the return true and return false oO man that script sux ;$ lets use expertise frag door instead.
and getPlayerFrags has been deprecated

this one worked when premmy door, so it'll work:
LUA:
local function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}

    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end

    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }
    
    return size.day + size.week + size.month
end        

local function checkStackpos(item, position)
    position.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
    local thing = getThingFromPos(position)

    position.stackpos = STACKPOS_TOP_FIELD
    local field = getThingFromPos(position)

    return (item.uid == thing.uid or thing.itemid < 100 or field.itemid == 0)
end

local function doorEnter(cid, item, toPosition)
    doTransformItem(item.uid, item.itemid + 1)
    doTeleportThing(cid, toPosition)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(fromPosition.x ~= CONTAINER_POSITION and isPlayerPzLocked(cid) and getTileInfo(fromPosition).protection) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    if(getItemLevelDoor(item.itemid) > 0) then
        if getPlayerFrags(cid) < 100 then 
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You must have 100 frags or more in order to pass through this door.')
            return true
        end

        doorEnter(cid, item, toPosition)
        return true
    end
        
    if(isInArray(horizontalOpenDoors, item.itemid) and checkStackpos(item, fromPosition)) then
        local newPosition = toPosition
        newPosition.y = newPosition.y + 1
        local doorPosition = fromPosition
        doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
        local doorCreature = getThingfromPos(doorPosition)
        if(doorCreature.itemid ~= 0) then
            local pzDoorPosition = getTileInfo(doorPosition).protection
            local pzNewPosition = getTileInfo(newPosition).protection
            if((pzDoorPosition and not pzNewPosition and doorCreature.uid ~= cid) or
                (not pzDoorPosition and pzNewPosition and doorCreature.uid == cid and isPlayerPzLocked(cid))) then
                doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            else
                doTeleportThing(doorCreature.uid, newPosition)
                if(not isInArray(closingDoors, item.itemid)) then
                    doTransformItem(item.uid, item.itemid - 1)
                end
            end

            return true
        end

        doTransformItem(item.uid, item.itemid - 1)
        return true
    end

    if(isInArray(verticalOpenDoors, item.itemid) and checkStackpos(item, fromPosition)) then
        local newPosition = toPosition
        newPosition.x = newPosition.x + 1
        local doorPosition = fromPosition
        doorPosition.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
        local doorCreature = getThingfromPos(doorPosition)
        if(doorCreature.itemid ~= 0) then
            if(getTileInfo(doorPosition).protection and not getTileInfo(newPosition).protection and doorCreature.uid ~= cid) then
                doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            else
                doTeleportThing(doorCreature.uid, newPosition)
                if(not isInArray(closingDoors, item.itemid)) then
                    doTransformItem(item.uid, item.itemid - 1)
                end
            end

            return true
        end

        doTransformItem(item.uid, item.itemid - 1)
        return true
    end
        
    return false
end

doesnt require tp or positions xDDDD
 
Last edited:
Back
Top