toribio

toribio

Nov 13th, 2009
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 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. public OnPlayerConnect(playerid)
  8. {
  9.     new pname[MAX_PLAYER_NAME];
  10.     GetPlayerName(playerid, pname, sizeof pname);
  11.     if(pname[0] == '[' && strfind(pname, "]", true) >= 2) //tem que ter [..] no nick
  12.     {
  13.         static clans;
  14.         new bool:is;
  15.         if(clans <= sizeof clan_colors)
  16.         {
  17.             new tag[14];
  18.             strmid(tag, pname, strfind(pname, "[", true), strfind(pname, "]", true));
  19.             for(new j = 0; j < sizeof clan_tag; j++)        
  20.             {
  21.                 if(strfind(clan_tag[j], tag, false) != -1)
  22.                 {
  23.                     SetPlayerColor(playerid, clan_colors[j]);
  24.                     is = true;
  25.                     break;
  26.                 } else is = false;            
  27.             }
  28.             if(!is)
  29.             {
  30.                 new id;
  31.                 for(id = 0; id < sizeof clan_tag; id++)
  32.                     if(!strlen(clan_tag[id]))
  33.                         break;
  34.                 strmid(clan_tag[id], tag, 0, strlen(tag));
  35.                 SetPlayerColor(playerid, clan_colors[id]);
  36.                 clans++;
  37.             }
  38.         }
  39.     }
  40.     return 1;
  41. }
  42.  
  43. public OnPlayerDisconnect(playerid, reason)
  44. {
  45.     new pname[MAX_PLAYER_NAME];
  46.     GetPlayerName(playerid, pname, sizeof pname);
  47.     if(pname[0] == '[' && strfind(pname, "]", true) >= 2)
  48.     {
  49.         new tag[14], has;
  50.         strmid(tag, pname, strfind(pname, "[", true), strfind(pname, "]", true));
  51.         for(new k = 0, t[14], n[MAX_PLAYER_NAME]; k < MAX_PLAYERS; k++)
  52.         {
  53.             GetPlayerName(k, n, sizeof n);
  54.             if(n[0] == '[' && strfind(n, "]", true) >= 2)
  55.             {
  56.                 strmid(t, n, strfind(n, "[", true), strfind(n, "]", true));
  57.                 if(playerid != k && strfind(tag, t, false) != -1) has++;
  58.             }
  59.         }
  60.         if(has == 0)
  61.             for(new i = 0; i < sizeof clan_tag; i++)
  62.                 if(strfind(clan_tag[i], tag, false) != -1)
  63.                     clan_tag[i] = "";
  64.     }
  65.     return 1;
  66. }
Add Comment
Please, Sign In to add comment