Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JuniorDjjr
Last active January 5, 2024 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JuniorDjjr/d65ac37ed1516ed5ce33afa2f89a769e to your computer and use it in GitHub Desktop.
Save JuniorDjjr/d65ac37ed1516ed5ce33afa2f89a769e to your computer and use it in GitHub Desktop.
// You need: https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
SCRIPT_START
{
LVAR_INT i scplayer hVeh hChar iPedType iPlayerId
LVAR_FLOAT car_x car_y car_z x y z fDistance fTimeOnSidewalk[2] fSpeed fDecreaseEase[2] fFinalDecreaseValue
NOP
/////////////////////////////////////////////////
WHILE TRUE
WAIT 0
// -- Simple 2 players adaptation
iPlayerId = 0
GOSUB CheckAndStart
IF IS_2PLAYER_GAME_GOING_ON
iPlayerId = 1
GOSUB CheckAndStart
ENDIF
ENDWHILE
CheckAndStart:
GET_PLAYER_CHAR iPlayerId scplayer
IF IS_CHAR_SITTING_IN_ANY_CAR scplayer
STORE_CAR_CHAR_IS_IN_NO_SAVE scplayer (hVeh)
GET_DRIVER_OF_CAR hVeh (hChar)
IF hChar = scplayer
AND IS_PLAYER_CONTROL_ON iPlayerId
GET_VEHICLE_POINTER hVeh i
i += 0x594 //mSubClass
READ_MEMORY i 4 FALSE (i)
IF NOT i = 6 //TRAIN
AND NOT i = 10 //BMX
GOSUB CarInSidewalk
ENDIF
ENDIF
ENDIF
RETURN
/////////////////////////////////////////////////
CarInSidewalk:
GET_CAR_COORDINATES hVeh car_x car_y car_z
GET_CLOSEST_CHAR_NODE car_x car_y car_z (x y z)
GET_DISTANCE_BETWEEN_COORDS_3D car_x car_y car_z x y z (fDistance)
IF fDistance > 3.0
fDecreaseEase[iPlayerId] +=@ 0.02
IF fDecreaseEase[iPlayerId] > 1.0
fDecreaseEase[iPlayerId] = 1.0
ENDIF
GET_CAR_SPEED hVeh (fSpeed)
fSpeed /= 10.0
IF fSpeed > 1.0
fSpeed = 1.0
ENDIF
fFinalDecreaseValue = fDecreaseEase[iPlayerId] * fSpeed
IF fFinalDecreaseValue > 0.0
fTimeOnSidewalk[iPlayerId] -=@ fFinalDecreaseValue
ENDIF
IF fTimeOnSidewalk[iPlayerId] < 0.0
fTimeOnSidewalk[iPlayerId] = 0.0
ENDIF
//PRINT_FORMATTED_NOW "~r~%.1f - %.1f" 100 fTimeOnSidewalk[iPlayerId] fFinalDecreaseValue
ELSE
fDecreaseEase[iPlayerId] -=@ 0.1
IF fDecreaseEase[iPlayerId] < 0.0
fDecreaseEase[iPlayerId] = 0.0
ENDIF
GET_CAR_SPEED hVeh (fSpeed)
fSpeed /= 20.0
IF fSpeed > 1.0
fSpeed = 1.0
ENDIF
fTimeOnSidewalk[iPlayerId] +=@ fSpeed
IF fTimeOnSidewalk[iPlayerId] > 25.0
IF NOT IS_WANTED_LEVEL_GREATER iPlayerId 1
IF GET_RANDOM_CHAR_IN_SPHERE_NO_SAVE_RECURSIVE car_x car_y car_z 100.0 FALSE TRUE (hChar)
GOSUB SeenByCop
WHILE GET_RANDOM_CHAR_IN_SPHERE_NO_SAVE_RECURSIVE car_x car_y car_z 100.0 TRUE TRUE (hChar)
GOSUB SeenByCop
ENDWHILE
ENDIF
ENDIF
IF fTimeOnSidewalk[iPlayerId] > 50.0
fTimeOnSidewalk[iPlayerId] = 50.0
ENDIF
ENDIF
//PRINT_FORMATTED_NOW "~y~%.1f + %.1f" 100 fTimeOnSidewalk[iPlayerId] fSpeed
ENDIF
RETURN
SeenByCop:
GET_PED_TYPE hChar (iPedType)
IF iPedType = 6
IF HAS_CHAR_SPOTTED_CHAR hChar scplayer
GET_SCRIPT_TASK_STATUS hChar 0x5C0 (i)
IF i = 7
TASK_LOOK_AT_VEHICLE hChar hVeh (3000)
ENDIF
ALTER_WANTED_LEVEL_NO_DROP iPlayerId 1
ENDIF
ENDIF
RETURN
}
SCRIPT_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment