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

TFS 0.X Exercise Dummie to 8.6

maikons

Member
Joined
Aug 1, 2015
Messages
227
Reaction score
16
Exercise dummies are a new funny way to train in servers 11x but there isnt such a thing in 8.6 servers, even that this not need change nothing on graphics
But i'm not good enoght to do it alone, so i need some help to make it work and if others servers want to use be free to use

I was thinking about make it by action, a member on forum helped me to do, but we couldnt make work
Code:
<action actionid="7998" script="train_weapon.lua" />

Code:
local requiredItem = {
    [8980] = {
        storage = 123456,
        removeAmount = 1,
        effect = 2,
        skill = SKILL_FIST,
        tries = 1,
        poof = CONST_ME_POFF,
        message = "Your Exercise Weapon is already in use.",
    }
}

local state, eventId = {}, {}

test = function(cid, pos, t)
    if not next(eventId[cid]) then
        return
    end
    -- if the player does not exist (they logged out) or their position has changed since they used the item
    if not Player(cid) or pos ~= getCreaturePosition(cid) then
        -- reset everything
        if next(eventId[cid]) then
            for _, eid in pairs(eventId[cid]) do
                stopEvent(eid)
            end
        end
        eventId[cid] = nil
        state[cid].key = false
    -- is the return value of getting the storage greater than or equal to the remove amount
    -- and is the stored position the same as the player's current position
    elseif t.value >= t.removeAmount and pos == getCreaturePosition(cid) then
        doSendMagicEffect(pos, t.effect)
        doPlayerAddSkillTry(cid, t.skill, t.tries)
        setPlayerStorageValue(cid, t.storage, (t.value - t.removeAmount))
        if getPlayerStorageValue(cid, t.storage) <= 0 then
            -- remove the item and reset the state
            doPlayerRemoveItem(cid, t.itemid, 1)
            state[cid].key = false
        end
    end       
end

function isActive(cid)
    if not state[cid] then
        state[cid] = {key = false}
    end
    return state[cid].key
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    -- default values
    local x, pos, message, effect = requiredItem[item.itemid], getCreaturePosition(cid), "Sorry, not possible.", CONST_ME_POFF
    if x and isActive(cid) then
        effect = x.poof
        message = x.message
    elseif x and not isActive(cid) then
        x.count = getPlayerItemCount(cid, item.itemid)
        x.value = getPlayerStorageValue(cid, x.storage)
        x.itemid = item.itemid
        state[cid].key = true
        if x.count >= 1 and x.value >= x.removeAmount then
            eventId[cid] = {}
            for i = x.value, 1, -1 do
                -- save the event id's so we can stop them later if the player moves
                eventId[cid][i] = addEvent(test, i * 1000, cid, pos, x)
            end
        end
        return true
    else
        message = "You need an Exercise Weapon to train with an Exercise Dummie."
    end
    doSendMagicEffect(pos, effect)
    doPlayerSendCancel(cid, message)
    return true
end

It's always shows the message = "You need an Exercise Weapon to train with an Exercise Dummie."

Is anyone know how to make it work?
 
I tried for like 25 minutes to understand what is going on in the script.. or how the script is supposed to work and I'm still confused because it's definitely not a finished script.

The only definitive thing I can tell you is the answer to your question.

You are always getting the message
"You need an Exercise Weapon to train with an Exercise Dummie."
Because you are using the item with actionid 7998 attached to it instead of using one of the requiredItem's in your table onto that item.

line 52 grabs "item.itemid", which is the item being clicked on by the player.
Which in your case is whatever item you've placed actionid 7998 onto, which isn't listed in your table "requiredItem".
Because it's not listed in that table lines 53 and 56 will always return false and is going to default to the else statement every time.
 
I tried for like 25 minutes to understand what is going on in the script.. or how the script is supposed to work and I'm still confused because it's definitely not a finished script.

The only definitive thing I can tell you is the answer to your question.

You are always getting the message
"You need an Exercise Weapon to train with an Exercise Dummie."
Because you are using the item with actionid 7998 attached to it instead of using one of the requiredItem's in your table onto that item.

line 52 grabs "item.itemid", which is the item being clicked on by the player.
Which in your case is whatever item you've placed actionid 7998 onto, which isn't listed in your table "requiredItem".
Because it's not listed in that table lines 53 and 56 will always return false and is going to default to the else statement every time.

I don't know how to do it, i found this script on forum (it was a try)...
Could u help to fix, make a base or even make the script to the community?
Pretty sure a lot servers would use a Exercise Dummies/xercise Weapons for 8.6
 
 
Solution
Back
Top