Git Product home page Git Product logo

Comments (5)

FileEX avatar FileEX commented on June 20, 2024 1

Damage Handler is located on the client side and this is where the onClientPedDamage event is sent and, depending on its status, the handler returns the result.

The server-side event works based on the synchronization packet, where the amount of HP is compared between packets. I think a reasonable solution would be to set the HP amount to something like "current HP + loss" if the event was canceled.

However, I don't know what happens when the ped/player dies? Then, despite the event being canceled, onPedWasted will be sent + the invicible bug will probably appear (#414 )

from mtasa-blue.

FileEX avatar FileEX commented on June 20, 2024 1

The sync packet covers a lot of information, not just health, so you can't just cancel it

if (Data.ucFlags & 0x08)
{
// Less health than last time?
float fPreviousHealth = pPed->GetHealth();
pPed->SetHealth(Data.fHealth);
if (Data.fHealth < fPreviousHealth)
{
// Grab the delta health
float fDeltaHealth = fPreviousHealth - Data.fHealth;
if (fDeltaHealth > 0.0f)
{
// Call the onPedDamage event
CLuaArguments Arguments;
Arguments.PushNumber(fDeltaHealth);
pPed->CallEvent("onPedDamage", Arguments);
}
}
}

from mtasa-blue.

TracerDS avatar TracerDS commented on June 20, 2024

Damage Handler is located on the client side and this is where the onClientPedDamage event is sent and, depending on its status, the handler returns the result.

The server-side event works based on the synchronization packet, where the amount of HP is compared between packets. I think a reasonable solution would be to set the HP amount to something like "current HP + loss" if the event was canceled.

if the server sends packets to the client about ped damage then cancelEvent should not send any synchronization packets and ignore everything. At least thats how I would see it to be the most reasonable and performant solution

However, I don't know what happens when the ped/player dies? Then, despite the event being canceled, onPedWasted will be sent + the invicible bug will probably appear (#414 )

Yeah we would need to check if loss >= currentHP and not run onPedWasted if the event was cancelled and ped died

I tried to implement it but its a lot of complicated work

from mtasa-blue.

FileEX avatar FileEX commented on June 20, 2024

if the server sends packets to the client about ped damage then cancelEvent should not send any synchronization packets and ignore everything. At least thats how I would see it to be the most reasonable and performant solution

We can't stop sending the sync packet and ignore everything. These packets concern general data synchronization between clients and the server, not just health. Canceling the sending of synchronization packets after canceling the event will cause desynchronization bugs

from mtasa-blue.

TracerDS avatar TracerDS commented on June 20, 2024

if the server sends packets to the client about ped damage then cancelEvent should not send any synchronization packets and ignore everything. At least thats how I would see it to be the most reasonable and performant solution

We can't stop sending the sync packet and ignore everything. These packets concern general data synchronization between clients and the server, not just health. Canceling the sending of synchronization packets after canceling the event will cause desynchronization bugs

If its about health only then how would that cause desync with other players? For other ped related packets, sure. However if we are cancelling the damage event then only the packets responsible for ped's health should be ignored

from mtasa-blue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.