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
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?
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?