AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Metamod:Source Questions (https://forums.alliedmods.net/forumdisplay.php?f=74)
-   -   IClient (https://forums.alliedmods.net/showthread.php?t=318970)

Contf 10-03-2019 07:58

IClient
 
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());
}


Fyren 10-03-2019 08:37

Re: IClient
 
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.

Contf 10-03-2019 10:06

Re: IClient
 
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());

Contf 10-03-2019 14:01

Re: IClient
 
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....

Fyren 10-03-2019 22:13

Re: IClient
 
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.

TheDS1337 10-04-2019 01:34

Re: IClient
 
Quote:

Originally Posted by Fyren (Post 2668728)
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.


All times are GMT -4. The time now is 02:40.

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