Raised This Month: $ Target: $400
 0% 

CPlayerState


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
showdax
Senior Member
Join Date: Dec 2004
Old 05-22-2006 , 18:59   CPlayerState
Reply With Quote #1

Has anyone used this before? I just now noticed it and it seems kind of useful:

Code:
        H_COMMAND(util_playerstate, "")
        {
                if (g_Engine->Cmd_Argc() < 2)
                {
                        META_CONPRINT("Usage: <entity index>\n");
                        return;
                }

                int index = Q_atoi(g_Engine->Cmd_Argv(1));
                if (index < 0 ||index >= g_Engine->GetEntityCount())
                {
                        META_CONPRINT("Specified index is higher than entity count! (Or below zero!)\n");
                }

                edict_t* entity = g_Engine->PEntityOfEntIndex(index);
                if (!entity)
                {
                        META_CONPRINT("Got NULL edict_t*!\n");
                        return;
                }

                CPlayerState* state = g_ServerGameClients->GetPlayerState(entity);
                if (!state)
                {
                        META_CONPRINT("Got NULL CPlayerState*!\n");
                        return;
                }

                META_CONPRINTF("deadflag:\t%d\n"
                        "v_angle:\t%f %f %f\n"
                        "netname:\t%s\n"
                        "fixangle:\t%d\n"
                        "anglechange:\t%f %f %f\n"
                        "hltv:\t%d\n"
                        "frags:\t%d\n"
                        "deaths:\t%d\n", state->deadflag ? 1 : 0, state->v_angle.x, state->v_angle.y,
                        state->v_angle.z, state->netname.ToCStr(), state->fixangle,
                        state->anglechange.x, state->anglechange.y, state->anglechange.z,
                        state->hltv ? 1 : 0, state->frags, state->deaths);
        }
Gives me:

Code:
util_playerstate 1
deadflag:       0
v_angle:        0.000000 90.000000 0.000000
netname:
fixangle:       0
anglechange:    0.000000 0.000000 0.000000
hltv:   0
frags:  -1
deaths: 1
I'm not sure if the deadflag is set when the player is starting to die or is done dying though. Everything else seems to work nicely, though netname seems to be unused.

Edit: World seems to have a CPlayerState instance with unitialized gibberish. Be careful with that.

Edit #2: Editing the data has no effect on anything. I guess this is purely for fast information access.
showdax is offline
Send a message via MSN to showdax
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 05-29-2006 , 11:49  
Reply With Quote #2

Its used in the noclip command, they use v_angle instead of any of the CBaseEntity angles o.O
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
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 03:29.


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