Hi, I somehow managed to do the onSelectTarget function in creaturescripts and its working great, so it will execute when player selects any target. But I am still stuck on the other part which is the OnDeselectTarget. To my game.cpp I have added the code in purple
const auto& events = player->getCreatureEvents(CREATURE_EVENT_DESELECT_TARGET);
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeOnDeselectTarget(this);
}
and I am getting the following error when trying to compile:
if I change this to player like that:
it will compile but the code does not execute at all, everything has been registered in creaturescripts
used TFS 1.0 and any help appreciated
//edit FIXED
Ok apparently that was the wrong function
the right one is here in game.cpp:
Game:layerSetAttackedCreature
const auto& events = player->getCreatureEvents(CREATURE_EVENT_DESELECT_TARGET);
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeOnDeselectTarget(this);
}
C++:
void Game::playerCancelAttackAndFollow(uint32_t playerId)
{
Player* player = getPlayerByID(playerId);
if (!player) {
return;
}
playerSetAttackedCreature(playerId, 0);
playerFollowCreature(playerId, 0);
player->stopWalk();
const auto& events = player->getCreatureEvents(CREATURE_EVENT_DESELECT_TARGET);
for (CreatureEvent* creatureEvent : events) {
creatureEvent->executeOnDeselectTarget(this);
}
}
and I am getting the following error when trying to compile:
Error 1 error C2664: 'bool CreatureEvent::executeOnDeselectTarget(Player *)' : cannot convert argument 1 from 'Game *const ' to 'Player *' D:\forgottenserver-1.0\src\game.cpp 3174 1 theforgottenserver
if I change this to player like that:
C++:
creatureEvent->executeOnDeselectTarget(player);
it will compile but the code does not execute at all, everything has been registered in creaturescripts
used TFS 1.0 and any help appreciated
//edit FIXED
Ok apparently that was the wrong function
the right one is here in game.cpp:
Game:layerSetAttackedCreature
Last edited: