C_far

DEV SAMP - Vidéo - TDM

Aug 7th, 2016
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.49 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_RED       0xFF0000FF
  4. #define COLOR_GREEN     0x33AA33FF
  5.  
  6. //-------------------------------
  7.  
  8. main(){}
  9.  
  10. //-------------------------------
  11.  
  12. enum Team
  13. {
  14.     BALLAS,
  15.     GROVE
  16. }
  17.  
  18. enum e_Player
  19. {
  20.     pName[MAX_PLAYER_NAME],
  21.    
  22.     Team:pTeam,
  23.    
  24.     pKills,
  25.     pDeaths,
  26.    
  27.     bool:pFirstSpawn
  28. }
  29.  
  30. //-------------------------------
  31.  
  32. stock
  33.     members[Team],
  34.     pInfo[MAX_PLAYERS][e_Player];
  35.    
  36. stock const
  37.     Float:spawns[Team][][] =
  38.     {
  39.         {
  40.             {-92.5665, -359.0368, 1.4297, 284.8226},
  41.             {-91.7508, -355.1365, 1.4297, 284.8226},
  42.             {-91.1126, -349.8121, 1.4297, 284.8226}
  43.         },
  44.        
  45.         {
  46.             {-6.6407, -320.0028, 5.4297, 90.5539},
  47.             {-7.4725, -317.0150, 5.4297, 90.5539},
  48.             {-8.2477, -314.3397, 5.4297, 90.5539}
  49.         }
  50.     };
  51.  
  52. //-------------------------------
  53.  
  54. stock AddPlayerToTeam(playerid, Team:teamid)
  55. {
  56.     pInfo[playerid][pTeam] = teamid;
  57.     members[teamid]++;
  58.    
  59.     SetPlayerTeam(playerid, _:teamid);
  60.    
  61.     static const
  62.         skins[Team][3] =
  63.         {
  64.             {102, 103, 104},
  65.             {105, 106, 107}
  66.         };
  67.        
  68.     SetPlayerSkin(playerid, skins[teamid][random(3)]);
  69.    
  70.     return 1;
  71. }
  72.  
  73. //-------------------------------
  74.  
  75. public OnPlayerConnect(playerid)
  76. {
  77.     GetPlayerName(playerid, pInfo[playerid][pName], MAX_PLAYER_NAME);
  78.    
  79.     //------------------
  80.    
  81.     pInfo[playerid][pFirstSpawn] = true;
  82.  
  83.     return 1;
  84. }
  85.  
  86. public OnPlayerDisconnect(playerid, reason)
  87. {
  88.     static const
  89.         reasonMsg[][] =
  90.         {
  91.             "Crash",
  92.             "Déconnexion",
  93.             "Kick/Ban"
  94.         };
  95.        
  96.     //----------------------
  97.  
  98.     new
  99.         str[64];
  100.        
  101.     format(str, sizeof(str), "%s a quitté le serveur. (%s)", pInfo[playerid][pName], reasonMsg[reason]);
  102.     SendClientMessageToAll(-1, str);
  103.    
  104.     //----------------------
  105.    
  106.     members[ pInfo[playerid][pTeam] ]--;
  107.    
  108.     //----------------------
  109.    
  110.     static const
  111.         eBlank[e_Player];
  112.        
  113.     pInfo[playerid] = eBlank;
  114.    
  115.     return 1;
  116. }
  117.  
  118. public OnPlayerSpawn(playerid)
  119. {
  120.     if(pInfo[playerid][pFirstSpawn])
  121.     {
  122.         pInfo[playerid][pFirstSpawn] = false;
  123.        
  124.         if(members[BALLAS] > members[GROVE])
  125.             AddPlayerToTeam(playerid, GROVE);
  126.            
  127.         else if(members[BALLAS] < members[GROVE])
  128.             AddPlayerToTeam(playerid, BALLAS);
  129.            
  130.         else
  131.             AddPlayerToTeam(playerid, Team:random(_:Team));
  132.     }
  133.    
  134.     //----------------------
  135.    
  136.     GivePlayerWeapon(playerid, WEAPON_DEAGLE, 500);
  137.    
  138.     new
  139.         Team:teamid = pInfo[playerid][pTeam],
  140.         rand = random( sizeof(spawns[]) );
  141.        
  142.     SetPlayerPos(playerid, spawns[teamid][rand][0], spawns[teamid][rand][1], spawns[teamid][rand][2]);
  143.  
  144.     return 1;
  145. }
  146.  
  147. public OnPlayerDeath(playerid, killerid, reason)
  148. {
  149.     if(killerid == INVALID_PLAYER_ID) return 1;
  150.    
  151.     //----------------------
  152.    
  153.     pInfo[playerid][pDeaths]++;
  154.     pInfo[killerid][pKills]++;
  155.    
  156.     //----------------------
  157.    
  158.     new
  159.         str[2][64],
  160.         Team:teamid = pInfo[playerid][pTeam];
  161.        
  162.     format(str[0], sizeof(str[]), "Un allié (%s) a été tué.", pInfo[playerid][pName]);
  163.     format(str[1], sizeof(str[]), "Un adversaire a été tué par %s.", pInfo[killerid][pName]);
  164.    
  165.     for(new i = 0; i < MAX_PLAYERS; i++)
  166.     {
  167.         if(!IsPlayerConnected(i)) continue;
  168.        
  169.         if(teamid == pInfo[i][pTeam])
  170.         {
  171.             if(playerid == i) continue;
  172.             SendClientMessage(i, COLOR_RED, str[0]);
  173.         }
  174.        
  175.         else
  176.         {
  177.             if(killerid == i) continue;
  178.             SendClientMessage(i, COLOR_GREEN, str[1]);
  179.         }
  180.     }
  181.    
  182.     format(str[0], sizeof(str[]), "Vous avez été tué par %s.", pInfo[killerid][pName]);
  183.     SendClientMessage(playerid, -1, str[0]);
  184.    
  185.     format(str[0], sizeof(str[]), "Vous avez tué %s.", pInfo[playerid][pName]);
  186.     SendClientMessage(killerid, -1, str[0]);
  187.  
  188.     return 1;
  189. }
Advertisement