Página 1 de 1

Ride as passenger

Enviado: 09 Fev 2020, 07:48
por Grinch_
This script lets you ride any vehicle as a passenger by pressing the 'G' key. Let me know if you find any issues.

SpoilerAbrir

Código: Selecionar tudo

/*
    Enter car as passenger script
    Author: Grinch_
    You'll need this for the script to compile,
    https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
*/
SCRIPT_START
{
    LVAR_INT scplayer pplayer hped hveh pveh idoor pdoor vec pvec iseat hdriver hpassenger itotalpassenger
    // ini
    LVAR_INT ikey idrivestyle idrivestyleincreasekey idrivestyledecreasekey idrivespeedincreasekey idrivespeeddecreasekey
    LVAR_FLOAT fdrivespeed
    NOP
    GET_PLAYER_CHAR 0 scplayer
    // INI check
    IF DOES_FILE_EXIST "cleo\Enter as passenger.ini"
        READ_INT_FROM_INI_FILE "cleo\Enter as passenger.ini" "Settings" "Key" ikey
        READ_INT_FROM_INI_FILE "cleo\Enter as passenger.ini" "Settings" "Drive Style" idrivestyle // https://gtamods.com/wiki/00AE
        READ_INT_FROM_INI_FILE "cleo\Enter as passenger.ini" "Settings" "Drive Style increase key" idrivestyleincreasekey
        READ_INT_FROM_INI_FILE "cleo\Enter as passenger.ini" "Settings" "Drive Style decrease key" idrivestyledecreasekey
        READ_INT_FROM_INI_FILE "cleo\Enter as passenger.ini" "Settings" "Drive Speed increase key" idrivespeedincreasekey
        READ_INT_FROM_INI_FILE "cleo\Enter as passenger.ini" "Settings" "Drive Speed decrease key" idrivespeeddecreasekey
        READ_INT_FROM_INI_FILE "cleo\Enter as passenger.ini" "Settings" "Key" ikey
        READ_FLOAT_FROM_INI_FILE "cleo\Enter as passenger.ini" "Settings" "Drive Speed" fdrivespeed
    ELSE
        // ini doesn't exist
        WHILE TRUE 
            PRINT_STRING "'Enter as passenger.ini' doesn't exist. Please reinstall" 1000
            WAIT 900
        ENDWHILE
    ENDIF

    WHILE TRUE
        WAIT 0
        IF IS_KEY_PRESSED ikey
            IF IS_CHAR_IN_ANY_CAR scplayer 
                GET_CAR_CHAR_IS_USING scplayer hveh
                GET_DRIVER_OF_CAR hveh hdriver
                IF NOT hdriver = scplayer
                    CAR_SET_IDLE hveh
                    WHILE NOT IS_CAR_STOPPED hveh
                        WAIT 0
                    ENDWHILE
                    TASK_LEAVE_CAR scplayer hveh
                    WHILE NOT IS_CHAR_ON_FOOT scplayer
                        WAIT 0
                    ENDWHILE
                    SET_CAR_MISSION hveh 1
                    SET_CAR_DRIVING_STYLE hveh idrivestyle
                    SET_CAR_CRUISE_SPEED hveh fdrivespeed
                ENDIF
                hveh = NULL
            ELSE
                STORE_CLOSEST_ENTITIES scplayer hveh hped
                IF hveh > 0
                    GET_VEHICLE_POINTER hveh pveh
                    GET_PED_POINTER scplayer pplayer
                    GET_VAR_POINTER idoor pdoor
                    GET_VAR_POINTER vec pvec
                    CALL_FUNCTION 0x650BB0 7 7 (FALSE FALSE FALSE pdoor pvec pveh pplayer) // CCarEnterExit::GetNearestCarPassengerDoor
                    CALL_FUNCTION_RETURN 0x64F1E0 2 2 (idoor,pveh) iseat // CCarEnterExit::ComputePassengerIndexFromCarDoor
                    TASK_ENTER_CAR_AS_PASSENGER scplayer hveh -1 iseat
                    GET_MAXIMUM_NUMBER_OF_PASSENGERS hveh itotalpassenger
                    iseat = 0
                    WHILE TRUE
                        GET_CHAR_IN_CAR_PASSENGER_SEAT hveh iseat hpassenger
                        IF hpassenger > 0
                        AND NOT hpassenger = scplayer
                            SET_CHAR_STAY_IN_CAR_WHEN_JACKED hpassenger TRUE
                        ENDIF
                        IF iseat = itotalpassenger
                            BREAK
                        ENDIF
                        iseat += 1
                    ENDWHILE
                ENDIF
            ENDIF
            WHILE IS_KEY_PRESSED ikey
                WAIT 0
            ENDWHILE
        ENDIF
        
        IF NOT hveh = NULL
        AND IS_CHAR_IN_CAR scplayer hveh
            GET_DRIVER_OF_CAR hveh hdriver
            IF hdriver > 0
            AND NOT hdriver = scplayer
                CAR_SET_IDLE hveh
                SET_CAR_MISSION hveh 1
                SET_CAR_DRIVING_STYLE hveh idrivestyle
                SET_CAR_CRUISE_SPEED hveh fdrivespeed
            ENDIF
            
            hdriver = NULL
        ENDIF
        IF IS_KEY_PRESSED idrivespeedincreasekey
            IF fdrivespeed < 50.0
                fdrivespeed += 5.0
                IF NOT hveh = NULL
                    SET_CAR_CRUISE_SPEED hveh fdrivespeed
                ENDIF
                PRINT_HELP_FORMATTED "Speed set to %0.f" fdrivespeed
            ELSE
                PRINT_HELP_STRING "Max speed set"
            ENDIF
            WAIT 250
        ENDIF
        IF IS_KEY_PRESSED idrivespeeddecreasekey
            IF fdrivespeed > 0.0
                fdrivespeed -= 5.0
                IF NOT hveh = NULL
                    SET_CAR_CRUISE_SPEED hveh fdrivespeed
                ENDIF
                PRINT_HELP_FORMATTED "Speed set to %0.f" fdrivespeed
            ELSE
                PRINT_HELP_STRING "Min speed set"
            ENDIF
            WAIT 250
        ENDIF
        IF IS_KEY_PRESSED idrivestyleincreasekey
            IF idrivestyle < 5
                idrivestyle += 1
                IF NOT hveh = NULL
                    SET_CAR_DRIVING_STYLE hveh idrivestyle
                ENDIF
                PRINT_HELP_FORMATTED "Style set to %d" idrivestyle
            ELSE
                PRINT_HELP_STRING "Max style set"
            ENDIF
            WAIT 250
        ENDIF
        IF IS_KEY_PRESSED idrivestyledecreasekey
            IF idrivestyle > 0
                idrivestyle -= 1
                IF NOT hveh = NULL
                    SET_CAR_DRIVING_STYLE hveh idrivestyle
                ENDIF
                PRINT_HELP_FORMATTED "Style set to %d" idrivestyle
            ELSE
                PRINT_HELP_STRING "Min style set"
            ENDIF
            WAIT 250
        ENDIF
    ENDWHILE
}
SCRIPT_END
Download from here

