Freelancer Community Network
Reminder: Internet Explorer 6 or below are NOT supported.
HomeHome
ForumForum
WikiWiki
DownloadsDownloads
ForgeForge
Multiplayer Connection Tutorial
Collapse/Expand Random Image
Collapse/Expand Login
Username:

Password:

Remember me



Lost Password?

Register now!
Collapse/Expand Chat
Collapse/Expand Who's Online
43 user(s) are online (26 user(s) are browsing Forum)

Members: 0
Guests: 43

more...
Collapse/Expand Donations
Monthly costs: -30€
Income (ads): +5€
Donations (last month): +10€

Current balance: -50€
(last updated 06/2019)

Please make a donation if you want to help keeping The-Starport online:

Bitcoin address:
Thanks!
Collapse/Expand Links
Collapse/Expand Advertisement
There are currently 48 users playing Freelancer on 31 servers.
July. 20, 2019

Browsing this Thread:   1 Anonymous Users



 Bottom   Previous Topic   Next Topic  Register To Post



FLHook 3.0 Autobuy issues
Just popping in
Joined:
2015/9/13 18:49
Group:
Registered Users
$$$ Supporters $$$
Posts: 3
Offline
Hi all,

I am using FLHook 3.0 from the lovely people at Discovery.

I found that the autobuy plugin provided would cause issues for Vanilla Freelancer (e.g. not buy the correct amount, miss items etc.)

I just wanted to post my solution for future modders. I have ported the 1.6.2 core Autobuy functionality into a plugin. I found that the topic here helped a lot with AntiCheat issues: https://the-starport.net/freelancer/fo ... ewtopic.php?topic_id=1686

Please find attached "Main.cpp" for the autobuy plugin.

I also had to modify "HKAddCargo" in HkFuncPlayers.cpp in the main FLHook Project. This method is shown below.

Hope this helps someone in the future.

Raikkonen - Zoner Universe

Code:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
HK_ERROR HkAddCargo(const wstring &wscCharname, uint iGoodID, int iCount, bool bMission)
{
HK_GET_CLIENTID(iClientID, wscCharname);

if (iClientID == -1 || HkIsInCharSelectMenu(iClientID))
return HKE_PLAYER_NOT_LOGGED_IN;

/* // anti-cheat related
char *szClassPtr;
memcpy(&szClassPtr, &Players, 4);
szClassPtr += 0x418 * (iClientID - 1);
EquipDescList *edlList = (EquipDescList*)szClassPtr + 0x328;
bool bCargoFound = true;
if(!edlList->find_matching_cargo(iGoodID, 0, 1))
bCargoFound = false;*/

// add
const GoodInfo *gi;
if (!(gi = GoodList::find_by_id(iGoodID)))
return HKE_INVALID_GOOD;

bool bMultiCount;
memcpy(&bMultiCount, (char*)gi + 0x70, 1);


uint iBase = 0;
pub::Player::GetBase(iClientID, iBase);
uint iLocation = 0;
pub::Player::GetLocation(iClientID, iLocation);

// trick cheat detection
if (iBase) {
if (iLocation)
Server.LocationExit(iLocation, iClientID);
Server.BaseExit(iBase, iClientID);
if (!HkIsValidClientID(iClientID)) // got cheat kicked
return HKE_PLAYER_NOT_LOGGED_IN;
}

if (bMultiCount) { // it's a good that can have multiple units(commodities, missile ammo, etc)
int iRet;

// we need to do this, else server or client may crash
list<CARGO_INFO> lstCargo;
HkEnumCargo(wscCharname, lstCargo, iRet);
foreach(lstCargo, CARGO_INFO, it)
{
if (((*it).iArchID == iGoodID) && ((*it).bMission != bMission))
{
HkRemoveCargo(wscCharname, (*it).iID, (*it).iCount);
iCount += (*it).iCount;
}
}

pub::Player::AddCargo(iClientID, iGoodID, iCount, 1, bMission);
}
else {
for (int i = 0; (i < iCount); i++)
pub::Player::AddCargo(iClientID, iGoodID, 1, 1, bMission);
}

if (iBase)
{ // player docked on base
///////////////////////////////////////////////////
// fix, else we get anti-cheat msg when undocking
// this DOES NOT disable anti-cheat-detection, we're
// just making some adjustments so that we dont get kicked
if (iBase) {
Server.BaseEnter(iBase, iClientID);
if (iLocation) // ADDED THIS CHECK
Server.LocationEnter(iLocation, iClientID);

/* // fix "Ship or Equipment not sold on base" kick
if(!bCargoFound)
{
// get last equipid
char *szLastEquipID = szClassPtr + 0x3C8;
ushort sEquipID;
memcpy(&sEquipID, szLastEquipID, 2);

// add to check-list which is being compared to the users equip-list when saving char
EquipDesc ed;
memset(&ed, 0, sizeof(ed));
ed.id = sEquipID;
ed.count = iCount;
ed.archid = iGoodID;
edlList->add_equipment_item(ed, true);
}

// fix "Ship Related" kick, update crc
ulong lCRC;
__asm
{
mov ecx, [szClassPtr]
call [CRCAntiCheat]
mov [lCRC], eax
}
memcpy(szClassPtr + 0x320, &lCRC, 4);*/
}
}

return HKE_OK;
}

Attach file:


zip Main.zip Size: 4.22 KB; Hits: 10

Posted on: 5/8 22:05
Top