MCPcopy Create free account
hub / github.com/assaultcube/AC / playerinfo

Function playerinfo

source/src/clientgame.cpp:243–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241#define ATTR_STR(name, attribute) if(!strcmp(attr, #name)) { result(attribute); return; }
242
243void playerinfo(int *cn, const char *attr)
244{
245 if(!*attr || !attr) return;
246
247 int clientnum = *cn; // get player clientnum
248 playerent *p = clientnum < 0 ? player1 : getclient(clientnum);
249 if(!p)
250 {
251 if(!m_botmode && multiplayer(NULL)) // bot clientnums are still glitchy, causing this message to sometimes appear in offline/singleplayer when it shouldn't??? -Bukz 2012may
252 conoutf("invalid clientnum cn: %d attr: %s", clientnum, attr);
253 return;
254 }
255
256 if(p == player1)
257 {
258 ATTR_INT(magcontent, p->weaponsel->mag);
259 ATTR_INT(ammo, p->weaponsel->ammo);
260 ATTR_INT(primary, p->primary);
261 ATTR_INT(curweapon, p->weaponsel->type);
262 ATTR_INT(nextprimary, p->nextprimary);
263 }
264
265 if(p == player1
266 || (team_base(p->team) == team_base(player1->team) && m_teammode)
267 || player1->team == TEAM_SPECT
268 || m_coop)
269 {
270 ATTR_INT(health, p->health);
271 ATTR_INT(armour, p->armour);
272 ATTR_INT(attacking, p->attacking);
273 ATTR_INT(scoping, p->scoping);
274 ATTR_FLOAT(x, p->o.x);
275 ATTR_FLOAT(y, p->o.y);
276 ATTR_FLOAT(z, p->o.z);
277 }
278 ATTR_STR(name, p->name);
279 ATTR_INT(team, p->team);
280 ATTR_INT(ping, p->ping);
281 ATTR_INT(pj, p->plag);
282 ATTR_INT(state, p->state);
283 ATTR_INT(role, p->clientrole);
284 ATTR_INT(frags, p->frags);
285 ATTR_INT(flags, p->flagscore);
286 ATTR_INT(deaths, p->deaths);
287 ATTR_INT(tks, p->tks);
288 ATTR_INT(alive, p->state == CS_ALIVE ? 1 : 0);
289 ATTR_INT(spect, p->team == TEAM_SPECT || p->spectatemode == SM_FLY ? 1 : 0);
290 ATTR_INT(cn, p->clientnum); // only useful to get player1's client number.
291 ATTR_INT(skin_cla, p->skin(TEAM_CLA));
292 ATTR_INT(skin_rvsf, p->skin(TEAM_RVSF));
293 ATTR_INT(skin, p->skin(player1->team));
294
295 string addrstr;
296 iptoa(p->address, addrstr);
297 ATTR_STR(ip, addrstr);
298
299 conoutf("invalid attribute: %s", attr);
300}

Callers 1

playerinfolocalFunction · 0.85

Calls 5

getclientFunction · 0.85
multiplayerFunction · 0.85
iptoaFunction · 0.85
skinMethod · 0.80
conoutfFunction · 0.70

Tested by

no test coverage detected