0% found this document useful (0 votes)
7 views3 pages

Message

The document is a script for a game mode that manages 3D text indicators for players in a multiplayer environment. It includes functionality for displaying player health and armor bars, updating indicators upon player actions, and hiding them after a specified duration. The script also handles player connection and disconnection events to manage the lifecycle of the indicators.

Uploaded by

elegatrp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Message

The document is a script for a game mode that manages 3D text indicators for players in a multiplayer environment. It includes functionality for displaying player health and armor bars, updating indicators upon player actions, and hiding them after a specified duration. The script also handles player connection and disconnection events to manage the lifecycle of the indicators.

Uploaded by

elegatrp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <a_samp>

#include <streamer>
#include <foreach>

#define NT_DISTANCE 25.0 // Distancia de los que ven la vida del jugador
#define OCULTAR_TIEMPO 5000 // El tiempo esta configurado a los 5 segundos

new Text3D:cIndicator[MAX_PLAYERS];
new PlayerTimers[MAX_PLAYERS];

public OnGameModeInit()
{
ShowNameTags(0); Quita los nametags(VIDA, CHALECO, NOMBRE)
return 1;
}

public OnPlayerConnect(playerid)
{
cIndicator[playerid] = CreateDynamic3DTextLabel("Cargando indicador...",
0xFFFFFFFF, 0.0, 0.0, 0.1, NT_DISTANCE, .attachedplayer = playerid, .testlos = 1);
PlayerTimers[playerid] = -1;
return 1;
}

public OnPlayerDisconnect(playerid, reason)


{
if (IsValidDynamic3DTextLabel(cIndicator[playerid]))
DestroyDynamic3DTextLabel(cIndicator[playerid]);

if (PlayerTimers[playerid] != -1)
KillTimer(PlayerTimers[playerid]);

return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)


{
ActualizarIndicadorJugador(playerid, true);

if (PlayerTimers[playerid] != -1)
{
KillTimer(PlayerTimers[playerid]);
}

PlayerTimers[playerid] = SetTimerEx("OcultarIndicador", OCULTAR_TIEMPO, false,


"i", playerid);
return 1;
}

forward OcultarIndicador(playerid);
public OcultarIndicador(playerid)
{
if (!IsPlayerConnected(playerid)) return;

new indicador[128], nombreJugador[MAX_PLAYER_NAME];


GetPlayerName(playerid, nombreJugador, sizeof(nombreJugador));
format(indicador, sizeof(indicador), "{%06x}%s {FFFFFF}(%i)",
GetPlayerColor(playerid) >>> 8, nombreJugador, playerid);
UpdateDynamic3DTextLabelText(cIndicator[playerid], 0xFFFFFFFF, indicador);
PlayerTimers[playerid] = -1;
}

stock ActualizarIndicadorJugador(playerid, bool:mostrarBarras)


{
if (!IsPlayerConnected(playerid)) return;

new indicador[128], nombreJugador[MAX_PLAYER_NAME], Float:armadura;


GetPlayerArmour(playerid, armadura);
GetPlayerName(playerid, nombreJugador, sizeof(nombreJugador));

if (mostrarBarras)
{
if (armadura > 1.0)
{
format(indicador, sizeof(indicador), "{%06x}%s {FFFFFF}(%i)\n{FFFFFF}
%s\n{FF0000}%s",
GetPlayerColor(playerid) >>> 8, nombreJugador, playerid,
ObtenerBarraArmadura(playerid), ObtenerBarraSalud(playerid));
}
else
{
format(indicador, sizeof(indicador), "{%06x}%s {FFFFFF}(%i)\
n{FF0000}%s",
GetPlayerColor(playerid) >>> 8, nombreJugador, playerid,
ObtenerBarraSalud(playerid));
}
}
else
{
format(indicador, sizeof(indicador), "{%06x}%s {FFFFFF}(%i)",
GetPlayerColor(playerid) >>> 8, nombreJugador, playerid);
}

UpdateDynamic3DTextLabelText(cIndicator[playerid], 0xFFFFFFFF, indicador);


}

stock ObtenerBarraSalud(playerid)
{
new barra[64];
new Float:HP;
GetPlayerHealth(playerid, HP);

if (HP == 100) barra = "||||||||||";


else if (HP >= 90) barra = "|||||||||{660000}|";
else if (HP >= 80) barra = "||||||||{660000}||";
else if (HP >= 70) barra = "|||||||{660000}|||";
else if (HP >= 60) barra = "||||||{660000}||||";
else if (HP >= 50) barra = "|||||{660000}|||||";
else if (HP >= 40) barra = "||||{660000}||||||";
else if (HP >= 30) barra = "|||{660000}|||||||";
else if (HP >= 20) barra = "||{660000}||||||||";
else if (HP >= 10) barra = "|{660000}|||||||||";
else barra = "{660000}||||||||||";

return barra;
}
stock ObtenerBarraArmadura(playerid)
{
new barra[64];
new Float:AR;
GetPlayerArmour(playerid, AR);

if (AR == 100) barra = "||||||||||";


else if (AR >= 90) barra = "|||||||||{666666}|";
else if (AR >= 80) barra = "||||||||{666666}||";
else if (AR >= 70) barra = "|||||||{666666}|||";
else if (AR >= 60) barra = "||||||{666666}||||";
else if (AR >= 50) barra = "|||||{666666}|||||";
else if (AR >= 40) barra = "||||{666666}||||||";
else if (AR >= 30) barra = "|||{666666}|||||||";
else if (AR >= 20) barra = "||{666666}||||||||";
else if (AR >= 10) barra = "|{666666}|||||||||";
else barra = "{666666}||||||||||";

return barra;
}

You might also like