Raised This Month: $51 Target: $400
 12% 

Get player id from CGameClient


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 04-14-2014 , 14:30   Get player id from CGameClient
Reply With Quote #1

I have a pointer to CGameClient, is it possible to determine the player id from this class (without mid-func hook) ?

The only clue I have:

PHP Code:
int __cdecl CGameClient::FileDenied(const char *a1int a2int a3)
{
  
int v3// eax@1

  
v3 = (*(int (__cdecl **)(_DWORD))(*(_DWORD *)a1 24))(a1);
  return 
ConMsg("Downloading file '%s' from client %s failed.\n"a2v3); //v3 - player name


Last edited by kadet.89; 04-14-2014 at 14:33.
kadet.89 is offline
Send a message via Skype™ to kadet.89
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 04-15-2014 , 09:19   Re: Get player id from CGameClient
Reply With Quote #2

CGameClient inherits from IClient. You should be able to call GetPlayerSlot() just fine.
donrevan is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 04-15-2014 , 13:14   Re: Get player id from CGameClient
Reply With Quote #3

Thanks, it works
kadet.89 is offline
Send a message via Skype™ to kadet.89
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 04-19-2014 , 08:09   Re: Get player id from CGameClient
Reply With Quote #4

I have another problem. This only works on windows server.
On linux server client->GetPlayerSlot() returns random numbers.
And I think client->GetClientName() returns wrong pointer. When I try to printf this string, my linux server crashes.

PHP Code:
DETOUR_DECL_MEMBER2(FileSentvoidchar *, fileNameinttransferID)
{
    
IClient client = (IClient*)this;
    
int clientid client->GetPlayerSlot()+1;
    
g_pSM->LogMessage(myself"FileSent %i %s"clientidclient->GetClientName());
    return;


Last edited by kadet.89; 04-19-2014 at 09:08.
kadet.89 is offline
Send a message via Skype™ to kadet.89
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 04-19-2014 , 19:37   Re: Get player id from CGameClient
Reply With Quote #5

Attach gdb and find out why it's crashing.
Most likely GetPlayerSlot and GetClientName are a few indexes off on Linux. Try to pad them correctly by inserting stub virtual functions or call them manually by their index.
Or do the lazy way and call the functions via symbol lookup.

Last edited by donrevan; 04-19-2014 at 19:39.
donrevan is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode