diff --git a/Server/Components/Objects/objects_impl.hpp b/Server/Components/Objects/objects_impl.hpp index 7def53c4c..edb38418f 100644 --- a/Server/Components/Objects/objects_impl.hpp +++ b/Server/Components/Objects/objects_impl.hpp @@ -417,6 +417,8 @@ class ObjectComponent final : public IObjectsComponent, public CoreEventHandler, void onPoolEntryDestroyed(IPlayer& player) override; + void onPoolEntryCreated(IPlayer& player) override; + void onPlayerStreamIn(IPlayer& player, IPlayer& forPlayer) override; // Pre-spawn so you can safely attach onPlayerSpawn diff --git a/Server/Components/Objects/objects_main.cpp b/Server/Components/Objects/objects_main.cpp index 92e0ffa8b..ce2a21ce7 100644 --- a/Server/Components/Objects/objects_main.cpp +++ b/Server/Components/Objects/objects_main.cpp @@ -33,20 +33,21 @@ void ObjectComponent::onTick(Microseconds elapsed, TimePoint now) void ObjectComponent::onPlayerConnect(IPlayer& player) { - auto player_data = new PlayerObjectData(*this, player); - player.addExtension(player_data, true); - // If client is using 0.3.7 or artwork isn't enabled we can create objects right on connect. // If not we need to wait for client to download custom models before creating objects. static bool artwork = (core->getConfig().getBool("artwork.enable")) ? (*core->getConfig().getBool("artwork.enable")) : false; if (artwork && player.getClientVersion() == ClientVersion::ClientVersion_SAMP_03DL) return; - player_data->setStreamedGlobalObjects(true); - for (IObject* o : storage) + auto playerData = reinterpret_cast(queryExtension(player)); + if (playerData) { - Object* obj = static_cast(o); - obj->createForPlayer(player); + playerData->setStreamedGlobalObjects(true); + for (IObject* o : storage) + { + Object* obj = static_cast(o); + obj->createForPlayer(player); + } } } @@ -168,6 +169,12 @@ void ObjectComponent::onPoolEntryDestroyed(IPlayer& player) } } +void ObjectComponent::onPoolEntryCreated(IPlayer& player) +{ + auto playerData = new PlayerObjectData(*this, player); + player.addExtension(playerData, true); +} + COMPONENT_ENTRY_POINT() { return new ObjectComponent(); diff --git a/Server/Components/Pawn/Scripting/Impl.cpp b/Server/Components/Pawn/Scripting/Impl.cpp index ce1e554ff..4ccde9462 100644 --- a/Server/Components/Pawn/Scripting/Impl.cpp +++ b/Server/Components/Pawn/Scripting/Impl.cpp @@ -98,7 +98,7 @@ void Scripting::addEvents() const if (mgr->players) { mgr->players->getPlayerSpawnDispatcher().addEventHandler(PlayerEvents::Get()); - mgr->players->getPlayerConnectDispatcher().addEventHandler(PlayerEvents::Get(), EventPriority_FairlyLow); + mgr->players->getPlayerConnectDispatcher().addEventHandler(PlayerEvents::Get()); mgr->players->getPlayerStreamDispatcher().addEventHandler(PlayerEvents::Get()); mgr->players->getPlayerTextDispatcher().addEventHandler(PlayerEvents::Get()); mgr->players->getPlayerShotDispatcher().addEventHandler(PlayerEvents::Get());