Other question: Ids_name To "Friendly Name"
-
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
-
Yes I know that, share or not, that’s up to you.
Seem like some issue, please look this picture:
You can find it have a “=” in those Chines word, how to fix it ?
Hehe, you need to clear one thing first, i don’t says “Im not share” ;D
Actually, i must share this moded module because other people helps me. but i need to clean code first to take the code out from my project that need take time but im working on other thing. so i need time ;D
And, i shared my idea here, take a look my post on page 1, i just make the idea come true and get success ;D
-
Seem like some issue, please look this picture:
You can find it have a “=” in those Chines word, how to fix it ?
Does this happen with every IDS read or just with a specific one? And are characters the right ones other than the ‘=’? I’m not really sure what could be causing this.
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…
Both of the method declarations are in the FLCoreServer.h file in the FLCoreSDK. pub::System::GetName is on line 654 and pub::Player::GetRank is on line 525.
-
It’s happen with that, when the faction name or IDS name bigger then 3 Chinese characters (1 Chinese characters = 2 English characters), and every time the characters is not same like “=”, some time is “I”, some time is “>”, some time is other characters.
Chinese characters is use two bytes characters make up, its first characters bigger then ASCII 127, but the seconds characters is no limit, so how to get it ?
Oh, and one thing I forget to tell you, some time the player get killed by NPC, but it will show the player be killed by another player, even the player not in same systme, why ?
Clear one thing first ? Is what ?
-
In chinese, have one way to make people to tell you he’s secret, called “taunts”.
JONG you want to use the “taunts” to me? ok here it is:
When i see the CResString code in FlakComm plugin, im go pass out……because… i dont understand the code, almost all… so i planing to make a new one to help me to load resstring. but one problem is: im so n00b…i dont know how to load Freelancer.ini (un standed ini file)… so i do this:
Add
string CResString::GetCurrentFileName() { return this->scAppPath; //lol, CResString get the path for me, i knon i can do this with others like list <inisectionvalue>lstValues, but i don't know how..... }</inisectionvalue>
Add
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Get DLL Filename by IDS Number string GetResDLLFileName(uint iIDS) //Only works for names { char szCurDir[MAX_PATH]; GetCurrentDirectory(sizeof(szCurDir), szCurDir); if(!iIDS) return ""; if (iIDS < 65536) { return string(szCurDir) + "\\resources.dll"; } else { uint iDLL = iIDS / 0x10000; iIDS -= iDLL * 0x10000; /*if(vDLLs[iDLL-1].GetStringBlock((iIDS / 16) + 1, 0) != 1000) return ""; return vDLLs[iDLL-1].GetString(iIDS - ((iIDS / 16) * 16)); */ return vDLLs[iDLL-1].GetCurrentFileName(); } } //Get really String ID in DLL File for load ResString. uint GetResIDByIDS(uint iIDS) //Only works for names { uint iResStringID; if (iIDS < 65536){ return iIDS; } else { //This is why i says i need long time to test iResStringID = iIDS / 65536; iResStringID = iIDS - 65536 * uint(iResStringID); //turn to integer, needn't float. return iResStringID; } } //Send Get res to blablabla wstring GetIDSName(uint iIDS) { return LoadResFromDLL(GetResDLLFileName(iIDS), GetResIDByIDS(iIDS)); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Add
//Very simply API to load String wstring LoadResFromDLL(string sFileName, int iStringID) { HINSTANCE hDllString; char DllString[600]; hDllString = LoadLibraryEx(sFileName.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE); // LoadString(hDllString, iStringID, DllString, 600); // FreeLibrary(hDllString); // return stows(ctos(DllString)); }
i known, i “solved” this problem by a “fool’s way”……but it worked…
and M0tah, please help me to load Rank and SystemName, im trying long time and can’t make it work… Thanks…
-
Hehe, finally, I got the secret in your hand. ;D
But I don’t know why the M0tah of code fix can’t fix Chinese word issue ?
Before you both give me a hand, I was google it and try to learn how to and try to fix it, even I’m a C++ idiot (not only a noob), but I never finish it.
I think if you can tell M0tah why the fix can’t fix our issue, maybe next time M0tah make his code can reference it, right ?
And I’m very inquisitive why you want to load the Rank and SystemName ? another secret ? ;D
Oh, and almost forget to Thanks your share ! ;D
May you can check the Nieckey’s code ?
Ps.Nieckey: no offence, just make sure that’s not cause another issue. ;D