Re: Ride as passenger

Enviado: 09 Fev 2020, 12:29
por HybridTheory
in gta3sc, you can make comparisons just using operators

IF IS_INT_LVAR_EQUAL_TO_NUMBER bool 1

🡓

IF bool = 1

Re: Ride as passenger

Enviado: 09 Fev 2020, 15:47
por Junior_Djjr
Me impressiona como o código foi inteiramente criado usando  IS_INT_LVAR_EQUAL_TO_NUMBER em vez de =

Re: Ride as passenger

Enviado: 09 Fev 2020, 17:56
por V_ZER0
Eu curto esse mod de passageiro mas todos que testei davam problema ou tinham bugs,seria bom um bem feito na mix

Re: Ride as passenger

Enviado: 09 Fev 2020, 23:03
por Grinch_
HybridTheory escreveu:
09 Fev 2020, 12:29
in gta3sc, you can make comparisons just using operators

IF IS_INT_LVAR_EQUAL_TO_NUMBER bool 1

🡓

IF bool = 1
I didn't know that. Thanks, updated it.

Re: Ride as passenger

Enviado: 27 Fev 2020, 19:32
por Kr0n0s800
"IDEA" por que no unes o expandes este mod para funcionar en conjunto con "Personal Driver", el funcionamiento seria: si estas con con tus miembros de banda y subes a un vehículo como pasajero, automáticamente uno de los miembros es designado como conductor.
PD: por que no puedo entrar como pasajero en los asientos traseros?

