SSGamers - 12 Anos online por você.

#SSGamers - A Comunidade que mais crescer no brasil!

Participe do fórum, é rápido e fácil

SSGamers - 12 Anos online por você.

#SSGamers - A Comunidade que mais crescer no brasil!

SSGamers - 12 Anos online por você.

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.
Chegou o novo tema 6.5.5 - SSGamers - Servidores online de qualidade - Aproveite e entre para nossa comunidade, inscreva-se já! - Ouça nossa web radio - Veja nossas novidades - Participe dos nossos setores de jogos online - Parcerias aberta fale já com um administrador.

    OnPlayerUpdate

    Weslley_Script
    Weslley_Script
    SS - Fundador
    SS - Fundador


    Steam Steam : WeslleySSGames
    Zello : WeslleySSGames
    Mensagens : 11378
    Moedas : 1031978
    Data de inscrição : 06/10/2011
    Idade : 28
    Localização : Brasil

    OnPlayerUpdate Empty OnPlayerUpdate

    Mensagem por Weslley_Script Dom 15 Jan 2023 - 12:44

    OnPlayerUpdate

    Description

    This callback is called every time a client/player updates the server with their status. It is often used to create custom callbacks for client updates that aren't actively tracked by the server, such as health or armor updates or players switching weapons.


    [th]Name[/th][th]Description[/th]
    playeridID of the player sending an update packet.

    Returns

    0 - Update from this player will not be replicated to other clients.
    1 - Indicates that this update can be processed normally and sent to other players.
    It is always called first in filterscripts.

    Examples

    Código:
    public OnPlayerUpdate(playerid)
    {
        new iCurWeap = GetPlayerWeapon(playerid); // Return the player's current weapon
        if (iCurWeap != GetPVarInt(playerid, "iCurrentWeapon")) // If he changed weapons since the last update
        {
            // Lets call a callback named OnPlayerChangeWeapon
            OnPlayerChangeWeapon(playerid, GetPVarInt(playerid, "iCurrentWeapon"), iCurWeap);
            SetPVarInt(playerid, "iCurrentWeapon", iCurWeap);//Update the weapon variable
        }
        return 1; // Send this update to other players.
    }

    stock OnPlayerChangeWeapon(playerid, oldweapon, newweapon)
    {
        new     s[128],
            oWeapon[24],
            nWeapon[24];

        GetWeaponName(oldweapon, oWeapon, sizeof(oWeapon));
        GetWeaponName(newweapon, nWeapon, sizeof(nWeapon));

        format(s, sizeof(s), "You changed weapon from %s to %s!", oWeapon, nWeapon);

        SendClientMessage(playerid, 0xFFFFFFFF, s);
    }
    public OnPlayerUpdate(playerid)
    {
        new Float:fHealth;

        GetPlayerHealth(playerid, fHealth);

        if (fHealth != GetPVarFloat(playerid, "faPlayerHealth"))
        {
            // Player health has changed since the last update -> server, so obviously thats the thing updated.
            // Lets do further checks see if he's lost or gained health, anti-health cheat? 

            if (fHealth > GetPVarFloat(playerid, "faPlayerHealth"))
            {
                /* He has gained health! Cheating? Write your own scripts here to figure how a player
                gained health! */
            }
            else
            {
                /* He has lost health! */
            }

            SetPVarFloat(playerid, "faPlayerHealth", fHealth);
        }
    }

    Notes

    TIP
    This callback can also be called by NPC.



    OnPlayerUpdate D07Xwqb
    OnPlayerUpdate Yjab9HN

      Data/hora atual: Qui 9 maio 2024 - 6:56