Doors bugs
#1

So many bugs with new doors... GetVehicleParamsCarDoors currently useless, because I can easy realise this function by scripting.

Doors bugs list:
  • Doors state will not be update if I will stop enter or exit in vehicle on opening door.
  • Doors state will not be update if vehicle doors get damage (by ingame process or UpdateVehicleDamageStatus function).
  • Doors state will set to -1 after enter or exit from vehicle.
  • Doors state not saving after reconnect and for new connected players (for state -1, but it's logical).
  • GetVehicleParamsCarDoors data are not updated after SetVehicleParamsCarDoors if someone is in the vehicle.
  • Function UpdateVehicleDamageStatus close doors visually if their state is -1.
You can use this simple script for test this.

P.S. UpdateVehicleDamageStatus working only after first enter.
Reply
#2

Ok, i'm fix some bugs with Pawn. But why you can not fix it in the server?
Here is my include (beta, for the implement in fixes.inc in the future):
PHP код:
/*
    About: GetVehicleParamsCarDoors fix (beta)
    Author: ziggi 
*/
#if !defined _samp_included
    #error Include a_samp.inc first
#endif
#define FIX_GetVehicleParamsCarDoors 1
enum e_PlayerInfo {
    
e_pi_vehicle,
    
e_pi_vehicle_seat,
    
bool:e_pi_isdriver,
    
e_pi_exit_time,
}
static 
playerInfo[MAX_PLAYERS][e_PlayerInfo];
enum e_VehicleInfo {
    
e_vi_door[4],
}
static 
vehicleInfo[MAX_VEHICLES][e_VehicleInfo];
/* 
 * FIXES_SetVehicleParamsCarDoors(vehicleid, driver, passenger, backleft, backright)
 * 
 * FIXES:
 *     GetVehicleParamsCarDoors
 */
#if defined _ALS_SetVehicleParamsCarDoors
    #error _ALS_SetVehicleParamsCarDoors defined
#endif
native BAD_SetVehicleParamsCarDoors(vehicleiddriverpassengerbackleftbackright) = SetVehicleParamsCarDoors;
#if FIX_GetVehicleParamsCarDoors
    
stock FIXES_SetVehicleParamsCarDoors(vehicleiddriverpassengerbackleftbackright)
    {
        if (
driver != -1)
        {
            
vehicleInfo[vehicleid][e_vi_door][0] = driver;
        }
        if (
passenger != -1)
        {
            
vehicleInfo[vehicleid][e_vi_door][1] = passenger;
        }
        if (
backleft != -1)
        {
            
vehicleInfo[vehicleid][e_vi_door][2] = backleft;
        }
        if (
backright != -1)
        {
            
vehicleInfo[vehicleid][e_vi_door][3] = backright;
        }
        return
            
SetVehicleParamsCarDoors(vehicleid,
                
vehicleInfo[vehicleid][e_vi_door][0],
                
vehicleInfo[vehicleid][e_vi_door][1],
                
vehicleInfo[vehicleid][e_vi_door][2],
                
vehicleInfo[vehicleid][e_vi_door][3]
            );
    }
    
#define _ALS_SetVehicleParamsCarDoors
    #define SetVehicleParamsCarDoors FIXES_SetVehicleParamsCarDoors
#endif
/* 
 * FIXES_GetVehicleParamsCarDoors(vehicleid, &driver, &passenger, &backleft, &backright)
 * 
 * FIXES:
 *     GetVehicleParamsCarDoors
 */
#if defined _ALS_GetVehicleParamsCarDoors
    #error _ALS_GetVehicleParamsCarDoors defined
#endif
native BAD_GetVehicleParamsCarDoors(vehicleid, &driver, &passenger, &backleft, &backright) = GetVehicleParamsCarDoors;
#if FIX_GetVehicleParamsCarDoors
    
stock FIXES_GetVehicleParamsCarDoors(vehicleid, &driver, &passenger, &backleft, &backright)
    {
        
driver vehicleInfo[vehicleid][e_vi_door][0];
        
passenger vehicleInfo[vehicleid][e_vi_door][1];
        
backleft vehicleInfo[vehicleid][e_vi_door][2];
        
backright vehicleInfo[vehicleid][e_vi_door][3];
    }
    
#define _ALS_GetVehicleParamsCarDoors
    #define GetVehicleParamsCarDoors FIXES_GetVehicleParamsCarDoors
#endif
/* 
 * _FIXES_SetVehiclePCDTimer(vehicleid, driver, passenger, backleft, backright)
 * 
 * FIXES:
 *     GetVehicleParamsCarDoors
 */
#if FIX_GetVehicleParamsCarDoors
    
forward _FIXES_SetVehiclePCDTimer(vehicleiddriverpassengerbackleftbackright);
    public 
_FIXES_SetVehiclePCDTimer(vehicleiddriverpassengerbackleftbackright)
    {
        return 
SetVehicleParamsCarDoors(vehicleiddriverpassengerbackleftbackright);
    }
#endif
/* 
 * FIXES_UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires)
 * 
 * FIXES:
 *     GetVehicleParamsCarDoors
 */
#if defined _ALS_UpdateVehicleDamageStatus
    #error _ALS_UpdateVehicleDamageStatus defined
#endif
native BAD_UpdateVehicleDamageStatus(vehicleidpanelsdoorslightstires) = UpdateVehicleDamageStatus;
#if FIX_GetVehicleParamsCarDoors
    
stock FIXES_UpdateVehicleDamageStatus(vehicleidpanelsdoorslightstires)
    {
        
UpdateVehicleDamageStatus(vehicleidpanelsdoorslightstires);
        
SetVehicleParamsCarDoors(vehicleid, -1, -1, -1, -1);
    }
    
#define _ALS_UpdateVehicleDamageStatus
    #define UpdateVehicleDamageStatus FIXES_UpdateVehicleDamageStatus
#endif 
/*
*/
public OnPlayerUpdate(playerid)
{
    if (
playerInfo[playerid][e_pi_vehicle] != 0) {
        new 
vehicleid playerInfo[playerid][e_pi_vehicle];
        new 
animindex GetPlayerAnimationIndex(playerid);
        
// opening
        
if ((1043 <= animindex <= 1044 || 1026 <= animindex <= 1027) && playerInfo[playerid][e_pi_vehicle_seat] == -1) {
            new 
model GetVehicleModel(vehicleid);
            new 
Float:fXFloat:fYFloat:fZ;
            
GetVehiclePos(vehicleidfXfYfZ);
            new 
Float:v_wideFloat:v_longFloat:v_high;
            
GetVehicleModelInfo(modelVEHICLE_MODEL_INFO_SIZEv_widev_longv_high);
            new 
Float:v_frontseat[3], Float:v_rearseat[3];
            
GetVehicleModelInfo(modelVEHICLE_MODEL_INFO_FRONTSEATv_frontseat[0], v_frontseat[1], v_frontseat[2]);
            
GetVehicleModelInfo(modelVEHICLE_MODEL_INFO_REARSEATv_rearseat[0], v_rearseat[1], v_rearseat[2]);
            new 
seat = -1;
            if (
playerInfo[playerid][e_pi_isdriver]) {
                if (
IsPlayerInRangeOfPoint(playerid1.0fX v_frontseat[0] / v_wide 2fY v_frontseat[1], fZ v_frontseat[2])) {
                    
seat 0;
                } else if (
IsPlayerInRangeOfPoint(playerid1.0fX v_frontseat[0] / v_wide 2fY v_frontseat[1], fZ v_frontseat[2])) {
                    
seat 1;
                }
            } else {
                if (
IsPlayerInRangeOfPoint(playerid1.0fX v_frontseat[0] / v_wide 2fY v_frontseat[1], fZ v_frontseat[2])) {
                    
seat 1;
                } else if (
IsPlayerInRangeOfPoint(playerid1.0fX v_rearseat[0] / v_wide 2fY v_rearseat[1], fZ v_rearseat[2])) {
                    
seat 2;
                } else if (
IsPlayerInRangeOfPoint(playerid1.0fX v_rearseat[0] / v_wide 2fY v_rearseat[1], fZ v_rearseat[2])) {
                    
seat 3;
                }
            }
            if (
seat != -1) {
                
playerInfo[playerid][e_pi_vehicle_seat] = seat;
                
vehicleInfo[vehicleid][e_vi_door][seat] = 1;
                
SetVehicleParamsCarDoors(vehicleid, -1, -1, -1, -1);
            }
        }
        
// closing
        
if (1011 <= animindex <= 1016 && playerInfo[playerid][e_pi_vehicle_seat] != -1) {
            new 
seat playerInfo[playerid][e_pi_vehicle_seat];
            
vehicleInfo[vehicleid][e_vi_door][seat] = 0;
            
SetVehicleParamsCarDoors(vehicleid, -1, -1, -1, -1);
        }
        
// shuffle
        
if (animindex == 1054) {
            
SetTimerEx("FIXES_SetVehiclePCDTimer"10000"ddddd"vehicleid0, -1, -1, -1);
        }
    }
    return 
CallLocalFunction("FIXES_OnPlayerUpdate""d"playerid);
}
#if defined _ALS_OnPlayerUpdate
    #error _ALS_OnPlayerUpdate defined
#endif
#define _ALS_OnPlayerUpdate
#define OnPlayerUpdate FIXES_OnPlayerUpdate
forward FIXES_OnPlayerUpdate(playerid);
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if (
oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) {
        new 
vehicleid playerInfo[playerid][e_pi_vehicle];
        new 
seat playerInfo[playerid][e_pi_vehicle_seat];
        
playerInfo[playerid][e_pi_vehicle] = 0;
        new 
bool:isclosed tickcount() - playerInfo[playerid][e_pi_exit_time] > 1600;
        
vehicleInfo[vehicleid][e_vi_door][seat] = isclosed 1;
        
SetVehicleParamsCarDoors(vehicleid, -1, -1, -1, -1);
    }
    return 
CallLocalFunction("FIXES_OnPlayerStateChange""ddd"playeridnewstateoldstate);
}
#if defined _ALS_OnPlayerStateChange
    #error _ALS_OnPlayerStateChange defined
