• 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 1.X] Secure mode with aoe spells

gritness

Member
Joined
May 26, 2021
Messages
33
Reaction score
6
Hey guys,

Anyone have solution for aoe spells on tfs 1.3 ?
I can't attack another players from weapons when secure mode is on, but when somebody use aoe spells (in secure mode) ... PK turns automatically.

it's possible to set up secure mode with aoe spells ?

Little part of code (creature.lua) :

Lua:
function CreaturenTargetCombat(player,target)
 
if player:hasSecureMode()== true then
        if self:isPlayer() and target:isPlayer() then
            return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
        end
    end
    return true
end


Without 'if syntax' player cant attack another player (with spells too), but still not working with my 'if'

-Attemp to call a nil value (method 'hasSecureMode')

In another funcion this 'if' working perfectly :

Lua:
function onSay(player, words)
if player:hasSecureMode()==true then
player:sendTextMessage(MESSAGE_INFO_DESCR,"Secure mode on")


elseif player:hasSecureMode()==false then

player:sendTextMessage(MESSAGE_INFO_DESCR,"Secure mode off")


end
end

Any idea's how to assign' if player:hasSecureMode()== true then' to function Creature ?
 
Last edited by a moderator:
GUYS! I found a solution :)

add in /events/scripts/creature.lua :

--SECURE MODE AOE PROTECTION

function Creature:eek:nTargetCombat(target)
if self:isPlayer() and target:isPlayer() then
if self:hasSecureMode()== true then

return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
end
end
return true
end


and in /src/luascript.cpp :

int LuaScriptInterface::luaCreatureHasSecureMode(lua_State* L)
{
// creature:hasSecureMode()
Creature* creature = getUserdata<Creature>(L, 1);
if (creature) {
pushBoolean(L, creature->secureMode);
} else {
lua_pushnil(L);
}
return 1;
}
 
Back
Top