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

No matching function addEvent

Snix

New Member
Joined
Jan 8, 2014
Messages
18
Reaction score
1
g_scheduler.addEvent(createSchedulerTask(4000, std::bind(&Game::internalAddItem, &g_game, tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT)));




ERROR:

no matching function for call to ‘bind(<unresolved overloaded function type>, Game*, Tile*&, Item*&, const int32_t&, cylinderflags_t)’

g_scheduler.addEvent(createSchedulerTask(4000, std::bind(&Game::internalAddItem, &g_game, tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT)));
 
add an item to the map after 10 seconds
Post automatically merged:

g_game.internalAddItem(tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT); add delay 10 seg
Post automatically merged:

addEvent
 
tfs 1.2
Post automatically merged:

function:

void Creature::addCorpse(Cylinder* tile, Item* corpse){
g_game.internalAddItem(tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT);
}

Event:

g_scheduler.addEvent(createSchedulerTask(10000, std::bind(addCorpse, tile, corpse)));


it worked :)
 
Hello there,

boost cannot deal with overloaded functions, in this case you should use static_cast because of ambiguity.

If you're using c++ 11 you could make use of Lambda Expressions, that would spare you of using bind.

Here's an article for you: Lambda expressions (since C++11) - cppreference.com (https://en.cppreference.com/w/cpp/language/lambda)

I still think the best approach to add an item to the map after 10 seconds is to use Lua.

Upon Startup:

addEvent(Game.createItem, 10000, itemid, 1, toPosition)

Best Wishes,
Okke
 
Last edited:
Back
Top