10/11/2021 20:56
Quem já jogou em um servidor Android pelo samp launcher está ciente que quando a "OnPlayerDeath" e chamada o Client e fechado na hora, isso ocorre devido a uma falha nos rpcs de morte, mais com um simples código podemos reverter essa situação.
Bom aproveito.
Código:
#include <a_samp>
new Float:G_Health[MAX_PLAYERS];
stock SetPlayerHealthEx(playerid, Float:amount)
{
if (amount > 150.0)
{
SetPlayerHealth(playerid, 150.0);
G_Health[playerid] = 150.0;
}
else if (amount <= 0.0) // You died
{
SetPlayerHealth(playerid, 25.0);
G_Health[playerid] = 0.0;
}
else
{
G_Health[playerid] = float(floatround(amount, floatround_floor));
SetPlayerHealth(playerid, float(floatround(amount, floatround_floor)));
}
return 1;
}
public OnPlayerConnect(playerid)
{
G_Health[playerid] = 150.0;
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
if (damagedid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID)
{
if ((G_Health[damagedid] - amount) < 1.0)
{
SendClientMessage(playerid, -1, "You died");
}
else
{
SetPlayerHealthEx(damagedid, G_Health[damagedid] - amount);
}
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if (issuerid == INVALID_PLAYER_ID)
{
if ((G_Health[playerid] - amount) < 1.0)
{
// Code here example: SendClientMessage(playerid, -1, "You died.");
}
else
{
G_Health[playerid] -= amount;
}
}
return 1;
}
Bom aproveito.
Programador profissional de pawn. Discord: Gabrieel#3270