Advertisement
Kartik_Sharma

Untitled

Aug 18th, 2012
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.35 KB | None | 0 0
  1. #if !defined TDperGroup
  2.     #define TDperGroup 25
  3. #endif
  4.  
  5. #if !defined MAX_GROUPS
  6.     #define MAX_GROUPS 100
  7. #endif
  8.  
  9. /*
  10. native CreateTDGroup({Text}:...);
  11. native DestroyTDGroup(slot);
  12. native TDGroupAddTD(slot,{Text}:...);
  13. native TDGroupRemoveTD(slot,{Text}:...);
  14. native TDGroupShowForAll(slot);
  15. native TDGroupHideForAll(slot);
  16. native TDGroupShowForPlayer(playerid,slot);
  17. native TDGroupHideForPlayer(playerid,slot);
  18.  
  19. */
  20.  
  21. enum E_TD_ENUM
  22. {
  23.     count,
  24. }
  25. new tdenum[MAX_GROUPS][E_TD_ENUM];
  26. new TDid[MAX_GROUPS][TDperGroup];
  27.  
  28. stock CreateTDGroup({Text}:...)
  29. {
  30.     new slot = -1;
  31.    
  32.     for(new i=0;i<MAX_GROUPS;++i)
  33.     {
  34.         if(tdenum[i][count] == -1)
  35.         {
  36.             slot=i;
  37.             break;
  38.         }
  39.     }
  40.    
  41.     if(slot == -1)
  42.     {
  43.         printf("No more emply slot's found. Increase MAX_GROUPS");
  44.         return -1;
  45.     }
  46.    
  47.     new num = tdenum[slot][count] = numargs();
  48.  
  49.     if(num > TDperGroup)
  50.     {
  51.         printf("Increase TDperGroup");
  52.         return -1;
  53.     }
  54.     for(new i=0;i<num;++i)
  55.     {
  56.         TDid[slot][i]=getarg(i,0);
  57.     }
  58.    
  59.     return slot;
  60. }
  61.  
  62. stock DestroyTDGroup(slot)
  63. {
  64.     if(slot > MAX_GROUPS || slot<0)
  65.     {
  66.         printf("Invalid Slot Passed in DestroyTDGroup");
  67.         return -1;
  68.     }
  69.     tdenum[slot][count] = -1;
  70.     return 1;
  71. }
  72. stock TDGroupAddTD(slot,{Text}:...)
  73. {
  74.     if(slot > MAX_GROUPS || slot<0)
  75.     {
  76.         printf("Invalid Slot Passed ");
  77.         return -1;
  78.     }
  79.     if(tdenum[slot][count] == -1) return -1;
  80.     new num = numargs();
  81.     new at = tdenum[slot][count];
  82.     if((num+at-1) > MAX_GROUPS)
  83.     {
  84.         printf("Increase TDperGroup");
  85.         return -1;
  86.     }
  87.     new i,j;
  88.     for(i = at,j=1;j<num;++i,++j) TDid[slot][i]=getarg(j,0);
  89.     tdenum[slot][count]=tdenum[slot][count]+num-1;
  90.     return 1;
  91. }
  92.  
  93. stock TDGroupRemoveTD(slot,{Text}:...)
  94. {
  95.     if(slot > MAX_GROUPS || slot<0)
  96.     {
  97.         printf("Invalid Slot Passed ");
  98.         return -1;
  99.     }
  100.     if(tdenum[slot][count] == -1) return -1;
  101.     new num = numargs();
  102.     new c = tdenum[slot][count];
  103.    
  104.     for(new j=1;j<num;++j)
  105.     {
  106.         for(new i=0;i<c;++i)
  107.         {
  108.             if(TDid[slot][i]==getarg(j,0))
  109.             {
  110.                 c=c-1;
  111.                 for(new k=i;k<c;++k) TDid[slot][k] = TDid[slot][k+1];
  112.                 tdenum[slot][count]--;
  113.                 break;
  114.             }
  115.                
  116.         }
  117.     }
  118.     return 1;
  119. }
  120.  
  121. stock TDGroupShowForAll(slot)
  122. {
  123.     if(slot > MAX_GROUPS || slot<0)
  124.     {
  125.         printf("Invalid Slot Passed ");
  126.         return -1;
  127.     }
  128.     if(tdenum[slot][count] == -1) return -1;
  129.     for(new i=0;i<tdenum[slot][count];++i)
  130.         TextDrawShowForAll(Text:TDid[slot][i]);
  131.     return 1;
  132. }
  133. stock TDGroupHideForAll(slot)
  134. {
  135.     if(slot > MAX_GROUPS || slot<0)
  136.     {
  137.         printf("Invalid Slot Passed ");
  138.         return -1;
  139.     }
  140.     if(tdenum[slot][count] == -1) return -1;
  141.     for(new i=0;i<tdenum[slot][count];++i)
  142.         TextDrawHideForAll(Text:TDid[slot][i]);
  143.     return 1;
  144. }
  145. stock TDGroupShowForPlayer(playerid,slot)
  146. {
  147.     if(slot > MAX_GROUPS || slot<0)
  148.     {
  149.         printf("Invalid Slot Passed ");
  150.         return -1;
  151.     }
  152.    
  153.     if(tdenum[slot][count] == -1) return -1;
  154.     for(new i=0;i<tdenum[slot][count];++i)
  155.         TextDrawShowForPlayer(playerid,Text:TDid[slot][i]);
  156.     return 1;
  157. }
  158. stock TDGroupHideForPlayer(playerid,slot)
  159. {
  160.     if(slot > MAX_GROUPS || slot<0)
  161.     {
  162.         printf("Invalid Slot Passed ");
  163.         return -1;
  164.     }
  165.     if(tdenum[slot][count] == -1) return -1;
  166.     for(new i=0;i<tdenum[slot][count];++i)
  167.         TextDrawHideForPlayer(playerid,Text:TDid[slot][i]);
  168.     return 1;
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement