SA-MP Forums Archive
[Include] Server-Side Health ― Sem mais s0rvete nem cl3o - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+----- Forum: Lançamentos/Releases (https://sampforum.blast.hk/forumdisplay.php?fid=56)
+----- Thread: [Include] Server-Side Health ― Sem mais s0rvete nem cl3o (/showthread.php?tid=319605)



Server-Side Health ― Sem mais s0rvete nem cl3o - steki. - 19.02.2012

Lй Introduction

Ah, seilб foda-se isso.

Lй Utiliser

No topo do GM, DE EXTREMA IMPORTВNCIA:
pawn Code:
#include <a_samp>
#include <AMINHAINCLUDE>
Sу.

E tem uma callback:
pawn Code:
forward OnPlayerHealthHacks(playerid, Float:serverhealth, Float:clienthealth, Float:serverarmour, Float:clientarmour);
Lй Transfйrer
pawn Code:
#if defined _server_health
    #endinput
#else
    #define _server_health
#endif

#define lazyfunction%0(%1) forward%0(%1); public%0(%1)

enum _SH_PINFO
{
    Float:shPlayerHealth,
    Float:shPlayerArmour
}
new _sg_PlayerInfo[MAX_PLAYERS][_SH_PINFO];
forward OnPlayerHealthHacks(playerid, Float:serverhealth, Float:clienthealth, Float:serverarmour, Float:clientarmour);



public OnPlayerSpawn(playerid)
{
    _sg_PlayerInfo[playerid][shPlayerHealth] = 100.0;
    _sg_PlayerInfo[playerid][shPlayerArmour] = 0.0;
    if (funcidx("SH_OnPlayerSpawn") != -1)
    {
        return CallLocalFunction("SH_OnPlayerSpawn", "i", playerid);
    }
    return 1;
}
#if defined _ALS_OnPlayerSpawn
  #undef OnPlayerSpawn
#else
  #define _ALS_OnPlayerSpawn
#endif
#define OnPlayerSpawn SH_OnPlayerSpawn
forward SH_OnPlayerSpawn(playerid);

/* */

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    _sg_PlayerInfo[playerid][shPlayerArmour] -= amount;

    if(_sg_PlayerInfo[playerid][shPlayerArmour] < 0)
    {
        _sg_PlayerInfo[playerid][shPlayerArmour] = 0.0;
        _sg_PlayerInfo[playerid][shPlayerHealth] += _sg_PlayerInfo[playerid][shPlayerArmour];
    }

    SetPlayerHealth(playerid, _sg_PlayerInfo[playerid][shPlayerHealth]);
    SetPlayerArmour(playerid, _sg_PlayerInfo[playerid][shPlayerArmour]);

    new Float:client_Health; GetPlayerHealth(playerid, client_Health);
    new Float:client_Armour; GetPlayerArmour(playerid, client_Armour);
    if(_sg_PlayerInfo[playerid][shPlayerHealth] != client_Health || _sg_PlayerInfo[playerid][shPlayerArmour] != client_Armour)
    {
        if(funcidx("OnPlayerHealthHacks") != -1)
            CallRemoteFunction("OnPlayerHealthHacks", "iffff", playerid, _sg_PlayerInfo[playerid][shPlayerHealth], client_Health, _sg_PlayerInfo[playerid][shPlayerArmour], client_Armour);
    }

    if (funcidx("SH_OnPlayerTakeDamage") != -1)
    {
        return CallLocalFunction("SH_OnPlayerTakeDamage", "iifi", playerid, issuerid, amount, weaponid);
    }
    return 1;
}
#if defined _ALS_OnPlayerTakeDamage
  #undef OnPlayerTakeDamage
#else
  #define _ALS_OnPlayerTakeDamage
#endif
#define OnPlayerTakeDamage SH_OnPlayerTakeDamage
forward SH_OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid);

/* */

lazyfunction SH_GetPlayerHealth(playerid, &Float:health)
{
    health = _sg_PlayerInfo[playerid][shPlayerHealth];
    return 1;
}
#define GetPlayerHealth SG_GetPlayerHealth

lazyfunction SH_SetPlayerHealth(playerid, Float:health)
{
    _sg_PlayerInfo[playerid][shPlayerHealth] = health;
    SetPlayerHealth(playerid, health);
    return 1;
}
#define SetPlayerHealth SH_SetPlayerHealth

