[Ajuda] No-lag
#4

Seguinte: Primeiro de tudo, faзa um Backup de todo o seu cуdigo..

Depois: substitua sua Public por essa:

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    new Float: Dano;

    if (weaponid == 16 || weaponid == 34 || weaponid == 35 || weaponid == 38)
    {
        ApplyAnimation(damagedid, "PED", "DAM_STOMACH_FRMFT", 4.1, 0, 1, 1, 0, 1, 1);
        Tiros[damagedid] = 0;
    }
    if (weaponid == 24 || weaponid == 25 || weaponid == 27)
    {
        Tiros[damagedid]++;

        if (Tiros[damagedid] > 4)
        {
            ApplyAnimation(damagedid, "PED", "DAM_STOMACH_FRMFT", 4.1, 0, 1, 1, 0, 1, 1);
            Tiros[damagedid] = 0;
        }
    }
    if (weaponid == 29 || weaponid == 30 || weaponid == 31)
    {
        Tiros[damagedid]++;

        if (Tiros[damagedid] > 9)
        {
            ApplyAnimation(damagedid, "PED", "DAM_STOMACH_FRMFT", 4.1, 0, 1, 1, 0, 1, 1);
            Tiros[damagedid] = 0;
        }
    }

    amount /= 2; // Isso й o mesmo que amount = amount / 2;

    if (Colete[playerid] > 0)
    {
        if (amount > Colete[playerid])
        {
            Dano = amount - Colete[playerid];
            Vida[playerid] -= Dano; // Isso й o mesmo que Vida[playerid] = Vida[playerid] - Dano;

            SetPlayerArmour(damagedid, 0.0);
            SetPlayerHealth(damagedid, Vida[playerid]);

            return 1;
        }
        Colete[playerid] -= amount; // Isso й o mesmo que Colete[playerid] = Colete[playerid] - amount;
        SetPlayerArmour(damagedid, Colete[playerid]);
    }
    if (Colete[playerid] < 1)
    {
        Vida[playerid] -= amount; // Isso й o mesmo que Vida[playerid] = Vida[playerid] - amount;
        SetPlayerHealth(damagedid, Vida[playerid]);
    }
    return 1;
}
Terceiro:

Coloque isto aqui no topo do GM, junto com as outras News:

pawn Код:
new Float:Vida[MAX_PLAYERS]; // Esta variбvel armazenarб a Life do Player
new Float:Colete[MAX_PLAYERS]; // Esta variбvel armazenarб o Colete do Player
Quarto:

Defina os valores de "Vida[playerid]" e "Colete[playerid]" cada vez que ele tomar dano ou Spawnar..

Ex:

Se quando o player spawna a vida e o colete enchem, sua public deverб ficar assim:

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerHealth(playerid, 100); // Setamos a vida do cara pra 100, portando, temos de setar a variбvel da vida tambйm.
    Vida[playerid] = 100; // Setamos a variбvel da vida.
    SetPlayerArmour(playerid, 100); // Setamos o colete do cara pra 100, portando, temos de setar a variбvel do colete tambйm.
    Colete[playerid] = 100; // Setamos a variбvel do colete.
}
Resumindo o Quarto passo: Cada vez que vocк utilizar "SetPlayerHealth(id)" deverб atualizar a "Vida[id]" e cada vez que usar "SetPlayerArmour(id)" deverб atualizar "Colete[id]"...

Quinto: Compile.

...

Por que isso pode resolver: Pois o uso do "Get" geralmente deixa o processamento do cуdigo mais lento...


Qualquer dъvida sу avisar :3

OBS: Nгo testei In-Game..
Reply


Messages In This Thread
No-lag - by Menor - 02.11.2013, 18:45
Re: No-lag - by Ph0ton - 02.11.2013, 19:00
Re: No-lag - by Menor - 02.11.2013, 19:20
Re: No-lag - by Ph0ton - 02.11.2013, 19:25
Re: No-lag - by Menor - 02.11.2013, 19:31
Re: No-lag - by Ph0ton - 02.11.2013, 20:18
Re: No-lag - by Menor - 02.11.2013, 20:25
Re: No-lag - by Ph0ton - 02.11.2013, 20:49

Forum Jump:


Users browsing this thread: 1 Guest(s)