Dock_Call function: DOCK being called when cancelling docking
-
Hello,
I’m attempting to display a message when the player is docked (BaseEnter and LocationEnter aren’t usable as they get triggered when logging as well). At first I wanted to display it when the docking cinematic started but I haven’t been able to find a function for that so I went for Dock_Call.
This is my code:
int __cdecl Dock_Call(unsigned int const &iShip, unsigned int const &iDockTarget, int iCancel, enum DOCK_HOST_RESPONSE response) { returncode = DEFAULT_RETURNCODE; uint iClientID = HkGetClientIDByShip(iShip); uint iTypeID; pub::SpaceObj::GetType(iDockTarget, iTypeID); if (iTypeID==OBJ_DOCKING_RING || iTypeID==OBJ_STATION) { if (!IsDockingAllowed(iShip, iDockTarget, iClientID)) { //AddLog("INFO: Docking suppressed docktarget=%u charname=%s", iDockTarget, wstos(Players.GetActiveCharacterName(iClientID)).c_str()); returncode = SKIPPLUGINS_NOFUNCTIONCALL; return 0; } if (response==PROCEED_DOCK) { // Print out a message when a player ship docks. wstring wscMsg = L"%timeTraffic control alert: %player has requested to dock"; wscMsg = ReplaceStr(wscMsg, L"%time", GetTimeString(set_bLocalTime)); wscMsg = ReplaceStr(wscMsg, L"%player", Players.GetActiveCharacterName(iClientID)); PrintLocalUserCmdText(iClientID, wscMsg, set_iLocalChatRange); } else if (response==DOCK) { // Print out a message when a player ship docks. wstring wscMsg = L"%timeTraffic control alert: %player IS SUPPOSED TO BE DOCKED"; wscMsg = ReplaceStr(wscMsg, L"%time", GetTimeString(set_bLocalTime)); wscMsg = ReplaceStr(wscMsg, L"%player", Players.GetActiveCharacterName(iClientID)); PrintLocalUserCmdText(iClientID, wscMsg, set_iLocalChatRange); } } SystemSensor::Dock_Call(iShip, iDockTarget, iCancel, response); return 0; } }
It mostly works fine, except (response==DOCK) is also being called when I cancel the docking request instead of only when the docking sequence is completed. I’ve attempted to use iCancel but that didn’t work.
Any idea on how to not make it trigger when cancelling the docking request ?
-
Are you sure that “response” is the variable you’re looking for?
As far as I unserstood, you’re talking about the state after the dock target’s respond, when screen goes wide and dock is opening. If I understand correctly, isn’t there a different part responsible for this? -
-
Wouldn’t you be able to distinguish between logins and docks by tracking the last call to PlayerLaunch and CharacterInfoReq (going by memory, names may be inexact)? If CharacterInfoReq is called on a client, set a flag. If PlayerLaunch is called for that client, clear the flag. If the flag is NOT set and BaseEnter is called, the client should have just docked.
-
BaseEnter fits perfectly well. Sure its also called when the player logs in at a base, but hey then he is docked. Eventually the LastBaseID in the PlayerData struct is 0 when he logged in? Didnt have tested this now, but eventually you can use this to differ if he enters a base after he has undocked and docked again or enters a base after he logged in.
Other than this you just have to use a workaround as FF suggested.