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

Lua Action - Remove Skill

darcioantonio

www.adventurerpg.com.br
Joined
Jul 30, 2013
Messages
165
Solutions
1
Reaction score
4
Location
Brasil
Twitch
darcio_
YouTube
UCEXCOEw_dYchojHNz
Action for Food: Use = +1 Skill Shield ~ 5 Sec -1 Shield.
No remove Skill :(
TF0.4 860

Lua:
function onUse(cid, item, frompos, item2, topos)
doPlayerAddSkill(cid, 5, 1)
doSendAnimatedText(topos, "+1 Distancia!", TEXTCOLOR_GREEN)
addEvent(function()
doSendAnimatedText(topos, "+1 Distancia!", TEXTCOLOR_GREEN)
doPlayerAddSkill(cid, 5, -1)
end, 5*1000)

end
 
Solution
Lua:
local seconds = 5
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 1)
setConditionParam(condition, CONDITION_PARAM_TICKS, seconds * 1000)

local function informlater(cid)
    if isCreature(cid) then
        doSendAnimatedText(getCreaturePosition(cid), "-1 Distancia!", TEXTCOLOR_GREEN)
    end
end

function onUse(cid, item, frompos, item2, topos)
    doAddCondition(cid, condition)
    doSendAnimatedText(topos, "+1 Distancia!", TEXTCOLOR_GREEN)
    addEvent(informlater, seconds * 1000, cid)
    return true
end
Does the event run? Do you get +1 distancia after 5 seconds?
have you tried to call doPlayerAddSkill(cid, 5, -1) directly to see if that works? It could be the function does not support negative values.

You may need to look into how skill rings does things and use it as a reference.
 
You can't remove skills with that function or any Lua functions AFAIK, best way is most likely to remove / lower the value via an SQL query and then save the player.
 
You can't remove skills with that function or any Lua functions AFAIK, best way is most likely to remove / lower the value via an SQL query and then save the player.
Since players are being loaded into memmory on login, I think you would need to kick them and do the change after their logout save call is called. Calling save after an SQL query will most likely overwrite your recent change with the player object that is already loaded into the memmory.

I think the best bet would be to adjust AddSkill (or addSkillTry) to support negative values in C++.
 
Since players are being loaded into memmory on login, I think you would need to kick them and do the change after their logout save call is called. Calling save after an SQL query will most likely overwrite your recent change with the player object that is already loaded into the memmory.

Yeah you are correct, might be better to try and write a new function for it in that case.
Question is why it hasn't been done yet .. could it be harder then it sounds?
 
if you're trying to add and remove skill, use a condition object instead
here's an example
Lua:
local time = xxxxx -- time in milliseconds
local condition = createConditionObject()
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 5)
setConditionParam(condition, CONDITION_PARAM_TICKS, time)
 
if you're trying to add and remove skill, use a condition object instead
here's an example
Lua:
local time = xxxxx -- time in milliseconds
local condition = createConditionObject()
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 5)
setConditionParam(condition, CONDITION_PARAM_TICKS, time)

Ohh, why didnt I think of this. xD
Can you destroy or remove a condition object before it expires by ticks?
Will multiple conditionobjects of same type stack, overwrite or be ignored?
 
Ohh, why didnt I think of this. xD
Can you destroy or remove a condition object before it expires by ticks?
Will multiple conditionobjects of same type stack, overwrite or be ignored?
yes you can remove condition whenever before ticks end, and i think they stack unless you're using the same subid
 
Lua:
local seconds = 5

function onUse(cid, item, frompos, item2, topos)
    local condition = createConditionObject()
    setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 1)
    setConditionParam(condition, CONDITION_PARAM_TICKS, seconds * 1000)
    doAddCondition(cid, condition)
 
    doSendAnimatedText(topos, "+1 Distancia!", TEXTCOLOR_GREEN)
    addEvent(informlater, seconds * 1000, cid)
end