Re: Ride as passenger

Enviado: 27 Fev 2020, 22:22
por Grinch_
Kr0n0s800 escreveu:
27 Fev 2020, 19:32
"IDEA" por que no unes o expandes este mod para funcionar en conjunto con "Personal Driver", el funcionamiento seria: si estas con con tus miembros de banda y subes a un vehículo como pasajero, automáticamente uno de los miembros es designado como conductor.
PD: por que no puedo entrar como pasajero en los asientos traseros?
Currently It's not possible. Maybe sometime in future.

Re: Ride as passenger

Enviado: 03 Mar 2020, 15:40
por Junior_Djjr
You are all frames setting the player to be ignored by everyone, it is obvious that this totally breaks the gameplay, no one else hits the CJ, neither peds nor cops. Why?

Re: Ride as passenger

Enviado: 03 Mar 2020, 15:46
por Grinch_
Already updated the google drive files but forgot to update the code inside the spoiler  😅

Re: Ride as passenger

Enviado: 03 Mar 2020, 15:55
por Junior_Djjr
I have 6 stars, I press G, and the army forgets me forever.
You don't need to get passenger by memory, just use GET_CHAR_IN_CAR_PASSENGER_SEAT
If you press G while driving your car will stop instantly and CJ will be launched from the door.

Re: Ride as passenger

Enviado: 03 Mar 2020, 16:04
por Grinch_
Junior_Djjr escreveu:
03 Mar 2020, 15:55
I have 6 stars, I press G, and the army forgets me forever.
You don't need to get passenger by memory, just use GET_CHAR_IN_CAR_PASSENGER_SEAT
If you press G while driving your car will stop instantly and CJ will be launched from the door.
ah, thanks. I'll update it soon :)

Re: Ride as passenger

Enviado: 10 Mai 2020, 11:16
por Grinch_
Improved the mod, now player will enter the nearest vehicle door seat, passengers won't run away when the player enters, the player won't be stuck inside the car if the car is moving fast.

Re: Ride as passenger

Enviado: 14 Mai 2020, 21:19
por GTA_GamerZ
Grinch_ escreveu:
10 Mai 2020, 11:16
Improved the mod, now player will enter the nearest vehicle door seat, passengers won't run away when the player enters, the player won't be stuck inside the car if the car is moving fast.
It would be better if the passenger randomly run away after a while or call the police and CJ will get one star.

Re: Ride as passenger

Enviado: 14 Mai 2020, 21:53
por Grinch_
GTA_GamerZ escreveu:
14 Mai 2020, 21:19
Grinch_ escreveu:
10 Mai 2020, 11:16
Improved the mod, now player will enter the nearest vehicle door seat, passengers won't run away when the player enters, the player won't be stuck inside the car if the car is moving fast.
It would be better if the passenger randomly run away after a while or call the police and CJ will get one star. 
I wanted it to be as basic as just entering as a passenger. Maybe something optional sometime later.