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

Opcode TASK_ENTER_CAR_AS_PASSENGER fails in SA #125

Open
nathan130200 opened this issue Feb 8, 2022 · 0 comments
Open

Opcode TASK_ENTER_CAR_AS_PASSENGER fails in SA #125

nathan130200 opened this issue Feb 8, 2022 · 0 comments

Comments

@nathan130200
Copy link

nathan130200 commented Feb 8, 2022

I'm trying to make CJ enter in a car without teleport (wrap) him inside the car, but this function

  • TASK_ENTER_CAR_AS_PASSENGER scplayer vehicle 0 20000 is always crashing.

In commands.xml display:

<Command ID="0x5ca" Name="TASK_ENTER_CAR_AS_PASSENGER">
  <Args>
	<Arg Type="INT" Entity="CHAR"/>
	<Arg Type="INT" Entity="CAR"/>
	<Arg Type="INT"/>
	<Arg Type="INT" Desc="Time"/>
  </Args>
</Command>

Where 3rd integer is seat id and last id time to wait, but even i put correct seat id still crashes.
I tried reverse argument position, same happen, crash.

Basically before crash i can see CJ attempting to enter in car, but him disappear after sit then game crashes.

Idk if this is right place for help, but i'm thankful any means.

The code WARP_CHAR_INTO_CAR_AS_PASSENGER scplayer vehicle 0 to teleport direct player into car works.

I'm checking everything if car and driver exists, if player is not dead, and if someone is in seat (any mean if seat id is occupied game itself eject other ped), but TASK_ENTER_CAR_AS_PASSENGER still not working.

My full script code (tested and everything working except that i'm forced to teleport player into car)

SCRIPT_START
{
    NOP
    
    LVAR_INT scplayer
    GET_PLAYER_CHAR 0 scplayer
    
    LVAR_INT vehicle driver state
    LVAR_FLOAT posX posY posZ
    LVAR_FLOAT destX destY destZ
    
    WHILE TRUE
        WAIT 0
        
        IF GET_TARGET_BLIP_COORDS destX destY destZ 
        AND IS_KEY_PRESSED VK_KEY_G
            // procura um veículo nos arredores
            GET_CHAR_COORDINATES scplayer posX posY posZ
            GET_RANDOM_CAR_IN_SPHERE_NO_SAVE posX posY posZ 15.0 -1 vehicle
            
            // verifica se o veiculo existe
            IF DOES_VEHICLE_EXIST vehicle 
                
                // obtendo o motorista 
                GET_DRIVER_OF_CAR vehicle driver
                
                // se for válido, cj entra no carrgo e o motorista digire ate a coordenada
                IF DOES_CHAR_EXIST driver                     
                    WARP_CHAR_INTO_CAR_AS_PASSENGER scplayer vehicle 0
                    TASK_CAR_DRIVE_TO_COORD driver vehicle destX destY destZ 15.0 0 0 3
                    GOSUB CheckDestination
                ENDIF
            ENDIF
        ENDIF
    ENDWHILE

    CheckDestination:
        LVAR_FLOAT distance
        
        LOCK_CAR_DOORS vehicle CARLOCK_LOCKED_BUT_CAN_BE_DAMAGED

        WHILE TRUE
            WAIT 0
            
            IF NOT IS_CHAR_IN_CAR scplayer vehicle
                BREAK
            ELSE
                GET_CAR_COORDINATES vehicle posX posY posZ
                GET_DISTANCE_BETWEEN_COORDS_3D posX posY posZ destX destY destZ distance

                IF distance <= 2.0
                    TASK_LEAVE_CAR scplayer vehicle
                    
                    WHILE IS_CHAR_SITTING_IN_CAR scplayer vehicle
                        WAIT 0
                    ENDWHILE

                    BREAK
                ENDIF
            ENDIF
            
            IF LOCATE_CHAR_IN_CAR_3D scplayer destX destY destZ 10.0 10.0 10.0 1
                LOCK_CAR_DOORS vehicle CARLOCK_UNLOCKED
                TASK_LEAVE_CAR scplayer vehicle
            ENDIF
        ENDWHILE
        
        RETURN
}
SCRIPT_END
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

1 participant