Advertisement
lucasgautheron

Untitled

Apr 23rd, 2011
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1.  
  2. #define LOCALPLAYER if(p!=player1) { conoutf("no permission"); return; }
  3. #define READONLY if(set) { conoutf("no permission"); return; }
  4.  
  5. void player(const char *cn, const char *attr, const char *value)
  6. {
  7.     if(!*cn || !cn || !*attr || attr) return;
  8.  
  9.     int clientnum = atoi(cn); // get player clientnum
  10.    
  11.     playerent *p = clientnum == player1->clientnum ? player1 : NULL;
  12.  
  13.     if(!p)
  14.     loopv(players) if(players[i])
  15.     {
  16.         if(players[i]->clientnum == clientnum)
  17.         {
  18.             p = players[i];
  19.         }
  20.     }
  21.  
  22.     if(!p)
  23.     {
  24.         conoutf("invalid clientnum");
  25.         return;
  26.     }
  27.  
  28.     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)
  29.  
  30.     string output = "";
  31.     if(!strcmp(attr, "health"))
  32.     {
  33.         LOCALPLAYER; READONLY;
  34.         formatstring(output)("%i", p->health);
  35.     }
  36.     else if(!strcmp(attr, "armour"))
  37.     {
  38.         LOCALPLAYER; READONLY;
  39.         formatstring(output)("%i", p->armour);
  40.     }
  41.     else if(!strcmp(attr, "name"))
  42.     {
  43.         LOCALPLAYER;
  44.         formatstring(output)("%s", p->name);
  45.     }
  46.     else if(!strcmp(attr, "primary"))
  47.     {
  48.         LOCALPLAYER; READONLY;
  49.         formatstring(output)("%s", p->primary);
  50.     }
  51.     else if(!strcmp(attr, "nextprimary"))
  52.     {
  53.         LOCALPLAYER; READONLY;
  54.         formatstring(output)("%s", p->nextprimary);
  55.     }
  56.     else if(!strcmp(attr, "magcontent"))
  57.     {
  58.         LOCALPLAYER; READONLY;
  59.         formatstring(output)("%s", p->weaponsel->ammo);
  60.     }
  61.     else if(!strcmp(attr, "magreserve"))
  62.     {
  63.         LOCALPLAYER; READONLY;
  64.         formatstring(output)("%s", p->weaponsel->mag);
  65.     }
  66.     result(output);
  67. }
  68.  
  69. COMMAND(player, ARG_3STR);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement