Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define LOCALPLAYER if(p!=player1) { conoutf("no permission"); return; }
- #define READONLY if(set) { conoutf("no permission"); return; }
- void player(const char *cn, const char *attr, const char *value)
- {
- if(!*cn || !cn || !*attr || attr) return;
- int clientnum = atoi(cn); // get player clientnum
- playerent *p = clientnum == player1->clientnum ? player1 : NULL;
- if(!p)
- loopv(players) if(players[i])
- {
- if(players[i]->clientnum == clientnum)
- {
- p = players[i];
- }
- }
- if(!p)
- {
- conoutf("invalid clientnum");
- return;
- }
- bool set = *value && value && atoi(value) == 1 && p==player1; // do we have to get or set an attribute (valid value, value = 1, player selected is local client)
- string output = "";
- if(!strcmp(attr, "health"))
- {
- LOCALPLAYER; READONLY;
- formatstring(output)("%i", p->health);
- }
- else if(!strcmp(attr, "armour"))
- {
- LOCALPLAYER; READONLY;
- formatstring(output)("%i", p->armour);
- }
- else if(!strcmp(attr, "name"))
- {
- LOCALPLAYER;
- formatstring(output)("%s", p->name);
- }
- else if(!strcmp(attr, "primary"))
- {
- LOCALPLAYER; READONLY;
- formatstring(output)("%s", p->primary);
- }
- else if(!strcmp(attr, "nextprimary"))
- {
- LOCALPLAYER; READONLY;
- formatstring(output)("%s", p->nextprimary);
- }
- else if(!strcmp(attr, "magcontent"))
- {
- LOCALPLAYER; READONLY;
- formatstring(output)("%s", p->weaponsel->ammo);
- }
- else if(!strcmp(attr, "magreserve"))
- {
- LOCALPLAYER; READONLY;
- formatstring(output)("%s", p->weaponsel->mag);
- }
- result(output);
- }
- COMMAND(player, ARG_3STR);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement