So I've made a function in source that challenges players, and it works. But I'm really bad at scripting spells, and I don't want to make a talk action if I can do it with a spell. This is my attempt:
Basicaly, I just want the challenge spell to work as usual on monsters, but use my new doChallengePlayer when it is used on a player. With this code, nothing happens to monsters nor players.
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)
function onCastSpell(cid, var)
if(isPlayer(variantToNumber(var))) then
doChallengePlayer(cid, variantToNumber(var))
elseif(isMonster(variantToNumber(var)) then
doChallengeCreature(cid, variantToNumber(var))
end
return doCombat(cid, combat, var)
end