• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

secureMode, getPlayerSpell (?) problem.... CyberM take a look please!

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Hello
I made working piece of code secureMode (popular hand in Tibia)
PHP:
function onCombat(cid, target)
    if isPlayer(cid) and secureMode == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot attack player when secure mode is off.")
        return false
        elseif isPlayer(cid) and secureMode == 1 then
                return true
    end  
    return true
end

But i dont know how to add function with ignoring spell, if i dont have selected hand.
Anyone can help me ?

If i try:
onCastSpell(cid) the script totally ruins, i totally cannot attack player (like non-pvp server)
 
nope... I wanna protect from spells (if player cast area spell, and have securemode = 0 [hand off], the spell ignore players in zone of spell)
 
do you want this??
PHP:
int32_t LuaScriptInterface::luaGetPlayerFight(lua_State* L)
{
	//getPlayerFight(cid)
	ScriptEnviroment* env = getEnv();

	Player* player = env->getPlayerByUID(popNumber(L));
	if(player)
	{
		lua_newtable(L);
		setField(L, "chase", player->getChaseMode());
		setField(L, "fight", player->getFightMode());
		setField(L, "secure", player->getSecureMode());
		return 1;
	}

	errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
	lua_pushboolean(L, false);
	return 1;

}

if getPlayerFightMode(cid).secure == 0 then
...
 
Last edited:
Ok but this is dont working with spells.

LUA:
function onStatsChange(cid, target)
        if isPlayer(cid) and getPlayerFightMode(cid).secure == 0 then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot attack player when secure mode is off.")
		return FALSE
		end
        if isPlayer(cid) and getPlayerFightMode(cid).secure == 1 then
        	return TRUE
        	end
	return TRUE
	end

Symbol: "--->" in my post is "could be like this:"


After that script, I cant attack player with meele while i have securemode on. ---> Only can meele/spells attack while i have securemode = 1
And if i attack with spell without securemode the skull appear and 0 damage, ---> I want if i dont have securemode on (securemode = 0) than my spells ignoring players in spell area and skull dont appear

after that if i target player the hits dont pop up, same as spells,
damage not showing..
. ---> This is bug while im going to try something with the spells .... ;/
 
Last edited:
OK but on - doCombat what event type i must put in .xml ? event="combat" or "doCombat" ?
You can get all that information in the /DOC/SCRIPTSYSTEM_HELP file of your TFS
Code:
    *CREATURESCRIPTS
        File: creaturescripts/creaturescripts.xml
        Attributes
            type
                Event type
                Values:
                    login, logout
                    advance, statschange,
                    direction, outfit
                    sendmail, receivemail
                    traderequest, tradeaccept
                    joinchannel, leavechannel
                    look, think, textedit, reportbug
                    push, target, follow
                    attack, [COLOR=red][B]combat[/B][/COLOR], areacombat, cast
                    kill, death, preparedeath
 
Ok but i dont want it when "spell needs target" i want to ignore players with area spell (if caster dont have securemode on [hand])
 
LUA:
function onCombat(cid, target)
    if isPlayer(target) and getPlayerFightMode(cid).secure == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You cannot attack player when secure mode is off.")
        return false
        elseif isPlayer(target) and getPlayerFightMode(cid).secure == 1 then
        return true
    end  
    return true
end

BUG: I cannot attack players, no matter what i set (securemode 1 or 0) , i cannot attack players :/
Help me.
 
I dont get it, when secure mode is OFF you want to disable attacking player?
strange...
are you sure that getPlayerFightMode(cid).secure is numeric, not boolean?
also irt could be shorter
if blah then return false end return true
 
Secure mode is an Tibia hand (where you got fight types - full, balanced, full defense, in right column you have securehand).
If you have secure mode on
87420448.png
- you can target all players and hitting hims with spells (area spells, waves).
If you have secure mode off
offyh.png
- you cannot target players without skulls and your area/wave spells ignoring players without skull (and ofcourse if any player in area of spell then dont make you skull/pz)

You get it ?
Help please :(


@Edit.
Images included.
 
Back
Top