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 <sscanf2>
- #include <zcmd> // ZCMD é usado para comandos, substitui o cmdtextdraw
- #include <YSI_Data\y_iterate> // esse include é necessário para o foreach ou outro include foreach
- // Cores
- #define C_RED 0xFF0000C8
- // Textdraw
- new Text:BombTagTD[3];
- public OnFilterScriptInit()
- {
- BombTagTD[0] = TextDrawCreate(567.000000, 186.000000, "Explode");
- TextDrawFont(BombTagTD[0], 2);
- TextDrawLetterSize(BombTagTD[0], 0.341666, 2.200000);
- TextDrawTextSize(BombTagTD[0], 633.000000, 92.000000);
- TextDrawSetOutline(BombTagTD[0], 1);
- TextDrawSetShadow(BombTagTD[0], 1);
- TextDrawAlignment(BombTagTD[0], 1);
- TextDrawColor(BombTagTD[0], -16776961);
- TextDrawBackgroundColor(BombTagTD[0], 255);
- TextDrawBoxColor(BombTagTD[0], 50);
- TextDrawUseBox(BombTagTD[0], true);
- TextDrawSetProportional(BombTagTD[0], true);
- TextDrawSetSelectable(BombTagTD[0], false);
- BombTagTD[1] = TextDrawCreate(601.000000, 210.000000, " ");
- TextDrawFont(BombTagTD[1], 3);
- TextDrawLetterSize(BombTagTD[1], 0.554166, 2.449999);
- TextDrawTextSize(BombTagTD[1], 400.000000, 17.000000);
- TextDrawSetOutline(BombTagTD[1], 2);
- TextDrawSetShadow(BombTagTD[1], 1);
- TextDrawAlignment(BombTagTD[1], 2);
- TextDrawColor(BombTagTD[1], 1097458175);
- TextDrawBackgroundColor(BombTagTD[1], 255);
- TextDrawBoxColor(BombTagTD[1], 50);
- TextDrawUseBox(BombTagTD[1], false);
- TextDrawSetProportional(BombTagTD[1], true);
- TextDrawSetSelectable(BombTagTD[1], false);
- BombTagTD[2] = TextDrawCreate(228.000000, 421.000000, " ");
- TextDrawFont(BombTagTD[2], 3);
- TextDrawLetterSize(BombTagTD[2], 0.233333, 2.000000);
- TextDrawTextSize(BombTagTD[2], 400.000000, 17.000000);
- TextDrawSetOutline(BombTagTD[2], 1);
- TextDrawSetShadow(BombTagTD[2], 1);
- TextDrawAlignment(BombTagTD[2], 1);
- TextDrawColor(BombTagTD[2], 1296911871);
- TextDrawBackgroundColor(BombTagTD[2], 255);
- TextDrawBoxColor(BombTagTD[2], 50);
- TextDrawUseBox(BombTagTD[2], true);
- TextDrawSetProportional(BombTagTD[2], true);
- TextDrawSetSelectable(BombTagTD[2], false);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- // Stock pName - Retorna o nome do jogador
- stock pName(playerid)
- {
- new GetName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, GetName, sizeof(GetName));
- return GetName;
- }
- // Bomba Tag - Variables
- new bool:HasBomb[MAX_PLAYERS];
- new BombCountdown[MAX_PLAYERS];
- new PlayerParticle[MAX_PLAYERS];
- new PlayersAlive = 0;
- forward Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
- 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));
- }
- 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);
- }
- stock StartBombCountdown(playerid) {
- BombCountdown[playerid] = 30;
- HasBomb[playerid] = true;
- new string[128];
- format(string, sizeof(string), "O Jogador %s agora esta com a bomba! FUJA!", pName(playerid));
- SendClientMessageToAll(C_RED, string);
- foreach(new i : Player) {
- TextDrawShowForPlayer(i, BombTagTD[0]);
- TextDrawShowForPlayer(i, BombTagTD[1]);
- TextDrawShowForPlayer(i, BombTagTD[2]);
- }
- format(string, sizeof(string), "%d jogadores vivos", PlayersAlive);
- SendClientMessageToAll(-1, string);
- new StrTDBomb[520];
- format(StrTDBomb, sizeof(StrTDBomb), "%s esta com a bomba", pName(playerid));
- TextDrawSetString(BombTagTD[2], StrTDBomb);
- if(IsValidObject(PlayerParticle[playerid])) DestroyObject(PlayerParticle[playerid]);
- 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);
- }
- forward UpdateBombCountdown(playerid);
- public UpdateBombCountdown(playerid) {
- if(BombCountdown[playerid] > 0) {
- BombCountdown[playerid]--;
- if(IsPlayerInAnyVehicle(playerid)) {
- new vehicleid = GetPlayerVehicleID(playerid);
- foreach(new i : Player) {
- if(i != playerid && !HasBomb[i] && IsPlayerInAnyVehicle(i)) {
- new targetVehicle = GetPlayerVehicleID(i);
- if(GetVehicleDistanceFromVehicle(vehicleid, targetVehicle) < 6.0) {
- TransferBomb(playerid, i);
- return 1;
- }
- }
- }
- }
- new StrTDBomb[32];
- format(StrTDBomb, sizeof(StrTDBomb), "%d", BombCountdown[playerid]);
- TextDrawSetString(BombTagTD[1], StrTDBomb);
- SetTimerEx("UpdateBombCountdown", 1000, false, "i", playerid);
- } else {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- CreateExplosion(x, y, z, 7, 10.0);
- HasBomb[playerid] = false;
- if(IsValidObject(PlayerParticle[playerid])) {
- DestroyObject(PlayerParticle[playerid]);
- }
- PlayersAlive--;
- new string[128];
- format(string, sizeof(string), "%s foi eliminado! %d jogadores continuam vivos", pName(playerid), PlayersAlive);
- SendClientMessageToAll(C_RED, string);
- TextDrawHideForPlayer(playerid, BombTagTD[0]);
- TextDrawHideForPlayer(playerid, BombTagTD[1]);
- TextDrawHideForPlayer(playerid, BombTagTD[2]);
- if(PlayersAlive <= 1) {
- foreach(new i : Player) {
- if(IsPlayerConnected(i) && i != playerid) {
- format(string, sizeof(string), "VENCEDOR: %s ganhou o Bomb Tag!", pName(i));
- SendClientMessageToAll(0xFFD700FF, string);
- TextDrawHideForPlayer(i, BombTagTD[0]);
- TextDrawHideForPlayer(i, BombTagTD[1]);
- TextDrawHideForPlayer(i, BombTagTD[2]);
- HasBomb[i] = false;
- if(IsValidObject(PlayerParticle[i])) {
- DestroyObject(PlayerParticle[i]);
- }
- break;
- }
- }
- } else {
- new candidates[MAX_PLAYERS], candidateCount = 0;
- foreach(new i : Player) {
- if(IsPlayerConnected(i) && i != playerid && !HasBomb[i]) {
- candidates[candidateCount++] = i;
- }
- }
- if(candidateCount > 0) {
- new randomPlayer = candidates[random(candidateCount)];
- StartBombCountdown(randomPlayer);
- }
- }
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(HasBomb[playerid]) {
- HasBomb[playerid] = false;
- if(IsValidObject(PlayerParticle[playerid])) {
- DestroyObject(PlayerParticle[playerid]);
- }
- PlayersAlive--;
- new string[128];
- format(string, sizeof(string), "%s desconectou e foi eliminado! %d jogadores continuam vivos", pName(playerid), PlayersAlive);
- SendClientMessageToAll(C_RED, string);
- TextDrawHideForPlayer(playerid, BombTagTD[0]);
- TextDrawHideForPlayer(playerid, BombTagTD[1]);
- TextDrawHideForPlayer(playerid, BombTagTD[2]);
- if(PlayersAlive <= 1) {
- foreach(new i : Player) {
- if(IsPlayerConnected(i) && i != playerid) {
- format(string, sizeof(string), "VENCEDOR: %s ganhou o Bomb Tag!", pName(i));
- SendClientMessageToAll(0xFFD700FF, string);
- TextDrawHideForPlayer(i, BombTagTD[0]);
- TextDrawHideForPlayer(i, BombTagTD[1]);
- TextDrawHideForPlayer(i, BombTagTD[2]);
- HasBomb[i] = false;
- if(IsValidObject(PlayerParticle[i])) {
- DestroyObject(PlayerParticle[i]);
- }
- break;
- }
- }
- } else {
- new candidates[MAX_PLAYERS], candidateCount = 0;
- foreach(new i : Player) {
- if(IsPlayerConnected(i) && i != playerid && !HasBomb[i]) {
- candidates[candidateCount++] = i;
- }
- }
- if(candidateCount > 0) {
- new randomPlayer = candidates[random(candidateCount)];
- StartBombCountdown(randomPlayer);
- }
- }
- }
- return 1;
- }
- stock EliminatedBombTag(playerid)
- {
- HasBomb[playerid] = false;
- if(IsValidObject(PlayerParticle[playerid])) {
- DestroyObject(PlayerParticle[playerid]);
- }
- PlayersAlive--;
- new string[128];
- format(string, sizeof(string), "%s foi eliminado! %d jogadores continuam vivos", pName(playerid), PlayersAlive);
- SendClientMessageToAll(C_RED, string);
- TextDrawHideForPlayer(playerid, BombTagTD[0]);
- TextDrawHideForPlayer(playerid, BombTagTD[1]);
- TextDrawHideForPlayer(playerid, BombTagTD[2]);
- if(PlayersAlive <= 1) {
- foreach(new i : Player) {
- if(IsPlayerConnected(i) && i != playerid) {
- format(string, sizeof(string), "VENCEDOR: %s ganhou o Bomb Tag!", pName(i));
- SendClientMessageToAll(0xFFD700FF, string);
- TextDrawHideForPlayer(i, BombTagTD[0]);
- TextDrawHideForPlayer(i, BombTagTD[1]);
- TextDrawHideForPlayer(i, BombTagTD[2]);
- HasBomb[i] = false;
- if(IsValidObject(PlayerParticle[i])) {
- DestroyObject(PlayerParticle[i]);
- }
- break;
- }
- }
- } else {
- new candidates[MAX_PLAYERS], candidateCount = 0;
- foreach(new i : Player) {
- if(IsPlayerConnected(i) && i != playerid && !HasBomb[i]) {
- candidates[candidateCount++] = i;
- }
- }
- if(candidateCount > 0) {
- new randomPlayer = candidates[random(candidateCount)];
- StartBombCountdown(randomPlayer);
- }
- }
- }
- stock TransferBomb(from, to) {
- HasBomb[from] = false;
- HasBomb[to] = true;
- BombCountdown[to] = BombCountdown[from];
- new string[128];
- format(string, sizeof(string), "%s transferiu a bomba para %s!", pName(from), pName(to));
- SendClientMessageToAll(C_RED, string);
- new StrTDBomb[520];
- format(StrTDBomb, sizeof(StrTDBomb), "%s esta com a bomba", pName(to));
- TextDrawSetString(BombTagTD[2], StrTDBomb);
- if(IsValidObject(PlayerParticle[from])) DestroyObject(PlayerParticle[from]);
- PlayerParticle[to] = CreateObject(18728, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- AttachObjectToPlayer(PlayerParticle[to], to, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- SetTimerEx("UpdateBombCountdown", 1000, false, "i", to);
- }
- CMD:bombtag(playerid, params[]) {
- PlayersAlive = 0;
- foreach(new i : Player) {
- if(IsPlayerConnected(i)) PlayersAlive++;
- }
- if(PlayersAlive < 2) return SendClientMessage(playerid, -1, "Necessário pelo menos 2 jogadores!");
- StartBombCountdown(playerid);
- return 1;
- }
- CMD:veh(playerid, params[])
- {
- new vehicleid, Float:x, Float:y, Float:z, Float:a;
- if(sscanf(params, "i", vehicleid)) {
- SendClientMessage(playerid, -1, "Uso: /veh [id do veículo]");
- return 1;
- }
- if(vehicleid < 400 || vehicleid > 611) {
- SendClientMessage(playerid, -1, "ID de veículo inválido (use entre 400-611)");
- return 1;
- }
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, a);
- new vehicle = CreateVehicle(vehicleid, x, y, z, a, -1, -1, -1);
- PutPlayerInVehicle(playerid, vehicle, 0);
- new string[128];
- format(string, sizeof(string), "Você criou um veículo ID: %d", vehicleid);
- SendClientMessage(playerid, -1, string);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement