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

IClient


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Contf
Junior Member
Join Date: Jun 2013
Old 10-03-2019 , 07:58   IClient
Reply With Quote #1

Hi,

So, i was trying to kick a client after connecting if they were not able to join the server, but the server keeps crashing when i am trying to cast the msg to the IClient interface.
I already read the sourcemod source code, and i am pretty sure that's how it is doing the job, but i am missing something that i cant figure it out.
I import the class CPlayer from the source code, and i am calling the method Initialize on the event OnClientConnected , thats where is crashing the server.

Code:
INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(playerid));
IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo(pEdict);

if (pNetChan != NULL && playerinfo->IsConnected())
{
    IClient *pClient  = static_cast<IClient *>(pNetChan->GetMsgHandler());
}

Last edited by Contf; 10-03-2019 at 08:04.
Contf is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-03-2019 , 08:37   Re: IClient
Reply With Quote #2

static_casting pointers is a noop. It's not the cause of your crash.

Off the top of my head, check to make sure all your pointers are valid. The code only checks pNetchan. The INetChan or IPlayerInfo layouts could be different between the headers and the server, but this is probably not the problem if SM works and you're using the same ones.
Fyren is offline
Contf
Junior Member
Join Date: Jun 2013
Old 10-03-2019 , 10:06   Re: IClient
Reply With Quote #3

Hi, thanks for the reply.

I based my code from here:

https://github.com/alliedmodders/sou...ager.cpp#L1982

That method is called from PlayerManager::OnClientConnect, thats what i did
The server crash's exacly on this line, i make sure of that putting some debug print's

IClient *pClient = static_cast<IClient *>(pNetChan->GetMsgHandler());

Last edited by Contf; 10-03-2019 at 10:08.
Contf is offline
Contf
Junior Member
Join Date: Jun 2013
Old 10-03-2019 , 14:01   Re: IClient
Reply With Quote #4

Hummm, the problem is resolved.
I am not sure what was the problem, i just re-downloaded the sdk for cs go and it started working.
Thanks anyway....
Contf is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-03-2019 , 22:13   Re: IClient
Reply With Quote #5

If the layout of INetChan changes (which can happen when the game patches) and you're using an older revision of the SDK, then calling its functions can break depending on what the change was. The SDK has to be updated to match it.

Last edited by Fyren; 10-03-2019 at 22:13. Reason: rephrase
Fyren is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 10-04-2019 , 01:34   Re: IClient
Reply With Quote #6

Quote:
Originally Posted by Fyren View Post
If the layout of INetChan changes (which can happen when the game patches) and you're using an older revision of the SDK, then calling its functions can break depending on what the change was. The SDK has to be updated to match it.
Yes, I just noticed he's using the engine interface here, which had additional functions added for CS:GO last month. so that could be his problem.

Last edited by TheDS1337; 10-04-2019 at 01:34.
TheDS1337 is offline
Reply


Thread Tools
Display Modes

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 11:04.


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