F1N4L_

Team Ex System [ATUALIZADO]

Oct 11th, 2016
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.11 KB | None | 0 0
  1. #if defined _included_teamex
  2.     #endinput
  3. #endif
  4. #define _included_teamex
  5. //---CONFIG
  6. #define MAX_TEAM_EX 500
  7. #define MIN_TEAM_EX 0
  8. #define NO_TEAM_EX -1
  9. //---VAR
  10. static
  11.     PlayerTeam[MAX_PLAYERS],
  12.     TeamKill[MAX_TEAM_EX],
  13.     TeamDeath[MAX_TEAM_EX]
  14. ;
  15. //---FORWARD
  16. forward OnPlayerTeamChangeEx(playerid, newteam, oldteam);
  17. forward OnHealthTeamChangeEx(playerid, team, Float:newhealth);
  18. forward OnArmourTeamChangeEx(playerid, team, Float:newarmour);
  19. forward OnWeaponTeamChangeEx(playerid, team, weaponid, ammo);
  20. forward OnKillTeamChangeEx(playerid, team, kills);
  21. forward OnDeathTeamChangeEx(playerid, team, deaths);
  22. //---GET-FUNCTION
  23. stock GetPlayerTeamEx(playerid)
  24.     return PlayerTeam[playerid];
  25. stock GetTeamKillEx(team)
  26. {
  27.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return -1;
  28.    
  29.     return TeamKill[team];
  30. }
  31. stock GetTeamDeathEx(team)
  32. {
  33.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return -1;
  34.    
  35.     return TeamDeath[team];
  36. }
  37. //---SET-FUNCTION
  38. stock SetPlayerTeamEx(playerid, team)
  39. {
  40.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  41.    
  42.     OnPlayerTeamChangeEx(playerid, team, PlayerTeam[playerid]);
  43.  
  44.     PlayerTeam[playerid] = team;
  45.    
  46.     return true;
  47. }
  48. stock SetAllPlayersTeamEx(team)
  49. {
  50.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  51.    
  52.     for(new i = 0; i < MAX_PLAYERS; ++ i)
  53.     {
  54.         if(!IsPlayerConnected(i)) continue;
  55.        
  56.         OnPlayerTeamChangeEx(i, team, PlayerTeam[i]);
  57.  
  58.         PlayerTeam[i] = team;
  59.     }
  60.  
  61.     return true;
  62. }
  63. stock SetTeamHealthEx(team, Float:health)
  64. {
  65.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  66.  
  67.     for(new i = 0 ; i < MAX_PLAYERS; ++ i)
  68.     {
  69.         if(!IsPlayerConnected(i)) continue;
  70.        
  71.         if(PlayerTeam[i] == team)
  72.         {
  73.             SetPlayerHealth(i, health);
  74.            
  75.             OnHealthTeamChangeEx(i, team, health);
  76.         }
  77.     }
  78.  
  79.     return true;
  80. }
  81. stock SetTeamArmourEx(team, Float:armour)
  82. {
  83.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  84.    
  85.     for(new i = 0 ; i < MAX_PLAYERS; ++ i)
  86.     {
  87.         if(!IsPlayerConnected(i)) continue;
  88.        
  89.         if(PlayerTeam[i] == team)
  90.         {
  91.             SetPlayerArmour(i, armour);
  92.            
  93.             OnArmourTeamChangeEx(i, team, armour);
  94.         }
  95.     }
  96.  
  97.     return true;
  98. }
  99. stock SetTeamKillEx(team, kills)
  100. {
  101.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  102.  
  103.     TeamKill[team] = kills;
  104.  
  105.     OnKillTeamChangeEx(INVALID_PLAYER_ID, team, kills);
  106.  
  107.     return true;
  108. }
  109. stock SetTeamDeathEx(team, deaths)
  110. {
  111.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  112.  
  113.     TeamDeath[team] = deaths;
  114.  
  115.     OnDeathTeamChangeEx(INVALID_PLAYER_ID, team, deaths);
  116.  
  117.     return true;
  118. }
  119. stock SetTeamWeaponEx(team, weaponid, ammo)
  120. {
  121.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  122.    
  123.     if(ammo < 1) return false;
  124.    
  125.     switch(weaponid)
  126.     {
  127.         case 0 .. 18, 22 .. 46:{}
  128.         default: return false;
  129.     }
  130.    
  131.     for(new i = 0 ; i < MAX_PLAYERS; ++ i)
  132.     {
  133.         if(!IsPlayerConnected(i)) continue;
  134.        
  135.         if(PlayerTeam[i] == team)
  136.         {
  137.             GivePlayerWeapon(i, weaponid, ammo);
  138.            
  139.             OnWeaponTeamChangeEx(i, team, weaponid, ammo);
  140.         }
  141.     }
  142.     return true;
  143. }
  144. //---REMOVE-FUNCTION
  145. stock RemovePlayerTeamEx(playerid)
  146. {
  147.     OnPlayerTeamChangeEx(playerid, NO_TEAM_EX, PlayerTeam[playerid]);
  148.  
  149.     PlayerTeam[playerid] = NO_TEAM_EX;
  150.  
  151.     return true;
  152. }
  153. stock RemoveAllPlayersTeamEx()
  154. {
  155.     for(new i = 0; i < MAX_PLAYERS; ++ i)
  156.     {
  157.         if(!IsPlayerConnected(i)) continue;
  158.  
  159.         OnPlayerTeamChangeEx(i, NO_TEAM_EX, PlayerTeam[i]);
  160.        
  161.         PlayerTeam[i] = NO_TEAM_EX;
  162.     }
  163.     return true;
  164. }
  165. //---RESET-FUNCTION
  166. stock ResetTeamKillEx(team)
  167. {
  168.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  169.  
  170.     OnKillTeamChangeEx(INVALID_PLAYER_ID, team, 0);
  171.    
  172.     TeamKill[team] = 0;
  173.    
  174.     return true;
  175. }
  176. stock ResetTeamDeathEx(team)
  177. {
  178.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  179.    
  180.     OnDeathTeamChangeEx(INVALID_PLAYER_ID, team, 0);
  181.  
  182.     TeamDeath[team] = 0;
  183.    
  184.     return true;
  185. }
  186. stock ResetAllTeamKillEx()
  187. {
  188.     for(new i = 0; i < MAX_TEAM_EX; ++ i)
  189.     {
  190.         OnKillTeamChangeEx(INVALID_PLAYER_ID, i, 0);
  191.  
  192.         TeamKill[i] = 0;
  193.     }
  194.    
  195.     return true;
  196. }
  197. stock ResetAllTeamDeathEx()
  198. {
  199.     for(new i = 0; i < MAX_PLAYERS; ++ i)
  200.     {
  201.         OnDeathTeamChangeEx(INVALID_PLAYER_ID, i, 0);
  202.  
  203.         TeamDeath[i] = 0;
  204.     }
  205.    
  206.     return true;
  207. }
  208. stock ResetTeamKillDeathEx(team)
  209. {
  210.     if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
  211.    
  212.     OnKillTeamChangeEx(INVALID_PLAYER_ID, team, 0);
  213.     TeamKill[team] = 0;
  214.  
  215.     OnDeathTeamChangeEx(INVALID_PLAYER_ID, team, 0);
  216.     TeamDeath[team] = 0;
  217.    
  218.     return true;
  219. }
  220. stock ResetAllTeamKillDeathEx()
  221. {
  222.     for(new i = 0; i < MAX_TEAM_EX; ++ i)
  223.     {
  224.         OnKillTeamChangeEx(INVALID_PLAYER_ID, i, 0);
  225.         TeamKill[i] = 0;
  226.  
  227.         OnDeathTeamChangeEx(INVALID_PLAYER_ID, i, 0);
  228.         TeamDeath[i] = 0;
  229.     }
  230.    
  231.     return true;
  232. }
  233. //---CALLBACK
  234. public OnPlayerConnect(playerid)
  235. {
  236.     PlayerTeam[playerid] = NO_TEAM_EX;
  237.  
  238.     #if defined TeamEx_OnPlayerConnect
  239.         TeamEx_OnPlayerConnect(playerid);
  240.     #endif
  241.     return true;
  242. }
  243. #if defined _ALS_OnPlayerConnect
  244.     #undef OnPlayerConnect
  245. #else
  246.     #define _ALS_OnPlayerConnect
  247. #endif
  248. #define OnPlayerConnect TeamEx_OnPlayerConnect
  249. #if defined TeamEx_OnPlayerConnect
  250.     forward TeamEx_OnPlayerConnect(playerid);
  251. #endif
  252. public OnPlayerDeath(playerid, killerid, reason)
  253. {
  254.     if(killerid != INVALID_PLAYER_ID)
  255.     {
  256.         if(PlayerTeam[killerid] != NO_TEAM_EX)
  257.         {
  258.             if(PlayerTeam[killerid] != PlayerTeam[playerid])
  259.             {
  260.                 ++TeamKill[PlayerTeam[killerid]];
  261.                 ++TeamDeath[PlayerTeam[playerid]];
  262.             }
  263.  
  264.             OnKillTeamChangeEx(killerid, PlayerTeam[killerid], TeamKill[PlayerTeam[killerid]]);
  265.             OnDeathTeamChangeEx(playerid, PlayerTeam[playerid], TeamDeath[PlayerTeam[playerid]]);
  266.         }
  267.     }
  268.     else
  269.     {
  270.         if(PlayerTeam[playerid] != NO_TEAM_EX)
  271.         {
  272.             ++TeamDeath[PlayerTeam[playerid]];
  273.            
  274.             OnDeathTeamChangeEx(playerid, PlayerTeam[playerid], TeamDeath[PlayerTeam[playerid]]);
  275.         }
  276.     }
  277.    
  278.     #if defined TeamEx_OnPlayerDeath
  279.         TeamEx_OnPlayerDeath(playerid, killerid, reason);
  280.     #endif
  281.     return true;
  282. }
  283. #if defined _ALS_OnPlayerDeath
  284.     #undef OnPlayerDeath
  285. #else
  286.     #define _ALS_OnPlayerDeath
  287. #endif
  288. #define OnPlayerDeath TeamEx_OnPlayerDeath
  289. #if defined TeamEx_OnPlayerDeath
  290.     forward TeamEx_OnPlayerDeath(playerid, killerid, reason);
  291. #endif
Advertisement
Add Comment
Please, Sign In to add comment