Weird behaviour with OnPlayerUpdate
#1

Alright, while testing and playing around with the functions on my TF gamemode I've noticed that a feature stopped working.

I emulate the spies TF2's invisibility by returning 0 at onplayerupdate, the following code seems to do the trick very well:

pawn Код:
forward InvisibilityVar(playerid);
public InvisibilityVar(playerid)
{
    //SafeSetPlayerPos(playerid, 0,0,0);
    invisible[playerid] = 1;
    UpdateAllPlayers();
    //UpdateAllPlayers();
    SetPVarInt(playerid,"PreInvisStep",2);
    SetTimerEx("MakeInvisible",GetPlayerPing(playerid)+250, false, "ii", playerid, 1);
    return 1;
}

forward MakeInvisible(playerid, in);
public MakeInvisible(playerid, in)
{
    if(in == 1)
    {
        if(GetPlayerHealthEx(playerid) <= 0)
            return 1;
   
        InvisibleBlink(playerid);
        TogglePlayerControllable(playerid,false);
        if(GetPVarInt(playerid, "PreInvisStep") == 0)
        {
            new Float:Float[3];
            GetPlayerPos(playerid, Float[0],Float[1],Float[2]);
            SetPVarFloat(playerid, "PreInvisX",Float[0]);
            SetPVarFloat(playerid, "PreInvisY",Float[1]);
            SetPVarFloat(playerid, "PreInvisZ",Float[2]);
            SetPVarInt(playerid, "PreInvisStep", 1);
            SafeSetPlayerPos(playerid, Float[0],Float[1],Float[2]-20.0);
            UpdateAllPlayers();
            SetTimerEx("InvisibilityVar",GetPlayerPing(playerid)+100,false,"i",playerid);
        }
        else if(GetPVarInt(playerid, "PreInvisStep") == 2)
        {
            //SetPlayerVirtualWorld(playerid, 0);
            SetPVarInt(playerid,"Invisible",1);
            TDBigInfo(playerid, "You're now invisible.");
            KillTimer(invtimer[playerid]);
            invtimer[playerid] = SetTimerEx("Invisibility",200,false,"ii",playerid,1);
            TogglePlayerControllable(playerid,true);
            SafeSetPlayerPos(playerid, GetPVarFloat(playerid,"PreInvisX"),GetPVarFloat(playerid,"PreInvisY"), GetPVarFloat(playerid,"PreInvisZ"));
        }
        return 1;
    }
    else
    {
        SetPVarInt(playerid,"Invisible",0);
        TogglePlayerControllable(playerid,false);
        invisible[playerid] = 0;
        ClearAnimations(playerid);
        TogglePlayerControllable(playerid,true);
        InvisibleBlink(playerid);
        TDBigInfo(playerid, "You're no longer invisible.");
        SetPVarInt(playerid, "PreInvisStep",0);
        KillTimer(invtimer[playerid]);
        invtimer[playerid] = SetTimerEx("Invisibility",250,false,"ii",playerid,0);
        return 1;
    }
}
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(invisible[playerid] == 1)
    {
        SetPlayerArmedWeapon(playerid, 0);
        return 0;
    }
}

Now what happens is that while on the invisibility state, OnPlayerWeaponShot seems to ignore completely the player who is not being updated to the server, which actually makes sense. However, all other sources of damage apart from those called at OnPlayerWeaponShot do work and the "invisible" player receives the damage via the OnPlayerTakeDamage callback.

Video: [ame]http://www.youtube.com/watch?v=-w1fgPlzZ9g[/ame]
(Not of my authority)

You can see in the video that once he goes invisible, I proceed to shot and none impact on him. OnPlayerWeaponShot is called as hittype 0 and impacts are on the ground behind him; however when I test with my knife OnPlayerTakeDamage is called perfectly and I'm able to kill him. He's invisible for me in my client:





This worked perfectly in 0.3x since OnPlayerTakeDamage was called every time an invisible player would see other clients hitting him, even when desynced by the effect of the OnPlayerUpdate.

Would this be an intended feature that came with the Lagshot fixes? Wouldn't this also mean that lagshot fixes are not reliable on melee/spray can/fire ex/etc since they are still open to desync issues such as the one I created? Since technically the player is desynced, however his packets are still being sent to the server, why wouldn't OnPlayerWeaponShot while OnPlayerTakeDamage does?
Reply
#2

OnPlayerWeaponShot is called when the shooter's client detects a fired shot. As the target (you) is not in front of the shooter in his client, OnPlayerWeaponShot won't detect a hit on it.

Edit: Oh, and additionally; yes, the laggshot-update moved the damage-syncing from the target's client to the shooter's client. So it relies on the data the shooter sends to the server, which is none as his client does not see the person at the correct position.
Reply
#3

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
OnPlayerWeaponShot is called when the shooter's client detects a fired shot. As the target (you) is not in front of the shooter in his client, OnPlayerWeaponShot won't detect a hit on it.

Edit: Oh, and additionally; yes, the laggshot-update moved the damage-syncing from the target's client to the shooter's client. So it relies on the data the shooter sends to the server, which is none as his client does not see the person at the correct position.
Well this makes sense and actually is good however it doesn't work with all weapons, does this mean the weapon sync is not completely fixed for melee's and others which are not detected at onplayerweaponshot? I've noticed some fails when using melees though; If this isn't the case I would love hit detection callbacks for all the other weapons.
Reply
#4

Quote:
Originally Posted by CuervO
Посмотреть сообщение
Well this makes sense and actually is good however it doesn't work with all weapons, does this mean the weapon sync is not completely fixed for melee's and others which are not detected at onplayerweaponshot? I've noticed some fails when using melees though; If this isn't the case I would love hit detection callbacks for all the other weapons.
OnPlayerWeaponShot only works on weapons that shoot bullets. It does not work on melee weapons, weapons that shoot particles (flamethrower, spray can) or weapons that shoot projectiles (rocket launcher, grenades).

This is because those other weapons would require completely different methods of detecting them, as Kalcor states somewhere (but can't remember where). This function only detects the actual bullet firing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)