Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Sistema de Bomba Tag criado por furiadanoite
- Discord: furiadanoitebr / !FuriaDaNoiteBR#6666
- Cada jogador que estiver com a bomba deve transferi-la para outro jogador ao encostar nele, para sobreviver.
- Quem estiver com a bomba quando o tempo acabar, explode e perde uma vida. O último jogador vivo vence!
- */
- #define SAMP_COMPAT
- #include <open.mp> // Open.mp ou <samp> é usado para compatibilidade com o SA:MP
- #include <zcmd> // ZCMD é usado para comando
- #include <YSI_Data\y_iterate> // esse include é necessário para o foreach ou outro include foreach
- // Bomba Tag - Jogo da Bomba
- new bool:HasBomb[MAX_PLAYERS];
- // new bool:BombGameActive = false; // Bomba Tag ativo - usado para verificar se o jogo está em andamento
- new BombCountdown[MAX_PLAYERS];
- new PlayerParticle[MAX_PLAYERS];
- // Cores
- #define C_RED 0xFF0000C8
- public OnFilterScriptInit()
- {
- SetTimer("CheckVehicleCollisions", 500, true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- // Limpa partículas e timers ao descarregar o filterscript
- for(new i = 0; i < MAX_PLAYERS; i++) {
- HasBomb[i] = false;
- BombCountdown[i] = 0;
- if(IsValidObject(PlayerParticle[i])) {
- DestroyObject(PlayerParticle[i]);
- PlayerParticle[i] = INVALID_OBJECT_ID;
- }
- }
- return 1;
- }
- // Stock pName - Retorna o nome do jogador
- stock pName(playerid)
- {
- new GetName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, GetName, sizeof(GetName));
- return GetName;
- }
- // Declaração da funçao antes do uso
- forward Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
- // Definição da funçao antes de qualquer uso
- stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
- {
- return floatsqroot((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));
- }
- // Iniciar contagem regressiva da bomba para um jogador
- stock StartBombCountdown(playerid) {
- BombCountdown[playerid] = 30;
- HasBomb[playerid] = true;
- new string[64];
- format(string, sizeof(string), "~r~BOMBA ATIVA!~n~Explodira em: %d", BombCountdown[playerid]);
- GameTextForAll(string, 1000, 3);
- // Destroi partícula anterior, se houver
- if(IsValidObject(PlayerParticle[playerid])) {
- DestroyObject(PlayerParticle[playerid]);
- }
- // Cria a partícula e anexa ao jogador
- PlayerParticle[playerid] = CreateObject(18728, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- AttachObjectToPlayer(PlayerParticle[playerid], playerid, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- SetTimerEx("UpdateBombCountdown", 1000, false, "i", playerid);
- }
- // Retorna a distância entre dois veículos
- stock Float:GetVehicleDistanceFromVehicle(vehicle1, vehicle2) {
- new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
- GetVehiclePos(vehicle1, x1, y1, z1);
- GetVehiclePos(vehicle2, x2, y2, z2);
- return GetDistanceBetweenPoints(x1, y1, z1, x2, y2, z2);
- }
- // Atualizar o temporizador da contagem regressiva da bomba
- forward UpdateBombCountdown(playerid);
- public UpdateBombCountdown(playerid) {
- if(BombCountdown[playerid] > 0) {
- BombCountdown[playerid]--;
- if(IsPlayerInAnyVehicle(playerid)) {
- new vehicleid = GetPlayerVehicleID(playerid);
- new Float:vHealth;
- GetVehicleHealth(vehicleid, vHealth);
- // Verifica se o veículo foi destruído
- if(vHealth < 250.0) {
- new closestPlayer = INVALID_PLAYER_ID;
- new Float:minDist = 999999.0;
- new Float:px, Float:py, Float:pz;
- GetPlayerPos(playerid, px, py, pz);
- foreach(new i : Player) {
- if(i != playerid && !HasBomb[i]) {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(i, x, y, z);
- new Float:dist = GetDistanceBetweenPoints(px, py, pz, x, y, z);
- if(dist < minDist) {
- minDist = dist;
- closestPlayer = i;
- }
- }
- }
- if(closestPlayer != INVALID_PLAYER_ID) {
- HasBomb[playerid] = false;
- HasBomb[closestPlayer] = true;
- BombCountdown[closestPlayer] = BombCountdown[playerid];
- BombCountdown[playerid] = 0;
- new string[128];
- format(string, sizeof(string), "> {ffffff}O jogador {ff2400}%s {ffffff}transferiu a bomba para {ff2400}%s {ffffff}apos seu veiculo ser destruido!", pName(playerid), pName(closestPlayer));
- SendClientMessageToAll(C_RED, string, 0);
- // Remove partícula antiga
- if(IsValidObject(PlayerParticle[playerid])) DestroyObject(PlayerParticle[playerid]);
- // Cria nova partícula
- if(IsValidObject(PlayerParticle[closestPlayer])) DestroyObject(PlayerParticle[closestPlayer]);
- PlayerParticle[closestPlayer] = CreateObject(18728, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- AttachObjectToPlayer(PlayerParticle[closestPlayer], closestPlayer, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- SetTimerEx("UpdateBombCountdown", 1000, false, "i", closestPlayer);
- return 1;
- }
- }
- // Verifica colisão entre veículos
- foreach(new i : Player) {
- if(i != playerid && IsPlayerInAnyVehicle(i) && !HasBomb[i]) {
- new targetVehicle = GetPlayerVehicleID(i);
- new Float:tHealth;
- GetVehicleHealth(targetVehicle, tHealth);
- if(GetVehicleDistanceFromVehicle(vehicleid, targetVehicle) < 8.0 && (vHealth < 1000.0 || tHealth < 1000.0)) {
- HasBomb[playerid] = false;
- HasBomb[i] = true;
- BombCountdown[i] = BombCountdown[playerid];
- BombCountdown[playerid] = 0;
- new string[128];
- format(string, sizeof(string), "> {ffffff}O jogador {ff2400}%s {ffffff}transferiu a bomba para {ff2400}%s!", pName(playerid), pName(i));
- SendClientMessageToAll(C_RED, string, 0);
- // Remove partícula antiga
- if(IsValidObject(PlayerParticle[playerid])) DestroyObject(PlayerParticle[playerid]);
- // Cria nova partícula
- if(IsValidObject(PlayerParticle[i])) DestroyObject(PlayerParticle[i]);
- PlayerParticle[i] = CreateObject(18728, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- AttachObjectToPlayer(PlayerParticle[i], i, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- SetTimerEx("UpdateBombCountdown", 1000, false, "i", i);
- return 1;
- }
- }
- }
- }
- // Mostrar contagem se não houve transferência
- new string[64];
- format(string, sizeof(string), "~r~BOMBA ATIVA!~n~Explodira em: %d", BombCountdown[playerid]);
- GameTextForAll(string, 1000, 3);
- SetTimerEx("UpdateBombCountdown", 1000, false, "i", playerid);
- } else {
- // Explosão da bomba
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- CreateExplosion(x, y, z, 7, 10.0);
- new string[128];
- format(string, sizeof(string), "> {ffffff}O jogador {ff2400}%s {ffffff}explodiu com a bomba!", pName(playerid));
- SendClientMessageToAll(C_RED, string, 0);
- HasBomb[playerid] = false;
- BombCountdown[playerid] = 0;
- // Remove partícula
- if(IsValidObject(PlayerParticle[playerid])) {
- DestroyObject(PlayerParticle[playerid]);
- PlayerParticle[playerid] = INVALID_OBJECT_ID;
- }
- }
- return 1;
- }
- // Comando para começar o jogo da bomba
- CMD:bombtag(playerid, params[]) {
- HasBomb[playerid] = true;
- StartBombCountdown(playerid);
- new string[128];
- format(string, sizeof(string), "> {ffffff}O admin {ff2400}%s {ffffff}iniciou o jogo da bomba! Fuja dele!", pName(playerid));
- SendClientMessageToAll(C_RED, string, 0);
- format(string, sizeof(string), "> {ffffff}Admin {ff2400}%s {ffffff}started bomb tag! Run from them!", pName(playerid));
- SendClientMessageToAll(C_RED, string, 1);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement