• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[TFS 1.0] !openhole command (Open a hole for a price)

Jack Parsons

Member
Joined
Mar 8, 2016
Messages
32
Reaction score
12
Location
São Paulo State, Brazil
I've developed a talkaction that allows a player to open a shovel hole for a price (I've decided that 1k is a fair price, considering the player's stupidity of not having a shovel). The script detects whether there's a hole in front of the player or not, and then checks whether the player has the necessary amount of money or not, and then it transforms the tile accordingly (Just like shovel.lua).

Entry in talkactions.xml:
Code:
<talkactions>
...
    <talkaction words="!openhole" script="openhole.lua"/>
...
</talkactions>

openhole.lua:
Code:
-- Script by Rederick Deathwill (Ericson Willians).

function onSay(cid, words, param)
    local price = 1000
    local p = Player(cid)
    local pPos = p:getPosition()
    local pDir = p:getDirection()
    local holes = {468, 481, 483}
    local holePos = nil
    local isEverythingFalse = true
    local booleanHoles = {false, false, false}
    if pDir == NORTH then
        holePos = {x = pPos['x'], y = pPos['y']-1, z = pPos['z'], stackpos = 0}
    elseif pDir == SOUTH then
        holePos = {x = pPos['x'], y = pPos['y']+1, z = pPos['z'], stackpos = 0}
    elseif pDir == WEST then
        holePos = {x = pPos['x']-1, y = pPos['y'], z = pPos['z'], stackpos = 0}
    elseif pDir == EAST then
        holePos = {x = pPos['x']+1, y = pPos['y'], z = pPos['z'], stackpos = 0}
    end
    for i, v in ipairs(holes) do
        local thing = getTileThingByPos(holePos)
        if thing["itemid"] == v then
            booleanHoles[i] = true
            if p:getMoney() >= price then
                p:say("Open hole!", TALKTYPE_MONSTER_SAY)
                local h = Item(thing["uid"])
                h:transform(thing["itemid"] + 1)
                h:decay()
                p:removeMoney(price)
            else
                p:sendTextMessage(MESSAGE_INFO_DESCR, "You need " .. price .. " gp in order to open this hole. Go get a shovel!")
                p:getPosition():sendMagicEffect(CONST_ME_POFF)
            end
        end
    end
    for _, v in ipairs(booleanHoles) do
        if v then
            isEverythingFalse = false
        end
    end
    if isEverythingFalse then
        p:sendTextMessage(MESSAGE_INFO_DESCR, "Don't be silly, what you're trying to open is not a hole.")
        p:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return false
end
 
If a player forgot a shovel and is heading to a hunting spot that requires a shovel...wouldn't he also not have 1k gold? I would understand this script if it was linked to their bank but its not.
 
It's not unusual to have 1k in the bp (Considering OT Servers, it's not unusual players that don't use the bank at all). Also, it's easy to make it work for free (Actually, just a matter of one line), and experienced players would have a shovel with them.
 
There is no reason to argue. I am just making the point that this doesn't solve anything for players who don't bring money or a shovel. Which is a very high possibility if they forget to remember a shovel itself.

btw how did you know my name was Nathan ;)
 
Back
Top