AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   playerinfo->IsPlayer() crash server on ClientActive (https://forums.alliedmods.net/showthread.php?t=134880)

sn4k3 08-09-2010 16:21

playerinfo->IsPlayer() crash server on ClientActive
 
Plugin is crashing server on ClientActive Callback
when try check for playerinfo->IsPlayer(); i also tried playerinfo->GetName(); and crash too, playerinfo should be invalid but the variable its not null

Console Logs:

Code:

Client "sn4k3" connected (192.168.1.70:27005).
"sn4k3<2><STEAM_0:1:7174016><>" STEAM USERID validated
Compressing fragments (5591 -> 5130 bytes)
PASS 3
What bad 1
What bad 2
What bad 3
Test 1
Test 2
Test 3

My Code:

Code:

IPlayerInfo *LIB_ENTITY_CLASS::GetPlayerinfoFromEntity(edict_t *pEntity)
{
        if (!IsEntitySafe(pEntity)) return NULL;

        Msg("Test 1\n");
    IPlayerInfo *playerinfo = VAR_IFACE_PLAYERINFOMANAGER->GetPlayerInfo(pEntity);
        Msg("Test 2\n");
        if(!playerinfo)
                return NULL;
        Msg("Test 3\n");
        if(!playerinfo->IsPlayer())
        {
                Msg("Test 3.1\n");
                return NULL;
        }
        Msg("Test 4\n");
        if(!playerinfo->IsConnected())
                return NULL;
        Msg("Test 5\n");
        return playerinfo;
}

how could i solve?
thanks

Keeper 08-09-2010 18:13

Re: playerinfo->IsPlayer() crash server on ClientActive
 
What SDK are you using? I believe the IPlayerInfo class has changed. If you are using the stock SDK from VALVe, that might explain it.

sn4k3 08-09-2010 18:38

Re: playerinfo->IsPlayer() crash server on ClientActive
 
Quote:

Originally Posted by Keeper (Post 1266746)
What SDK are you using? I believe the IPlayerInfo class has changed. If you are using the stock SDK from VALVe, that might explain it.

im using hl2sdk-ob-valve: http://hg.alliedmods.net/hl2sdks/hl2sdk-ob-valve/

it work in all others cases, like UserMessages get name, get steamid, etc (Out of ClientActive)

its strange

BAILOPAN 08-10-2010 03:28

Re: playerinfo->IsPlayer() crash server on ClientActive
 
If you read the SDK, you'll see that PlayerInfo is instantiated with the entity, and player entities are not created until PutInServer.

sn4k3 08-10-2010 09:58

Re: playerinfo->IsPlayer() crash server on ClientActive
 
Quote:

Originally Posted by BAILOPAN (Post 1267058)
If you read the SDK, you'll see that PlayerInfo is instantiated with the entity, and player entities are not created until PutInServer.

oh ok, i always think it should work on ClientActive because they say: Purpose: called when a client spawns into a server (i.e as they begin to play)

thanks

sn4k3 08-10-2010 12:45

Re: playerinfo->IsPlayer() crash server on ClientActive
 
Problem solved, my fault


i was inputing index (int from my class, after set to 0), when argument its playerindex

so i used argument playerindex to all lines less on the GetPlayerInfo, so all checks say playerindex is valid, but when i use index to getplayerinfo it crash because its 0

so ClientActive is fine and work well with IPlayerInfo

BAILOPAN 08-13-2010 00:48

Re: playerinfo->IsPlayer() crash server on ClientActive
 
Yes, ClientActive occurs after PutInServer.


All times are GMT -4. The time now is 03:59.

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