function informlater(cid)
    if isCreature(cid) then
        local topos = getCreaturePosition(cid)
        doSendAnimatedText(topos, "-1 Distancia!", TEXTCOLOR_GREEN)
    end
    return true
end

I reinitialize topos in the event in order to get the position the player is curently in when loosing the skill, instead of where he used the item.

Now just add this script to blueberries and it will be the best consumable item in the game. :D

Imagine a paladin gobbling down a bucket of blueberries shooting a Super Saiyan power bolt in your face.
 
Last edited:
Lua:
local seconds = 5

function onUse(cid, item, frompos, item2, topos)
    local condition = createConditionObject()
    setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 1)
    setConditionParam(condition, CONDITION_PARAM_TICKS, seconds * 1000)
    doAddCondition(cid, condition)
 
    doSendAnimatedText(topos, "+1 Distancia!", TEXTCOLOR_GREEN)
    addEvent(informlater, 1000*seconds, {cid=cid})
end

function informlater(tbl)
    local cid = tbl.cid
    if isCreature(cid) then
        local topos = getCreaturePosition(cid)
        doSendAnimatedText(topos, "-1 Distancia!", TEXTCOLOR_GREEN)
    end
    return true
end

I reinitialize topos in the event in order to get the position the player is curently in when loosing the skill, instead of where he used the item.

Now just add this script to blueberries and it will be the best consumable item in the game. :D
you don't need to pass cid as a table you can just pass it directly
 
Ops 1 erro.
Lua:
local seconds = 5
function onUse(cid, item, frompos, item2, topos)
    local condition = createConditionObject()
    setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 1)
    setConditionParam(condition, CONDITION_PARAM_TICKS, seconds * 1000)
    doAddCondition(cid, condition)
    doSendAnimatedText(topos, "+1 Distancia!", TEXTCOLOR_GREEN)
    addEvent(informlater, 1000*seconds, {cid=cid})
end
function informlater(tbl)
    local cid = tbl.cid
    if isCreature(cid) then
        local topos = getCreaturePosition(cid)
        doSendAnimatedText(topos, "-1 Distancia!", TEXTCOLOR_GREEN)
    end
    return true
end

-- [ Erro ]

Code:
[13:1:37.149] [Error - Action Interface]
[13:1:37.149] data/actions/scripts/Colheita Feliz/Receitas/receitaA.lua:onUse
[13:1:37.150] Description:
[13:1:37.151] (luaDoAddCondition) Condition not found
 
Last edited by a moderator:
Lua:
local seconds = 5
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 1)
setConditionParam(condition, CONDITION_PARAM_TICKS, seconds * 1000)

local function informlater(cid)
    if isCreature(cid) then
        doSendAnimatedText(getCreaturePosition(cid), "-1 Distancia!", TEXTCOLOR_GREEN)
    end
end

function onUse(cid, item, frompos, item2, topos)
    if getCreatureCondition(cid, CONDITION_ATTRIBUTES) then
        return false
    end
    doAddCondition(cid, condition)
    doSendAnimatedText(topos, "+1 Distancia!", TEXTCOLOR_GREEN)
    addEvent(informlater, seconds * 1000, cid)
    return true
end
 
You can link the script with many kinds of food if I right understood your question.
Lua:
<action itemid="2362;2363;2666-2691;2696;2787-2796;5097;6125;6278;6279;6394" event="script" value="YourScript.lua"/>
 
Lua:
local seconds = 5
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 1)
setConditionParam(condition, CONDITION_PARAM_TICKS, seconds * 1000)

local function informlater(cid)
    if isCreature(cid) then
        doSendAnimatedText(getCreaturePosition(cid), "-1 Distancia!", TEXTCOLOR_GREEN)
    end
end

function onUse(cid, item, frompos, item2, topos)
    doAddCondition(cid, condition)
    doSendAnimatedText(topos, "+1 Distancia!", TEXTCOLOR_GREEN)
    addEvent(informlater, seconds * 1000, cid)
    return true
end
 
Solution
Back
Top