lazyfunction SH_GetPlayerArmour(playerid, &Float:armour)
{
    armour = _sg_PlayerInfo[playerid][shPlayerArmour];
    return 1;
}
#define GetPlayerArmour SH_GetPlayerArmour

lazyfunction SG_SetPlayerArmour(playerid, Float:armour)
{
    _sg_PlayerInfo[playerid][shPlayerArmour] = armour;
    SetPlayerArmour(playerid, armour);
    return 1;
}
#define SetPlayerArmour SH_SetPlayerArmour

Apenas 0.3d+ e mantenham os crйditos, crianзas.


Re: Server-Side Health ― Sem mais s0rvete nem cl3o - Bosma_cmd - 19.02.2012

Bom sistema, mas recomendo para quem for usar sempre banir o jogador na hora que a OnPlayerHealthHacks for chamada, pois tem uns cleos ae que trava a HP do cara, nem sethp muda a health dele (porйm no /slap ou /explode perde normal) e tem o cleo dos 5ps tmb, que a OnPlayerTakeDamage nгo й chamada mesmo quando o cara toma dano, enfim, cleo й foda de pegar...


Re: Server-Side Health ― Sem mais s0rvete nem cl3o - steki. - 19.02.2012

Eu tenho algumas dъvidas sobre esse sistema. Eu nгo tive a chance de testar a callback 100%.
(Eu nгo sei ao certo se o damage na OnPlayerTakeDamage й o damage que ele deveria tomar ou o que ele tomou).

Mas dб pra resolver isso rapidamente com uma simples array com o damage das armas.


Re: Server-Side Health ― Sem mais s0rvete nem cl3o - RashiiD - 26.02.2012

Stewie , poderia me tirar uma duvida?

Nгo sei se entendi bem.. Mas..

Oque a include faz й verificar se tal player perdeu HP quando levou dano, caso nгo ele chama a OnPlayerHealthHacks? Desculpe se a pergunta for ignorante.


Re: Server-Side Health ― Sem mais s0rvete nem cl3o - |_MeGaTroN_| - 26.02.2012

Uma duvida e se o player estiver esc o outro atirar ele vais ser ban/kick ?


Respuesta: Server-Side Health ― Sem mais s0rvete nem cl3o - Luciano* - 26.02.2012

Explica melhor o que isso faz.. fazendo favor rs


Re: Server-Side Health ― Sem mais s0rvete nem cl3o - Shadoww5 - 27.02.2012

pawn Code:
if(_sg_PlayerInfo[playerid][shPlayerArmour] < 0)
    {
        _sg_PlayerInfo[playerid][shPlayerArmour] = 0.0;
        _sg_PlayerInfo[playerid][shPlayerHealth] += _sg_PlayerInfo[playerid][shPlayerArmour];
    }
Nгo deveria ser assim ?

pawn Code:
if(_sg_PlayerInfo[playerid][shPlayerArmour] < 0)
    {
        _sg_PlayerInfo[playerid][shPlayerHealth] += _sg_PlayerInfo[playerid][shPlayerArmour];
        _sg_PlayerInfo[playerid][shPlayerArmour] = 0.0;
    }
E outra coisa: De qualquer forma, se o jogador atingido nгo estiver usando cheat, a vida dele nгo serб esta que foi setada e sim a correta (entendeu ? '-').


Re: Server-Side Health ― Sem mais s0rvete nem cl3o - steki. - 28.02.2012

1 - Certo.
2 - Deixando de lado o fato que a include simplesmente nгo funciona (deve-se usar OPGD), Nгo terб uma 'vida dele'. Й uma vida client side. Ou isso ou vocк explicou bem mal :$


Re: Server-Side Health ― Sem mais s0rvete nem cl3o - CyNiC - 28.02.2012

O jogador pode ganhar health por via de mбquinas de refrigerante e lanchonetes causando a diferenзa que й checada no callback/sendo confundido com cheater.


Re: Server-Side Health ― Sem mais s0rvete nem cl3o - Mattos - 03.03.2012

Eh so verificar se no momento ou proximo ao momento de ganhar vida GetPlayerSpecialAction == 23 e configurar isso como excessao pra nao banir pessoas erradas... https://sampwiki.blast.hk/wiki/GetPlayerSpecialAction