How to get player affiliation?
-
Even if the thread is pretty old:
The easy way to get the faction name would be something like that:
int iPlayerRep; pub::Player::GetRep(iClientID, iPlayerRep); uint iAff; Reputation::Vibe::GetAffiliation(iPlayerRep, iAff, false); TString<16> tsNick; Reputation::get_nickname(tsNick, iAff); uint iGroupName; pub::Reputation::GetGroupName(iAff, iGroupName); HINSTANCE hInstance = GetModuleHandle("NameResources.dll"); if(!hInstance) { return; } char szBuf [1024]; int iLength = LoadString( hInstance, iGroupName, szBuf, sizeof(szBuf) ); ConPrint(L"Length: %i, text: %s\n", iLength, stows(szBuf).c_str());
tsNick will be the nickname (eg “li_n_grp”) and szBuf the full name (eg “Liberty Navy”). [If you don’t need to get the nickname you can ignore the TString part).
This will ofc only work if the name is stored in NameResources.dll (like the original fl faction names). So there’s prolly a better way but as said: That’s the crappy and easy one
-
@HeIIoween, Mainy problem is i been busy on work, and i cannot do 3 things at same time. My plan is first my website, then the mod, then the other related things include the plugin. But it is open source and base on GPL, so if you want to continue or make your new one, just feel free to do it.
@Crazy, MARK. LOL Useful code, Thanks Crazy.
-
In Console, I thought I used a function to get the name directly, but no, it returns the id and I used Freelancer’s function to read the string. It’s at 4347E0:
typedef UINT (*TGetString)( LPVOID, // resource table? UINT, // resource number LPWSTR, // buffer for string UINT // length of buffer (chars, not bytes) ); extern TGetString GetString; #define RSRC *(LPVOID*)0x67eca8 // the resource table // Make use of Freelancer's string buffer. LPWSTR const wstrbuf = (LPWSTR)0x66dc60; PUINT const wstrlen = (PUINT)0x6119f8; UINT strid; pub::Reputation::GetShortGroupName( fac, strid ); GetString( RSRC, strid, wstrbuf, *wstrlen );
-
Of course, you’re running the server, not the client. The function in FLServer.exe is at 4176B0. Same parameters, but RSRC is just 0/NULL. BTW, it returns the length of the string (0 if doesn’t exist; length of buffer minus one if too long). Buffer may be NULL, in which case it just finds the length.
-
Brrrr, problem is to found player affilation of player who destroyed dockable base, i mean…:
[player]
…
house = 0, fc_maquis_grp
house = -0.3, fc_corse_grp
house = -0.3, fc_brigands_grp
…
rep_group = fc_freelancer ; <-- this string
…for example to show in event mode:
basedestroy basename=Li01_08_Base basehash=3197728322 solarhash=2810150415 by=Poupkine with affilation=fc_freelancer
So at server side function to get affilation gives always 0?
-
I mean that from how FL works internally, players never have an affiliation. Of course they can have a rep-group, but they wont have an affiliation as regards the reputation methods and so on (-> get-affiliation always returning 0). Correct me if Im wrong.
-
w0dk4 wrote:
Ah, good to know!yes very… i always thought it was set via the NewCharacter.ini & linked into “co_ic_grp” & its reputations in empathy.ini
so… that’s SP only im reading here? For MP its set differently… especially when hook is involved. im very intrigued…
-
And how to get tsNick to be printed?
TString<16> tsNick; Reputation::get_nickname(tsNick, iAff);