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

Pls help me with this code (House Training Dummy) its half-fixed.

sevengym

Member
Joined
Aug 27, 2014
Messages
100
Reaction score
9
Location
Poland
Inspired by this code link to post (btw i use tfs 1.5 by nekiro)
I reworked the script to work like this:
1.Players can summon dummy only in houses.
2.Monster is attacking players in pz
Before my change I couldnt spawn dummy in either PZ or house.
I changed
LUA:
local creature = Game.createMonster(config.monsterName, player:getPosition())
to
Code:
local creature = Game.createMonster(config.monsterName, player:getPosition())
After that I could spawn this dummy in house. But then I had problems with attacking this dummy so i solved this problem in combat.cpp by adding requirement like this:
Code:
        //pz-zone
        if (attacker->getZone() == ZONE_PROTECTION) {
       // Check for a specific property or name
        if (target->getName() == "Training Dummy") { // Replace with the actual name
            return RETURNVALUE_NOERROR; // Allow attack
        }
  
            return RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE;
}
But its not over... I still can't use spells and in spells.cpp I can't do the same because
Code:
bool Spell::playerSpellCheck(Player* player) const
have no target definition so i cant use target->getName() to find Training Dummy in this code
Code:
if ((aggressive || pzLock) && !player->hasFlag(PlayerFlag_IgnoreProtectionZone) && player->getZone() == ZONE_PROTECTION) {
        player->sendCancelMessage(RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE);
        return false;
    }
and I don't want to set aggressive="0" for all spells. I want to enable spells only for Training Dummy. Not so they are usable in all pz places.

Anyone have idea how to fix it so I can not only attack but also use spells on Training Dummy that is located in house(pz)
Post automatically merged:

SOLVED.
LUA:
    if ((aggressive || pzLock)
    && !player->hasFlag(PlayerFlag_IgnoreProtectionZone)
    && player->getZone() == ZONE_PROTECTION) {
   
    Creature* target = player->getAttackedCreature();
    if (target && target->getName() == "Training Dummy") {
        // Allow spells on the Training Dummy without restrictions in the protection zone
        // Do not return here; allow further spell checks and cooldowns to proceed
    } else {
        player->sendCancelMessage(RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE);
        return false;
    }
}
 
Last edited:
Back
Top