#endif
#define _ALS_OnPlayerStateChange
#define OnPlayerStateChange FIXES_OnPlayerStateChange
forward FIXES_OnPlayerStateChange(playerid);
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    
playerInfo[playerid][e_pi_vehicle] = vehicleid;
    
playerInfo[playerid][e_pi_isdriver] = !ispassenger;
    
playerInfo[playerid][e_pi_vehicle_seat] = -1;
    return 
CallLocalFunction("FIXES_OnPlayerEnterVehicle""ddd"playeridvehicleidispassenger);
}
#if defined _ALS_OnPlayerEnterVehicle
    #error _ALS_OnPlayerEnterVehicle defined
#endif
#define _ALS_OnPlayerEnterVehicle
#define OnPlayerEnterVehicle FIXES_OnPlayerEnterVehicle
forward FIXES_OnPlayerEnterVehicle(playerid);
public 
OnPlayerExitVehicle(playeridvehicleid)
{
    
playerInfo[playerid][e_pi_exit_time] = tickcount();
    return 
CallLocalFunction("FIXES_OnPlayerEnterVehicle""dd"playeridvehicleid);
}
#if defined _ALS_OnPlayerExitVehicle
    #error _ALS_OnPlayerExitVehicle defined
#endif
#define _ALS_OnPlayerExitVehicle
#define OnPlayerExitVehicle FIXES_OnPlayerExitVehicle
forward FIXES_OnPlayerExitVehicle(playerid); 
Reply
#3

The door states will reset to VEHICLE_PARAMS_UNSET (-1) whenever there is a driver or passenger in the vehicle. This is expected behaviour for now because I don't want to enable players to change the door states on any vehicle they want.

As for the damage system. The door states and the damage status are seperate. That's just the way the game is designed.

It'll be improved over time. For now it's probably only good for closing the doors when they didn't close by themselves, or allowing players to open doors on their unoccupied vehicles.
Reply
#4

Kalcor then mean I can not get values when I am inside a vehicle.

In tests, I saw that inside the vehicle, the return value is -1. Using SetVehicleParamsCarDoors (), can change the status of the port 0-1 but still returns to -1 in GetVehicleParamsCarDoors ()

It's for work anyway?

-
Sorry for bad english.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)