Advertisement
furiadanoitebr

Sistema de BombTag V2

Jun 7th, 2025 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.60 KB | Gaming | 0 0
  1. /*
  2. Sistema de Bomba Tag criado por furiadanoite
  3. Discord: furiadanoitebr / !FuriaDaNoiteBR#6666
  4.  
  5. Cada jogador que estiver com a bomba deve transferi-la para outro jogador ao encostar nele, para sobreviver.
  6. Quem estiver com a bomba quando o tempo acabar, explode e perde uma vida. O último jogador vivo vence!
  7. */
  8.  
  9. #define SAMP_COMPAT
  10. #include <open.mp> // Open.mp ou <samp> é usado para compatibilidade com o SA:MP
  11. #include <sscanf2>
  12. #include <zcmd> // ZCMD é usado para comandos, substitui o cmdtextdraw
  13. #include <YSI_Data\y_iterate> // esse include é necessário para o foreach ou outro include foreach
  14.  
  15. // Cores
  16. #define C_RED  0xFF0000C8
  17.  
  18. // Textdraw
  19. new Text:BombTagTD[3];
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     BombTagTD[0] = TextDrawCreate(567.000000, 186.000000, "Explode");
  24.     TextDrawFont(BombTagTD[0], 2);
  25.     TextDrawLetterSize(BombTagTD[0], 0.341666, 2.200000);
  26.     TextDrawTextSize(BombTagTD[0], 633.000000, 92.000000);
  27.     TextDrawSetOutline(BombTagTD[0], 1);
  28.     TextDrawSetShadow(BombTagTD[0], 1);
  29.     TextDrawAlignment(BombTagTD[0], 1);
  30.     TextDrawColor(BombTagTD[0], -16776961);
  31.     TextDrawBackgroundColor(BombTagTD[0], 255);
  32.     TextDrawBoxColor(BombTagTD[0], 50);
  33.     TextDrawUseBox(BombTagTD[0], true);
  34.     TextDrawSetProportional(BombTagTD[0], true);
  35.     TextDrawSetSelectable(BombTagTD[0], false);
  36.  
  37.     BombTagTD[1] = TextDrawCreate(601.000000, 210.000000, " ");
  38.     TextDrawFont(BombTagTD[1], 3);
  39.     TextDrawLetterSize(BombTagTD[1], 0.554166, 2.449999);
  40.     TextDrawTextSize(BombTagTD[1], 400.000000, 17.000000);
  41.     TextDrawSetOutline(BombTagTD[1], 2);
  42.     TextDrawSetShadow(BombTagTD[1], 1);
  43.     TextDrawAlignment(BombTagTD[1], 2);
  44.     TextDrawColor(BombTagTD[1], 1097458175);
  45.     TextDrawBackgroundColor(BombTagTD[1], 255);
  46.     TextDrawBoxColor(BombTagTD[1], 50);
  47.     TextDrawUseBox(BombTagTD[1], false);
  48.     TextDrawSetProportional(BombTagTD[1], true);
  49.     TextDrawSetSelectable(BombTagTD[1], false);
  50.  
  51.     BombTagTD[2] = TextDrawCreate(228.000000, 421.000000, " ");
  52.     TextDrawFont(BombTagTD[2], 3);
  53.     TextDrawLetterSize(BombTagTD[2], 0.233333, 2.000000);
  54.     TextDrawTextSize(BombTagTD[2], 400.000000, 17.000000);
  55.     TextDrawSetOutline(BombTagTD[2], 1);
  56.     TextDrawSetShadow(BombTagTD[2], 1);
  57.     TextDrawAlignment(BombTagTD[2], 1);
  58.     TextDrawColor(BombTagTD[2], 1296911871);
  59.     TextDrawBackgroundColor(BombTagTD[2], 255);
  60.     TextDrawBoxColor(BombTagTD[2], 50);
  61.     TextDrawUseBox(BombTagTD[2], true);
  62.     TextDrawSetProportional(BombTagTD[2], true);
  63.     TextDrawSetSelectable(BombTagTD[2], false);
  64.     return 1;
  65. }
  66.  
  67. public OnFilterScriptExit()
  68. {
  69.     return 1;
  70. }
  71.  
  72. // Stock pName - Retorna o nome do jogador
  73. stock pName(playerid)
  74. {
  75.     new GetName[MAX_PLAYER_NAME];
  76.     GetPlayerName(playerid, GetName, sizeof(GetName));
  77.     return GetName;
  78. }
  79.  
  80. // Bomba Tag - Variables
  81. new bool:HasBomb[MAX_PLAYERS];
  82. new BombCountdown[MAX_PLAYERS];
  83. new PlayerParticle[MAX_PLAYERS];
  84. new PlayersAlive = 0;
  85.  
  86. forward Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
  87. stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
  88. {
  89.     return floatsqroot((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));
  90. }
  91.  
  92. stock Float:GetVehicleDistanceFromVehicle(vehicle1, vehicle2) {
  93.     new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
  94.     GetVehiclePos(vehicle1, x1, y1, z1);
  95.     GetVehiclePos(vehicle2, x2, y2, z2);
  96.     return GetDistanceBetweenPoints(x1, y1, z1, x2, y2, z2);
  97. }
  98.  
  99. stock StartBombCountdown(playerid) {
  100.     BombCountdown[playerid] = 30;
  101.     HasBomb[playerid] = true;
  102.  
  103.     new string[128];
  104.     format(string, sizeof(string), "O Jogador %s agora esta com a bomba! FUJA!", pName(playerid));
  105.     SendClientMessageToAll(C_RED, string);
  106.  
  107.     foreach(new i : Player) {
  108.         TextDrawShowForPlayer(i, BombTagTD[0]);
  109.         TextDrawShowForPlayer(i, BombTagTD[1]);
  110.         TextDrawShowForPlayer(i, BombTagTD[2]);
  111.     }
  112.  
  113.     format(string, sizeof(string), "%d jogadores vivos", PlayersAlive);
  114.     SendClientMessageToAll(-1, string);
  115.  
  116.     new StrTDBomb[520];
  117.     format(StrTDBomb, sizeof(StrTDBomb), "%s esta com a bomba", pName(playerid));
  118.     TextDrawSetString(BombTagTD[2], StrTDBomb);
  119.    
  120.     if(IsValidObject(PlayerParticle[playerid])) DestroyObject(PlayerParticle[playerid]);
  121.     PlayerParticle[playerid] = CreateObject(18728, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  122.     AttachObjectToPlayer(PlayerParticle[playerid], playerid, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  123.     SetTimerEx("UpdateBombCountdown", 1000, false, "i", playerid);
  124. }
  125.  
  126. forward UpdateBombCountdown(playerid);
  127. public UpdateBombCountdown(playerid) {
  128.     if(BombCountdown[playerid] > 0) {
  129.         BombCountdown[playerid]--;
  130.  
  131.         if(IsPlayerInAnyVehicle(playerid)) {
  132.             new vehicleid = GetPlayerVehicleID(playerid);
  133.             foreach(new i : Player) {
  134.                 if(i != playerid && !HasBomb[i] && IsPlayerInAnyVehicle(i)) {
  135.                     new targetVehicle = GetPlayerVehicleID(i);
  136.                     if(GetVehicleDistanceFromVehicle(vehicleid, targetVehicle) < 6.0) {
  137.                         TransferBomb(playerid, i);
  138.                         return 1;
  139.                     }
  140.                 }
  141.             }
  142.         }
  143.  
  144.         new StrTDBomb[32];
  145.         format(StrTDBomb, sizeof(StrTDBomb), "%d", BombCountdown[playerid]);
  146.         TextDrawSetString(BombTagTD[1], StrTDBomb);
  147.         SetTimerEx("UpdateBombCountdown", 1000, false, "i", playerid);
  148.     } else {
  149.         new Float:x, Float:y, Float:z;
  150.         GetPlayerPos(playerid, x, y, z);
  151.         CreateExplosion(x, y, z, 7, 10.0);
  152.        
  153.         HasBomb[playerid] = false;
  154.         if(IsValidObject(PlayerParticle[playerid])) {
  155.             DestroyObject(PlayerParticle[playerid]);
  156.         }
  157.        
  158.         PlayersAlive--;
  159.        
  160.         new string[128];
  161.         format(string, sizeof(string), "%s foi eliminado! %d jogadores continuam vivos", pName(playerid), PlayersAlive);
  162.         SendClientMessageToAll(C_RED, string);
  163.         TextDrawHideForPlayer(playerid, BombTagTD[0]);
  164.         TextDrawHideForPlayer(playerid, BombTagTD[1]);
  165.         TextDrawHideForPlayer(playerid, BombTagTD[2]);
  166.  
  167.         if(PlayersAlive <= 1) {
  168.             foreach(new i : Player) {
  169.                 if(IsPlayerConnected(i) && i != playerid) {
  170.                     format(string, sizeof(string), "VENCEDOR: %s ganhou o Bomb Tag!", pName(i));
  171.                     SendClientMessageToAll(0xFFD700FF, string);
  172.                     TextDrawHideForPlayer(i, BombTagTD[0]);
  173.                     TextDrawHideForPlayer(i, BombTagTD[1]);
  174.                     TextDrawHideForPlayer(i, BombTagTD[2]);
  175.                     HasBomb[i] = false;
  176.                     if(IsValidObject(PlayerParticle[i])) {
  177.                         DestroyObject(PlayerParticle[i]);
  178.                     }
  179.                     break;
  180.                 }
  181.             }
  182.         } else {
  183.             new candidates[MAX_PLAYERS], candidateCount = 0;
  184.             foreach(new i : Player) {
  185.                 if(IsPlayerConnected(i) && i != playerid && !HasBomb[i]) {
  186.                     candidates[candidateCount++] = i;
  187.                 }
  188.             }
  189.             if(candidateCount > 0) {
  190.                 new randomPlayer = candidates[random(candidateCount)];
  191.                 StartBombCountdown(randomPlayer);
  192.             }
  193.         }
  194.     }
  195.     return 1;
  196. }
  197.  
  198. public OnPlayerDisconnect(playerid, reason)
  199. {
  200.     if(HasBomb[playerid]) {
  201.         HasBomb[playerid] = false;
  202.         if(IsValidObject(PlayerParticle[playerid])) {
  203.             DestroyObject(PlayerParticle[playerid]);
  204.         }
  205.        
  206.         PlayersAlive--;
  207.        
  208.         new string[128];
  209.         format(string, sizeof(string), "%s desconectou e foi eliminado! %d jogadores continuam vivos", pName(playerid), PlayersAlive);
  210.         SendClientMessageToAll(C_RED, string);
  211.         TextDrawHideForPlayer(playerid, BombTagTD[0]);
  212.         TextDrawHideForPlayer(playerid, BombTagTD[1]);
  213.         TextDrawHideForPlayer(playerid, BombTagTD[2]);
  214.    
  215.         if(PlayersAlive <= 1) {
  216.             foreach(new i : Player) {
  217.                 if(IsPlayerConnected(i) && i != playerid) {
  218.                     format(string, sizeof(string), "VENCEDOR: %s ganhou o Bomb Tag!", pName(i));
  219.                     SendClientMessageToAll(0xFFD700FF, string);
  220.                     TextDrawHideForPlayer(i, BombTagTD[0]);
  221.                     TextDrawHideForPlayer(i, BombTagTD[1]);
  222.                     TextDrawHideForPlayer(i, BombTagTD[2]);
  223.                     HasBomb[i] = false;
  224.                     if(IsValidObject(PlayerParticle[i])) {
  225.                         DestroyObject(PlayerParticle[i]);
  226.                     }
  227.                     break;
  228.                 }
  229.             }
  230.         } else {
  231.             new candidates[MAX_PLAYERS], candidateCount = 0;
  232.             foreach(new i : Player) {
  233.                 if(IsPlayerConnected(i) && i != playerid && !HasBomb[i]) {
  234.                     candidates[candidateCount++] = i;
  235.                 }
  236.             }
  237.             if(candidateCount > 0) {
  238.                 new randomPlayer = candidates[random(candidateCount)];
  239.                 StartBombCountdown(randomPlayer);
  240.             }
  241.         }
  242.     }
  243.     return 1;
  244. }
  245.  
  246. stock EliminatedBombTag(playerid)
  247. {
  248.     HasBomb[playerid] = false;
  249.     if(IsValidObject(PlayerParticle[playerid])) {
  250.         DestroyObject(PlayerParticle[playerid]);
  251.     }
  252.    
  253.     PlayersAlive--;
  254.    
  255.     new string[128];
  256.     format(string, sizeof(string), "%s foi eliminado! %d jogadores continuam vivos", pName(playerid), PlayersAlive);
  257.     SendClientMessageToAll(C_RED, string);
  258.     TextDrawHideForPlayer(playerid, BombTagTD[0]);
  259.     TextDrawHideForPlayer(playerid, BombTagTD[1]);
  260.     TextDrawHideForPlayer(playerid, BombTagTD[2]);
  261.  
  262.     if(PlayersAlive <= 1) {
  263.         foreach(new i : Player) {
  264.             if(IsPlayerConnected(i) && i != playerid) {
  265.                 format(string, sizeof(string), "VENCEDOR: %s ganhou o Bomb Tag!", pName(i));
  266.                 SendClientMessageToAll(0xFFD700FF, string);
  267.                 TextDrawHideForPlayer(i, BombTagTD[0]);
  268.                 TextDrawHideForPlayer(i, BombTagTD[1]);
  269.                 TextDrawHideForPlayer(i, BombTagTD[2]);
  270.                 HasBomb[i] = false;
  271.                 if(IsValidObject(PlayerParticle[i])) {
  272.                     DestroyObject(PlayerParticle[i]);
  273.                 }
  274.                 break;
  275.             }
  276.         }
  277.     } else {
  278.         new candidates[MAX_PLAYERS], candidateCount = 0;
  279.         foreach(new i : Player) {
  280.             if(IsPlayerConnected(i) && i != playerid && !HasBomb[i]) {
  281.                 candidates[candidateCount++] = i;
  282.             }
  283.         }
  284.         if(candidateCount > 0) {
  285.             new randomPlayer = candidates[random(candidateCount)];
  286.             StartBombCountdown(randomPlayer);
  287.         }
  288.     }
  289. }
  290.  
  291. stock TransferBomb(from, to) {
  292.     HasBomb[from] = false;
  293.     HasBomb[to] = true;
  294.     BombCountdown[to] = BombCountdown[from];
  295.  
  296.     new string[128];
  297.     format(string, sizeof(string), "%s transferiu a bomba para %s!", pName(from), pName(to));
  298.     SendClientMessageToAll(C_RED, string);
  299.  
  300.     new StrTDBomb[520];
  301.     format(StrTDBomb, sizeof(StrTDBomb), "%s esta com a bomba", pName(to));
  302.     TextDrawSetString(BombTagTD[2], StrTDBomb);
  303.  
  304.     if(IsValidObject(PlayerParticle[from])) DestroyObject(PlayerParticle[from]);
  305.     PlayerParticle[to] = CreateObject(18728, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  306.     AttachObjectToPlayer(PlayerParticle[to], to, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
  307.     SetTimerEx("UpdateBombCountdown", 1000, false, "i", to);
  308. }
  309.  
  310. CMD:bombtag(playerid, params[]) {
  311.     PlayersAlive = 0;
  312.     foreach(new i : Player) {
  313.         if(IsPlayerConnected(i)) PlayersAlive++;
  314.     }
  315.    
  316.     if(PlayersAlive < 2) return SendClientMessage(playerid, -1, "Necessário pelo menos 2 jogadores!");
  317.    
  318.     StartBombCountdown(playerid);
  319.     return 1;
  320. }
  321.  
  322. CMD:veh(playerid, params[])
  323. {
  324.     new vehicleid, Float:x, Float:y, Float:z, Float:a;
  325.    
  326.     if(sscanf(params, "i", vehicleid)) {
  327.         SendClientMessage(playerid, -1, "Uso: /veh [id do veículo]");
  328.         return 1;
  329.     }
  330.    
  331.     if(vehicleid < 400 || vehicleid > 611) {
  332.         SendClientMessage(playerid, -1, "ID de veículo inválido (use entre 400-611)");
  333.         return 1;
  334.     }
  335.    
  336.     GetPlayerPos(playerid, x, y, z);
  337.     GetPlayerFacingAngle(playerid, a);
  338.    
  339.     new vehicle = CreateVehicle(vehicleid, x, y, z, a, -1, -1, -1);
  340.     PutPlayerInVehicle(playerid, vehicle, 0);
  341.    
  342.     new string[128];
  343.     format(string, sizeof(string), "Você criou um veículo ID: %d", vehicleid);
  344.     SendClientMessage(playerid, -1, string);
  345.     return 1;
  346. }
  347.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement