• 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 Only challenge if the player have a storage

Joined
Apr 11, 2015
Messages
98
Reaction score
5
0.4
Hello everybody, im here to ask for help.
I was trying to do a normal attack spell, but if the player has a storage, the creature would target him, like exeta res.
Here's the code I worked so far:
C++:
local outfit = 425


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 0)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)

local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)

function onGetFormulaValues(cid, level, skill, attack, factor)
    skill = getPlayerSkill(cid, SKILL_FIST)
    return
        - (skill * 1),
        - (skill * 1.1)
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')
function onCastSpell(cid, var)

if getPlayerStorageValue(cid, 27133) == 1 then
if isCreature(target) then
            doChallengeCreature(cid, target)
        end
            else
                end
    if getCreatureOutfit(cid).lookType == outfit then
        return doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid, "")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    end
end

There is no errors in console, but if the player, that have the storage, uses the spell, the creature don't turn on him
 
Hard to tell what the hell is going on here because your code is actually terrible and I don't usually say that.

This should get you a little closer.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)

local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)

function onGetFormulaValues(cid, level, skill, attack, factor)
    min = getPlayerSkill(cid, SKILL_FIST) * 1.0
    max = getPlayerSkill(cid, SKILL_FIST) * 1.1
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')

local storage = 27133

function onCastSpell(cid, var)
    local target = variantToNumber(var)
    if isPlayer(cid) and target and isMonster(target) then
        if getPlayerStorageValue(cid, storage) == 1 then
            doChallengeCreature(cid, target)
        end
    end
    return doCombat(cid, combat, var)
end
 
@Itutorial Why its a terrible code? Only the area there is useless, but all the others work just fine.
The spell is like an exori, but also challenge the creature if you have the storage and you need to be wearing a specific outfit to cast the spell.
But didn't work the code, no errors in the console
 
You never said anything about player needing a certain outfit. The code had a bunch of stuff in it that was nonsense thats why it was bad.
Post automatically merged:

Try this

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)

local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)

function onGetFormulaValues(cid, level, skill, attack, factor)
    local min = getPlayerSkill(cid, SKILL_FIST) * 1.0
    local max = getPlayerSkill(cid, SKILL_FIST) * 1.1
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')

local storage = 27133
local outfitId = 425

function onCastSpell(cid, var)
    local target = variantToNumber(var)
    if isPlayer(cid) and target and isMonster(target) and getCreatureOutfit(cid).looktype == outfitId then
        if getPlayerStorageValue(cid, storage) == 1 then
            doChallengeCreature(cid, target)
        end
    end
    return doCombat(cid, combat, var)
end
 
@Itutorial In my code, if there was a local outfit and then a code like this:
if getCreatureOutfit(cid).lookType == outfit then
Why did i had to say about the outfit?
Also, didnt work, no errors but also no damage
 
Code:
function onGetFormulaValues(cid, level, skill, attack, factor)
    local min = getPlayerSkill(cid, SKILL_FIST) * 1.0
    local max = getPlayerSkill(cid, SKILL_FIST) * 1.1
    return -min, -max
end

change that
 
I have just tested it again. Its working.
You must be declaring it wrong.
How are you putting the code into xml.

The above code Itutorial posted allows you to use the spell but the challenge only works if player has outfit.
Its not difficult to modify to get working for what you want, if you had tried.

If i understand correctly
If storage value then challenge.
if outfit then cast spell else poof.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_USECHARGES, true)

local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)

function onGetFormulaValues(cid, level, skill, attack, factor)
    local min = getPlayerSkill(cid, SKILL_FIST) * 1.0
    local max = getPlayerSkill(cid, SKILL_FIST) * 1.1
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, 'onGetFormulaValues')

local storage = 27133
local outfitId = 425

function onCastSpell(cid, var)
    local target = variantToNumber(var)
    if isPlayer(cid) and target and isMonster(target) then
        if getPlayerStorageValue(cid, storage) == 1 then
            doChallengeCreature(cid, target)
        end
    end
    if getCreatureOutfit(cid).looktype == outfitId then
        return doCombat(cid, combat, var)
    else
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        return
    end
end

1586744841834.png
You can see its working in the images I've posted.
 
Last edited:
@Leesne Ok, here in my server, it poofs all the time, if player has the storage, if player is using the outfit, if its not.... He can't use the spell at all.
The idea of the spell is the following: If the player is wearing the outfit, the spell casts, if not, poof. AND, if the player has the storage, the spell also challenge the monster
 
post your spells.xml as i said.
so you just need to put this above return doCombat, and it will do exactly what you said.
Lua:
        if getPlayerStorageValue(cid, storage) == 1 then
            doChallengeCreature(cid, target)
        end
 
@Leesne
C++:
<instant name="Strike" words="strike" lvl="16" manapercent="35" prem="1" blockwalls="1" needweapon="1" exhaustion="1000" needlearn="0" event="script" value="attack/strike.lua">
        <vocation id="5"/>
        <vocation id="10"/>
    </instant>
 
Back
Top