Other question: Ids_name To "Friendly Name"
-
Hi again agin
im almost done my plugin if without a critical problem……that is i dont know how to get player info like player rank and player mission count.
i found a topic talkd about how to get player rank, but it need to mod flhook and i want done all in my plugin……
Information i need to get: Player Name, Player Rank, Player Cash, Player Online Time Count, Last Base, Last System, Ship. bold text mean i dont know how to get it with FLHook or/and get the friendly name of it.
give some help please. -
Try these…
HkGetPlayerInfo (and HkGetPlayers)
- system, ship
HkGetCash - the cash!!
You’ll need to be careful when sending http posts using libcurl. You may find that you’ll need to do these in another thread - as the web server may take a while to process the post and flserver will block while this happens. If the web server is hosted on the same machine as flserver then it probably doesn’t matter.
EDIT: reading your post again - i’m not sure how to turn the ship-id into the ids_name. One way would be to parse the ini files and build a map of ship-id to ids_names. I’m sure there’s a better way.
- system, ship
-
and M0tah, do you mind me add your code to my flhook? i will credit you ;D
Of course. I do say in the readme that
You may use it for
whatever purpose you wish. If you use it in one of your projects, I would
appreciate being mentioned somewhere.
Though if you’re just making a plugin it would make more sense to just use the flak_common plugin in its compiled form. All you have to do is include the FlakCommonExports.h file and put FlakCommon.lib in your linker dependency.Information i need to get: Player Name, Player Rank, Player Cash, Player Online Time Count, Last Base, Last System, Ship.
To get the friendly name of the ship you’ll need to get the updated Archetype::Ship struct that includes iIDSName. Then you can get the ids_name of the ship like this:
uint iShipID; pub::Player::GetShipID(iClientID, iShipID); Archetype::Ship *ship = Archetype::GetShip(iShipID); if(ship->iIDSName) { wstring wscShip = stows(HkGetStringFromIDS(ship->iIDSName)); //do stuff with name here } ```To get the last system you'll have to keep track of it yourself, as I don't think FLServer does. Then you can get the IDS from **pub::System::GetName(uint iSystemID, uint iNameIDS)**. Also, a note on the HkGetStringFromIDS function. As you can see, it returns a string. However, you'd expect it to return a wstring instead because the data in stringtables is stored in unicode. This is because the CResString class that reads data from stringtables in DLLs (which I made modifications to and which HKGetStringFromIDS uses) internally converts the wide chars to regular chars. This means that any special characters in the strings will be lost. This will be fixed in the next version of flak_common. Thanks to JONG for reporting this bug.
-
and M0tah, do you mind me add your code to my flhook? i will credit you ;D
Of course. I do say in the readme that
You may use it for
whatever purpose you wish. If you use it in one of your projects, I would
appreciate being mentioned somewhere.
Though if you’re just making a plugin it would make more sense to just use the flak_common plugin in its compiled form. All you have to do is include the FlakCommonExports.h file and put FlakCommon.lib in your linker dependency.Information i need to get: Player Name, Player Rank, Player Cash, Player Online Time Count, Last Base, Last System, Ship.
To get the friendly name of the ship you’ll need to get the updated Archetype::Ship struct that includes iIDSName. Then you can get the ids_name of the ship like this:
uint iShipID; pub::Player::GetShipID(iClientID, iShipID); Archetype::Ship *ship = Archetype::GetShip(iShipID); if(ship->iIDSName) { wstring wscShip = stows(HkGetStringFromIDS(ship->iIDSName)); //do stuff with name here } ```To get the last system you'll have to keep track of it yourself, as I don't think FLServer does. Then you can get the IDS from **pub::System::GetName(uint iSystemID, uint iNameIDS)**. Also, a note on the HkGetStringFromIDS function. As you can see, it returns a string. However, you'd expect it to return a wstring instead because the data in stringtables is stored in unicode. This is because the CResString class that reads data from stringtables in DLLs (which I made modifications to and which HKGetStringFromIDS uses) internally converts the wide chars to regular chars. This means that any special characters in the strings will be lost. This will be fixed in the next version of flak_common. Thanks to JONG for reporting this bug.
I see that problem about losting string, and other new problem is, then i include FlakCommon plugin in my DLL (or just install it as a plugin) , FLServer will crash at start……
-
@Nieckey: Could you give me the value of the “Mod Name” field in the dialog that tells you that FLServer has crashed? Also, are you using any freelancer.ini hacks that make it so Datastorm, etc don’t work? Finally, what version of the plugin version are you using?
@JONG: The flak_common plugin contains functions that I wrote in 88 Flak’s FLHook. I made the plugin to facilitate making plugins out of the features in that FLHook, but it does not contain any new features on its own. If I didn’t have that plugin I’d have to include some of those functions in each plugin I made. Having them in a separate plugin means I only have to do that once. I hope that answers your question.
-
Hi M0tah, Where i can find the “Mod Name” field? i only get this when i start flserver…
and, i have some encoded Freelancer ini file, but im not remeber i hacked the Freelancer.ini
so that is a strange problem….
PS, im try to copy your code to my plugin for geting string form dll by ids number, but compiler output some warning like C4267 C4018 C4311 C4312 in resstring.cpp, how to reslove it?
-
a simply idea for load DLL string:
i checked the ids number with FL-IDS, and i found this:
First DLL’s IDS Number limlited: 0 - 65535;
Second: 65536(= 65535 + 1) - 131071(= 65536 + 65535);
Third: 131072(131071 + 1) - 196607(= 131072 + 65535);so, if a IDS_Name is 196932, it must in Third DLL (196932 / 65536 = 3.00494384765625 ignore all float), and String_ID is 196932 - (65536*3) = 324 ;D
-
You mean that you was fix the CResString ?
Do you mind to share your fix code ?
yep, i think it is, but i have not testing full yet. and please waiting im done my plug in OK?
PS. Im feeling strange to talking you with english, PM me on our web site all right? ;D
-
Hi M0tah, Where i can find the “Mod Name” field? i only get this when i start flserver…
I’m not sure what it is on Vista or in Chinese?, but here it is on Windows XP.
and, i have some encoded Freelancer ini file, but im not remeber i hacked the Freelancer.ini
This may be making the flak_common plugin not able to read the DLLs from the [Resources] section in Freelancer.ini. I’ll change the plugin to use FL’s own INI_Reader in the next version, which will hopefully fix this problem.
PS, im try to copy your code to my plugin for geting string form dll by ids number, but compiler output some warning like C4267 C4018 C4311 C4312 in resstring.cpp, how to reslove it?
The compiler warnings shouldn’t be a problem - as long as you don’t get any errors it should work. Looks like you did get something working though.
So if I need your new FLHook 1.61 functions, I can’t use this FLHook plugin version, right ?
Right.
-
I’ve made the necessary changes to CResString for it to return wstrings.
In ResString.cpp add (after the int CResString::GetString( UINT nIndex, LPSTR pszText ) and string CResString::GetString( UINT nIndex ) methods respectively):```
int CResString::GetWString( UINT nIndex, LPWSTR pswzText )
{
if( NULL == pStrBlock )
{
return INVALID_BLOCK;
}
if( (nIndex < 0) || (nIndex >= NO_OF_STRINGS_PER_BLOCK) )
{
return INVALID_BLOCK_INDEX;
}
if( NULL == pswzText )
{
return INVALID_STRING;
}
wcscpy(pswzText, pStrBlock->strArray[nIndex]);return SUCCESS_MADE;
}
wstring CResString::GetWString( UINT nIndex )
{
wstring wscText;
LPWSTR pwText;
int nLen = GetStringLength( nIndex ); // Determin length of stringpwText = (LPWSTR)malloc(sizeof(LPWSTR) * nLen); // Allocate memory for string if( this->GetWString( nIndex, pwText ) ) // Retrieve string { wscText = pwText; free( pwText ); // Free memory from retrieving text return wscText; }else return L""; // Return string;
}
In ResString.h add (same as above):
// Retrieves the wstring at nIndex
int GetWString( UINT nIndex, LPWSTR pswzText );wstring GetWString( UINT nIndex );
In HkFuncTools.cpp add:
wstring HkGetWStringFromIDS(uint iIDS) //Only works for names
{
if(!iIDS)
return L"";uint iDLL = iIDS / 0x10000; iIDS -= iDLL * 0x10000; if(vDLLs[iDLL-1].GetStringBlock((iIDS / 16) + 1, 0) != 1000) return L""; return vDLLs[iDLL-1].GetWString(iIDS - ((iIDS / 16) * 16));
}
-
Yeah, the fix worked, but Euyis helps me to this by other way, ;D
and M0tah, im still trying to load system name and player rank, thanks for reply me on 88flak forum, but i can’t load that two thing successfuly, im not found GetRank or GetName in my SDK or FLHook also in FlakCommon plugin(without a “Class call” named “pub::Reputation::GetName(iPlayerRep, fsOut1, fsOut2);”, but it be /**/ed….)…, so that so strange…
-
Thanks M0tah, now I can fix it myself.
Why you don’t share your “other way” before the M0tah fix ?
This issue let me disable some function in flhook.
You know that, I will kill you ASAP. ;D
Sorry but im busy to do building a classified project so i have not any free time for clean up my code. ;D