GetPlayerHealth
#1

How I can do something like this:


[pawn]
new oldHealth,NewHealth;
SendClientMessageToAll(BLUE, %s changed his health from %d to %d",oldHealth,NewHealth);
return 1;
[pawn]
Reply
#2

Quote:
Originally Posted by Alex_Obando
Посмотреть сообщение
How I can do something like this:


[pawn]
new oldHealth,NewHealth;
SendClientMessageToAll(BLUE, %s changed his health from %d to %d",oldHealth,NewHealth);
return 1;
[pawn]
pawn Код:
//OnPlayerUpdate
    static
        Float: cHealth,
        Float: pHealth[MAX_PLAYERS];
    GetPlayerHealth(playerid, cHealth);
    if(cHealth != pHealth[playerid]) {
        OnPlayerHealthChange(playerid, pHealth[playerid], cHealth);
        pHealth[playerid] = cHealth;
    }
pawn Код:
OnPlayerHealthChange(playerid, Float: oldhealth, Float: newhealth) {
    new tmp[128];
    GetPlayerName(playerid, tmp, MAX_PLAYER_NAME);
    format(tmp, sizeof tmp, "%s changed his health from %.0f to %.0f", oldhealth, newhealth);
    SendClientMessageToAll(BLUE, tmp);
}
Use a timer instead of OnPlayerUpdate
Reply
#3

How to make it in my code?
pawn Код:
/* HHCheck - iPLEOMAX */

#include <a_samp>

new HHTimer[MAX_PLAYERS];
public OnFilterScriptInit()
{
        printf("                Alex Obando Castellanos                                         ");
        printf("                Anti Weapon Hack System                                         ");
        printf("                       -LOADED-                    ");

        return 1;
}
public OnPlayerSpawn( playerid ) { SetTimerEx("HealthCheck", 1000, false, "df", playerid , 100.0 ); }
public OnPlayerDeath( playerid ) { StopHealthCheck( playerid ); }
public OnPlayerDisconnect( playerid, reason ) { StopHealthCheck( playerid ); }

stock StopHealthCheck( playerid ) { return HealthCheck( playerid, -1337.1337 ); }

forward HealthCheck( playerid, Float:iHealth );
public HealthCheck( playerid, Float:iHealth )
{
    if( iHealth == -1337.1337 )
    {
       return KillTimer(HHTimer[playerid]);
    }
   
    new Float:cHealth; GetPlayerHealth( playerid, cHealth );

    if(cHealth > iHealth || cHealth > 101.0 || cHealth < -1.0) { Hacking( playerid ); HHTimer[playerid] = SetTimerEx("HealthCheck", 1000, false, "df", playerid, 100.0); }
    else { HHTimer[playerid] = SetTimerEx("HealthCheck", 100, false, "df", playerid, cHealth); }

    return true;
}
forward Hacking( playerid );
public Hacking( playerid )
{
    new hackername[MAX_PLAYER_NAME], hackmessage[80];
    new plrIP[16];
    GetPlayerName(playerid, hackername, sizeof(hackername));
    GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    format(hackmessage, sizeof(hackmessage), "%s [ID: %d] [IP: %s] is suspected of having Health Hacks %.0f to %.0f", hackername,playerid, plrIP);
    for( new i=0; i<MAX_PLAYERS; i++)
    {
    CallRemoteFunction("SendClientMessageToAdmins","isi",0xFF0000,hackmessage,1);
    }
    return true;
}
Reply
#4

#Bump
Reply
#5

pawn Код:
//OnPlayerUpdate
    static
        Float: cHealth,
        Float: pHealth[MAX_PLAYERS];
    GetPlayerHealth(playerid, cHealth);
    if(cHealth != pHealth[playerid]) {
        OnPlayerHealthChange(playerid, pHealth[playerid], cHealth);
        pHealth[playerid] = cHealth;
    }
pawn Код:
OnPlayerHealthChange(playerid, Float: oldhealth, Float: newhealth) {
    new tmp[128];
    GetPlayerName(playerid, tmp, MAX_PLAYER_NAME);
    format(tmp, sizeof tmp, "%s changed his health from %.0f to %.0f", oldhealth, newhealth);
    SendClientMessageToAll(BLUE, tmp);
}
How to add that above to this below:

pawn Код:
CMD:armourme(playerid, params[])
{
    if(dini_Int(PFile(playerid),"VipMember")<3)return SendClientMessage(playerid, red, "You must be Premium member to use this command");
    {
    SendClientMessage(playerid, red, "You must be Premium member to %.0f to %.0f", oldhealth, newhealth);
    SetPlayerArmour(playerid, 99);
    }
    return 1;
}
Reply
#6

pawn Код:
stock
    Float: gOldHealth[MAX_PLAYERS];
pawn Код:
OnPlayerHealthChange(playerid, Float: oldhealth, Float: newhealth) {
    gOldHealth[playerid] = oldhealth;
}
pawn Код:
CMD:armourme(playerid, params[])
{
    if(dini_Int(PFile(playerid),"VipMember")<3)return SendClientMessage(playerid, red, "You must be Premium member to use this command");
    {
        new
            string[64],
            Float: newhealth;
        GetPlayerHealth(playerid, newhealth);
        format(string, sizeof string, "You must be Premium member to %.0f to %.0f", gOldHealth[playerid], newhealth);
        SendClientMessage(playerid, red, string);
        SetPlayerArmour(playerid, 99.0);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)