sa-mp-fixes icon indicating copy to clipboard operation
sa-mp-fixes copied to clipboard

Garage doors aren't synced

Open IstuntmanI opened this issue 6 years ago • 5 comments

I just noted this on wiki too: http://wiki.sa-mp.com/wiki/Bugs

This include should remove (RemoveBuildingForPlayer) those old default doors, create them again with the position a little changed (creating on the exactly same old position crashes the game when getting close, AFAIK) and manually move them if someone is in a close near-original range. Including the huge LV/Abandoned Airports ones. I noticed that you need to be near the center of the door to open and it won't close/open until it fully opened/closed. House garage doors are moving pretty fast, while the LV/Abandoned Airports doors are moving really slow. The LV Airport door is moving down and while it is being closed it can be opened if you are really close (or something like that, not sure about others, they move differently).

I noticed that lots of Fun servers that have the spawn in the Abandoned Airport garage (my server too) are having the sync bugged when more than one player is entering through the door, because at one player the door is closed and at the other one it is (being) opened.

This could also provide other useful functions:

native GarageGetClosestID(Float:x, Float:y);
native GarageGetDoorPos(doorid, &Float:x, &Float:y);
native GarageDoorGetSpeed(doorid, &Float:speed);
native GarageDoorSetSpeed(doorid, Float:speed);

#define GARAGEDOOR_STATE_CLOSED 0
#define GARAGEDOOR_STATE_OPENED 1
native GarageDoorSetState(doorid, state); // will instantly set it to closed/opened state - not sure if needed, as it would probably open/close back again instantly
native GarageDoorLockState(doorid, state); // will lock it on that state, so it won't move anymore
native GarageDoorGetLockState(doorid); // -1 (? if not locked in a state) or GARAGEDOOR_STATE_CLOSED/OPENED
native GarageDoorUnLock(doorid);

If this include allowed external plugins, the Streamer Plugin could be really handy: CreateDynamicSphere, OnPlayerEnter/LeaveDynamicArea, IsAnyPlayerInDynamicArea, while also streaming all the garage doors.

This looks like a filterscript, but, well, this is a sync that SA-MP SHOULD provide in the first place, with more manipulation too, in my opinion. Not sure if you will agree with this addition.

IstuntmanI avatar Jul 16 '17 16:07 IstuntmanI

I do agree. I also agree with detecting plugins better. As I said the other day, submitting any code is better than not having any code at all, so do you want to take the lead on writing this @IstuntmanI ? You said you were worried about commiting - don't be! As a general rule, if it works that's good!

Y-Less avatar Jul 16 '17 18:07 Y-Less

I could write a filterscript for all my suggestions and then try to implement it in the fixes include, but for now I can't even manage to find the coordinates of garage doors from GTA SA, only these informations: https://www.gtamodding.com/wiki/Memory_Addresses_(SA)#Garages_and_Parking I'm not sure if there are only 50 garage doors, because some houses around the map have garage doors that can be opened, so they aren't regular safehouses or mod shops/pay'n'sprays. Also, that information isn't too useful for SA-MP's MoveObject function. I found something pretty useful in MTA, but not enough:

  • Locations: https://wiki.multitheftauto.com/wiki/Garage
  • Source code of loading garages directly from the memory: https://github.com/multitheftauto/mtasa-blue/blob/b2227c359092ce530cdf9727466b88bec8282cd0/Client/game_sa/CGaragesSA.cpp#L22

If those are all the locations, we could just duplicate the doors coordinates via editor.exe, but the open coordinates wouldn't be exact because the editor only shows the garage doors closed AFAIK. It would've been too great to find the open and closed coordinates directly. Probably GTA SA isn't storing them because it just uses math based on those memory informations.

IstuntmanI avatar Jul 16 '17 20:07 IstuntmanI

Well it must have at least one of the co-ordinates stored somewhere, since they need to be placed closed. They will be in one of the map files or the SCM, couldn't tell you which (possibly a combination of both). I don't know if the SA:MP SCM can be decompiled (it was written with protections that prevented that at the time, but modern decompilers are much better at ignoring junk data), but the base one can. Your best bet is those places.

And if the game only stores one location and uses maths, why can't we?

Y-Less avatar Jul 16 '17 22:07 Y-Less

Also, do pay-n-sprays work without the door?

Y-Less avatar Jul 16 '17 22:07 Y-Less

Just tested this. They work, but the camera won't move outside of the Pay'n'Spray. It will be frozen until the vehicle is resprayed, right where you left it before the freeze. This will be a problem. I don't think that mod shops and Pay'n'Sprays are synced (EDIT: Tested this, not synced, they will close only if YOUR vehicle is being resprayed). (btw, just noticed that Pay'n'Spray is abbreviated as P'n'S, damn it Rockstar* !!)


Also, I can remember that when players are in mod shops they will collide with other players in that mod shop. Mod shops should change the virtual world (EDIT: Tested this too, still behaves like this). This can help: http://wiki.sa-mp.com/wiki/OnEnterExitModShop . EDIT: Created issue #53.

By the way, when the vehicle is resprayed, there's some nice colored smoke near the vehicle, do we have access to similar colored particles in SA-MP, or we have to apply materials to some existent smoke particles (not sure if materials are working on particles, I don't think they do) ?

Also, I noticed again (forgot about this) that the server isn't calling OnVehicleRespray when respraying it in Pay'n'Spray. This is also noted on wiki: http://wiki.sa-mp.com/wiki/OnVehicleRespray : "Misleadingly, this callback is not called for pay 'n' spray (only modshops)." . The fix calls OnVehicleRespray with -1 colors, but ideally it should have the same color as the smoke, but since this isn't possible, it could be implemented in Fixes with a random carcols.dat color, maybe, as you already worked on that in your pull request. EDIT: Created issue #54.

I guess that this is a different issue entirely.

IstuntmanI avatar Jul 17 '17 15:07 IstuntmanI