toribio

toribio

Nov 13th, 2009
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. new clan_colors[] =
  2. {
  3.     0xFF0000AA, 0xFFF000AA, 0x00FF00AA
  4. }; //cada cor aqui, é a cor de um clan
  5. new clan_tag[sizeof clan_colors][14];
  6.  
  7. //no OnPlayerConnect:
  8. new pname[MAX_PLAYER_NAME];
  9. GetPlayerName(playerid, pname, sizeof pname);
  10. if(pname[0] == '[' && strfind(pname, "]", true) >= 2) //tem que ter [..] no nick
  11. {
  12.     static clans;
  13.     new bool:is;
  14.     if(clans <= sizeof clans_colors)
  15.     {
  16.         new tag[14];
  17.         strmid(tag, pname, strfind(pname, "[", true), strfind(pname, "]", true));
  18.         for(new i = 0; i < sizeof clan_tag; i++)
  19.             if(strfind(clan_tag[i], tag, false) != -1)
  20.             {
  21.                 SetPlayerColor(playerid, clan_colors[i]);
  22.                 is = true;
  23.                 break;
  24.             } else is = false;
  25.         if(!is)
  26.         {
  27.             new id;
  28.             for(id = 0; id < sizeof clan_tag; id++)
  29.                 if(!strlen(clan_tag[id])
  30.                     break;
  31.             strmid(clan_tag[id], tag, 0, strlen(tag));
  32.             SetPlayerColor(playerid, clan_colors[id]);
  33.             clans++;
  34.         }
  35.     }
  36. }
  37.  
  38. //OnPlayerDisconnect:
  39. new pname[MAX_PLAYER_NAME];
  40. GetPlayerName(playerid, pname, sizeof pname);
  41. if(pname[0] == '[' && strfind(pname, "]", true) >= 2)
  42. {
  43.     new tag[14], has;
  44.     strmid(tag, pname, strfind(pname, "[", true), strfind(pname, "]", true));
  45.     for(new i = 0, t[14], n[MAX_PLAYER_NAME]; i < MAX_PLAYERS]; i++)
  46.     {
  47.         GetPlayerName(i, n, sizeof n);
  48.         if(n[0] == '[' && strfind(n, "]", true) >= 2)
  49.         {
  50.             strmid(t, n, strfind(n, "[", true), strfind(n, "]", true));
  51.             if(playerid != i && strfind(tag, t, false) != -1) has++;
  52.         }
  53.     }
  54.     if(has == 0)
  55.         for(new i = 0; i < sizeof clan_tag; i++)
  56.             if(strfind(clan_tag[i], tag, false) != -1)
  57.                 clan_tag[i] = "";
  58. }
Add Comment
Please, Sign In to add comment