LucasForums

LucasForums (http://www.lucasforums.com/index.php)
-   JA Coding (http://www.lucasforums.com/forumdisplay.php?f=539)
-   -   Getting client info on CG (http://www.lucasforums.com/showthread.php?t=172278)

Dom_152 11-04-2006 12:44 PM

Getting client info on CG
 
I have a boolean in the server side client->pers structure and now I want to use that boolean to determine if the client should draw something extra on the scoreboard. My question is how can I access the state of that boolean from cg_scorboard.c or in any cg_xxx.x file?

Tinny 11-04-2006 11:23 PM

Ooh, I don't know much about client->pers but I know the client->ps (playerState) can be edited from q_shared.h. This is the tricky thing though, editing q_shared.h can really mess everything else up so I would stick with using userints. Even if you do edit userint though, you have to make sure enough bits are being sent across the network to represent it properly, so you'll need to edit the external netf_overrides and psf_overrides too (I can tell you where those are if you don't know).

ensiform 11-05-2006 01:54 AM

An easier way would be to send it in ClientUserinfoChanged.

pers.myqboolean and x being the key being stored to be recognized in client.

Note: Don't just copy and paste this as it appears to have extra spaces in the s = va() area but it really doesn't.

Code:

        // send over a subset of the userinfo keys so other clients can
        // print scoreboards, display models, and play custom sounds
        if ( ent->r.svFlags & SVF_BOT ) {
                s = va("n\\%s\\t\\%i\\model\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\skill\\%s\\tt\\%d\\tl\\%d\\siegeclass\\%s\\st\\%s\\st2\\%s\\dt\\%i\\sdt\\%i\\x\\%d",
                        client->pers.netname, team, model,  c1, c2,
                        client->pers.maxHealth, client->sess.wins, client->sess.losses,
                        Info_ValueForKey( userinfo, "skill" ), teamTask, teamLeader, className, saberName, saber2Name, client->sess.duelTeam, client->sess.siegeDesiredTeam, client->pers.myqboolean);
        } else {
                if (g_gametype.integer == GT_SIEGE)
                { //more crap to send
                        s = va("n\\%s\\t\\%i\\model\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d\\siegeclass\\%s\\st\\%s\\st2\\%s\\dt\\%i\\sdt\\%i\\x\\%d",
                                client->pers.netname, client->sess.sessionTeam, model, c1, c2,
                                client->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask, teamLeader, className, saberName, saber2Name, client->sess.duelTeam, client->sess.siegeDesiredTeam, client->pers.myqboolean);
                }
                else
                {
                        s = va("n\\%s\\t\\%i\\model\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d\\st\\%s\\st2\\%s\\dt\\%i\\x\\%d",
                                client->pers.netname, client->sess.sessionTeam, model, c1, c2,
                                client->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask, teamLeader, saberName, saber2Name, client->sess.duelTeam, client->pers.myqboolean);
                }
        }

Add it to the end of the s char, then you can get it in the clientinfo in cg_players.c: CG_NewClientInfo

Code:

        // myqboolean x
        v = Info_ValueForKey( configstring, "x" );
        newInfo.myqboolean = atoi( v );


Dom_152 11-05-2006 04:45 AM

Thank you. And for the record I barely ever Copy-Paste example code as I like to write it out step by step so I know what I'm doing.


All times are GMT -4. The time now is 05:28 AM.

Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
LFNetwork, LLC ©2002-2011 - All rights reserved.