Advertisement
Deaderik

(FS) football script 0.5

Feb 12th, 2024
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.46 KB | Gaming | 0 0
  1. #include <a_samp>
  2.  
  3. #define MAX_TEAMS 2
  4. #define MAX_PLAYERS_PER_TEAM 5
  5. #define NO_TEAM -1
  6. #define INVALID_PLAYER_ID -1
  7. #define COLOR_WHITE 0xFFFFFF
  8. #define COLOR_YELLOW 0xFFFF00
  9.  
  10. new playerTeam[MAX_PLAYERS];
  11. new teamScore[MAX_TEAMS];
  12.  
  13. public OnPlayerConnect(playerid)
  14. {
  15.     SetPlayerTeam(playerid, NO_TEAM); // Noví hráči nemajú tím
  16.     playerTeam[playerid] = NO_TEAM;
  17.     return 1;
  18. }
  19.  
  20. public OnPlayerRequestClass(playerid, classid)
  21. {
  22.     if (playerTeam[playerid] == NO_TEAM)
  23.     {
  24.         SetPlayerTeam(playerid, classid); // Priradenie hráča k tímu
  25.         playerTeam[playerid] = classid;
  26.         SendClientMessage(playerid, COLOR_WHITE, "Pripojil si sa k tímu!");
  27.     }
  28.     else
  29.     {
  30.         SendClientMessage(playerid, COLOR_WHITE, "Už si v tíme!");
  31.     }
  32.     return 1;
  33. }
  34.  
  35. public OnPlayerDeath(playerid, killerid, reason)
  36. {
  37.     if (killerid != INVALID_PLAYER_ID && playerTeam[playerid] != NO_TEAM && playerTeam[playerid] == playerTeam[killerid])
  38.     {
  39.         teamScore[playerTeam[playerid]]++; // Zvýšenie skóre tímu
  40.         SendClientMessageToAll(COLOR_YELLOW, "Gól! Tím %d má %d bodov.", playerTeam[playerid], teamScore[playerTeam[playerid]]);
  41.     }
  42.     return 1;
  43. }
  44.  
  45. // Príkaz na vytvorenie tímu
  46. public OnPlayerCommandText(playerid, cmdtext[])
  47. {
  48.     new cmd[32];
  49.     new params[128];
  50.     if(sscanf(cmdtext, "ss[32]s[128]", cmd, params))
  51.     {
  52.         if(!strcmp(cmd, "/createteam", true))
  53.         {
  54.             CreateTeam(playerid, params);
  55.             return 1;
  56.         }
  57.         else if(!strcmp(cmd, "/showscore", true))
  58.         {
  59.             ShowTeamScore(playerid);
  60.             return 1;
  61.         }
  62.         else if(!strcmp(cmd, "/changeteam", true))
  63.         {
  64.             ChangeTeam(playerid, params);
  65.             return 1;
  66.         }
  67.         else if(!strcmp(cmd, "/resetscore", true))
  68.         {
  69.             ResetTeamScore(playerid);
  70.             return 1;
  71.         }
  72.     }
  73.     return 0;
  74. }
  75.  
  76. public CreateTeam(playerid, teamname[])
  77. {
  78.     new teamID = GetAvailableTeamID();
  79.     if(teamID != -1)
  80.     {
  81.         SetPlayerTeam(playerid, teamID);
  82.         SendClientMessageToAll(COLOR_WHITE, "Hráč %d vytvoril nový tím %s.", playerid, teamname);
  83.     }
  84.     else
  85.     {
  86.         SendClientMessage(playerid, COLOR_WHITE, "Všetky tímy sú plné.");
  87.     }
  88. }
  89.  
  90. public GetAvailableTeamID()
  91. {
  92.     for(new i = 0; i < MAX_TEAMS; i++)
  93.     {
  94.         new playersInTeam = CountPlayersInTeam(i);
  95.         if(playersInTeam < MAX_PLAYERS_PER_TEAM)
  96.         {
  97.             return i;
  98.         }
  99.     }
  100.     return -1;
  101. }
  102.  
  103. public CountPlayersInTeam(teamID)
  104. {
  105.     new count = 0;
  106.     for(new i = 0; i < MAX_PLAYERS; i++)
  107.     {
  108.         if(playerTeam[i] == teamID)
  109.         {
  110.             count++;
  111.         }
  112.     }
  113.     return count;
  114. }
  115.  
  116. public ShowTeamScore(playerid)
  117. {
  118.     for(new i = 0; i < MAX_TEAMS; i++)
  119.     {
  120.         SendClientMessage(playerid, COLOR_WHITE, "Tím %d má %d bodov.", i, teamScore[i]);
  121.     }
  122. }
  123.  
  124. public ChangeTeam(playerid, newteamid)
  125. {
  126.     if(newteamid >= 0 && newteamid < MAX_TEAMS)
  127.     {
  128.         SetPlayerTeam(playerid, newteamid);
  129.         SendClientMessage(playerid, COLOR_WHITE, "Zmenil si tím.");
  130.     }
  131.     else
  132.     {
  133.         SendClientMessage(playerid, COLOR_WHITE, "Neplatný tím.");
  134.     }
  135. }
  136.  
  137. public ResetTeamScore(playerid)
  138. {
  139.     for(new i = 0; i < MAX_TEAMS; i++)
  140.     {
  141.         teamScore[i] = 0;
  142.     }
  143.     SendClientMessageToAll(COLOR_WHITE, "Skóre tímov bolo resetované.");
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement