Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when get Component values in GameModeExit #419

Closed
joaoseidel opened this issue Aug 18, 2022 · 3 comments
Closed

Bug when get Component values in GameModeExit #419

joaoseidel opened this issue Aug 18, 2022 · 3 comments

Comments

@joaoseidel
Copy link

joaoseidel commented Aug 18, 2022

When trying to get a component value inside GameModeExit event with IEntityManager, those values are always 0, at least with Vehicles entities.

Eg.:

[Event]
public void OnGameModeExit(IEntityManager entityManager)
{
    var vehicles = entityManager.GetComponents<Vehicle>();
    foreach (var vehicle in vehicles)
    {
        Console.WriteLine(vehicle.Health);  // always return 0
    }
}
ikkentim added a commit that referenced this issue Aug 27, 2022
@ikkentim
Copy link
Owner

I've tested this with this system: https://github.com/ikkentim/SampSharp/blob/master/src/TestMode.Entities/Systems/IssueTests/Issue419VehicleHealthOnGmx.cs

It seems to work just fine on both samp-server and open.mp.

I've tested it with GMX, how are you testing this?

@joaoseidel
Copy link
Author

Yes, on GMX works, the problem only occurs when shutting down. Is that the correct behavior?

@ikkentim
Copy link
Owner

I've verified this is a bug with open.mp. Here's the simplest reproduction case for this:

#include <a_samp>

main() return;

new vid;

public OnGameModeInit()
{
	vid = CreateVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, -1, -1, 60);
	return 1;
}

public OnGameModeExit()
{
	new Float:h;
	GetVehicleHealth(vid, h);
	printf("health:  %f", h); // prints "health: 0" in open.mp, "health: 1000" in sa-mp
	return 1;
}

You can create an issue in the open.mp repo if you'd like to get this fixed.

ikkentim added a commit that referenced this issue Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants