Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SCRIPT_START
{
LVAR_INT scplayer
LVAR_INT veh char
LVAR_INT veh_model veh_class cped pedtype createdby
LVAR_FLOAT x y z
GET_PLAYER_CHAR 0 scplayer
main_loop:
WAIT 0
IF IS_PLAYER_PLAYING 0
//IF TEST_CHEAT TEST
//IF GET_RANDOM_CAR_IN_SPHERE_NO_SAVE_RECURSIVE (x y z) 10.0 (FALSE, TRUE) veh
//CREATE_CHAR_INSIDE_CAR veh PEDTYPE_GANG2 7 char
//CREATE_CHAR_AS_PASSENGER veh PEDTYPE_GANG2 7 0 char
//ADD_BLIP_FOR_CHAR char cped
//GET_PED_POINTER char cped
//CALL_METHOD 0x5E47E0 cped 1 0 (1) // CPed::SetCharCreatedBy
//ENDIF
//ENDIF
GET_CHAR_COORDINATES scplayer (x y z)
IF GET_RANDOM_CHAR_IN_SPHERE_NO_SAVE_RECURSIVE (x y z) 200.0 (FALSE, TRUE) char
GOSUB apply
WHILE GET_RANDOM_CHAR_IN_SPHERE_NO_SAVE_RECURSIVE (x y z) 200.0 (TRUE, TRUE) char
GOSUB apply
ENDWHILE
ENDIF
ENDIF
GOTO main_loop
apply:
IF IS_CHAR_MODEL char 7 // MALE01
GET_PED_POINTER char cped
createdby = cped + 0x484
READ_MEMORY createdby 1 FALSE createdby
IF createdby = 1 // created by RANDOM (not a script ped)
IF IS_CHAR_SITTING_IN_ANY_CAR char
STORE_CAR_CHAR_IS_IN_NO_SAVE char veh
//////// ON CAR ////////
// - Fix by vehicle model
GET_CAR_MODEL veh veh_model
IF veh_model = 532 //combine
OR veh_model = 531 //tractor
OR veh_model = 537 //freight
OR veh_model = 538 //streak
OR veh_model = 463 //freeway
CLEO_CALL update_char_model_by_vehicle_model 0 (char, veh, veh_model)()
ENDIF
// - Fix by vehicle class
GET_VEHICLE_CLASS veh veh_class
IF veh_class = 4 //worker
OR veh_class = 6 //taxi
CLEO_CALL update_char_model_by_vehicle_class 0 (char, veh, veh_class)()
ENDIF
// - Fix by pedtype
GET_PED_TYPE char pedtype
IF pedtype >= 7
AND pedtype <= 16
CLEO_CALL update_char_model_by_gang_pedtype 0 (char, pedtype, veh)()
ENDIF
ELSE
//////// ON FOOT ////////
// - Fix by pedtype
GET_PED_TYPE char pedtype
IF pedtype >= 7
AND pedtype <= 16
CLEO_CALL update_char_model_by_gang_pedtype 0 (char, pedtype, -1)()
ENDIF
ENDIF
ENDIF
ENDIF
RETURN
}
/////////////////////////////////////////////////
{
LVAR_INT char // in
LVAR_INT pedtype // in
LVAR_INT veh // in
LVAR_FLOAT char_x char_y char_z
LVAR_INT char_model cped gang_id driver
// var types
CREATE_CHAR 0 0 0.0 0.0 0.0 char
update_char_model_by_gang_pedtype:
IF NOT veh = -1
// Only recreate the char if it's the driver. If passenger, just delete it, because of a bug
GET_DRIVER_OF_CAR veh driver
IF NOT driver = char
DELETE_CHAR char
CLEO_RETURN 0
ENDIF
ENDIF
gang_id = pedtype - 6 // GANG1("7") now is ID "1"
CLEO_CALL get_char_model_by_gang_id 0 (gang_id)(char_model)
REQUEST_MODEL char_model
LOAD_ALL_MODELS_NOW
CLEO_CALL change_char_model 0 (char, char_model)()
IF veh > -1
CLEO_CALL reput_char_in_veh 0 (char, veh)()
ENDIF
MARK_MODEL_AS_NO_LONGER_NEEDED char_model
CLEO_RETURN 0
}
{
LVAR_INT gang_id // in
LVAR_INT temp model_id
get_char_model_by_gang_id:
gang_id--
GET_VAR_POINTER model_id temp
CALL_FUNCTION 0x443A20 2 2 (temp, gang_id) // CGangWars::GetLoadedGangPed
CLEO_RETURN 0 model_id
}
{
LVAR_INT char // in
LVAR_INT veh // in
LVAR_INT veh_model // in
LVAR_INT char_model driver
// var types
CREATE_CHAR 0 0 0.0 0.0 0.0 char
CREATE_CAR 0 0.0 0.0 0.0 veh
update_char_model_by_vehicle_model:
// Only change the char if it's the driver. If passenger, not, because of a bug
GET_DRIVER_OF_CAR veh driver
IF NOT driver = char
CLEO_RETURN 0
ENDIF
GOSUB get_char_model_by_veh_model
REQUEST_MODEL char_model
LOAD_ALL_MODELS_NOW
CLEO_CALL change_char_model 0 (char, char_model)()
// Only reput (fix sit anim) if isn't a train, because of a bug
IF NOT veh_model = 537 //freight
AND NOT veh_model = 538 //streak
CLEO_CALL reput_char_in_veh 0 (char, veh)()
ENDIF
MARK_MODEL_AS_NO_LONGER_NEEDED char_model
CLEO_RETURN 0
get_char_model_by_veh_model:
SWITCH veh_model
CASE 532 //combine
CASE 531 //tractor
GENERATE_RANDOM_INT_IN_RANGE 158 163 char_model
BREAK
CASE 537 //freight
CASE 538 //streak
char_model = 253 //BMOSEC
BREAK
CASE 463 //freeway
char_model = 248 //BIKERA
BREAK
ENDSWITCH
RETURN
}
{
LVAR_INT char // in
LVAR_INT veh // in
LVAR_INT veh_class // in
LVAR_INT char_model driver
// var types
CREATE_CHAR 0 0 0.0 0.0 0.0 char
CREATE_CAR 0 0.0 0.0 0.0 veh
update_char_model_by_vehicle_class:
// Only change the char if it's the driver. If passenger, not, because of a bug
GET_DRIVER_OF_CAR veh driver
IF NOT driver = char
CLEO_RETURN 0
ENDIF
GOSUB get_char_model_by_veh_class
REQUEST_MODEL char_model
LOAD_ALL_MODELS_NOW
CLEO_CALL change_char_model 0 (char, char_model)()
CLEO_CALL reput_char_in_veh 0 (char, veh)()
MARK_MODEL_AS_NO_LONGER_NEEDED char_model
CLEO_RETURN 0
get_char_model_by_veh_class:
SWITCH veh_class
CASE 4 //worker
char_model = 50 //WMYMECH
BREAK
CASE 6 //taxi
char_model = 253 //BMOSEC
BREAK
ENDSWITCH
RETURN
}
{
LVAR_INT char // in
LVAR_INT char_model // in
LVAR_INT cped cpedsound
// var types
CREATE_CHAR 0 0 0.0 0.0 0.0 char
change_char_model:
GET_PED_POINTER char cped
CALL_METHOD 0x5E4880 cped 1 0 (char_model) // CPed::setModelIndex
cpedsound = cped + 0x294
CALL_METHOD 0x4E68D0 cpedsound 1 0 (cped) // CPedSound::setPedSound
CLEO_RETURN 0
}
{
LVAR_INT char // in
LVAR_INT veh // in
LVAR_INT current_seat
LVAR_FLOAT x y z
// var types
CREATE_CHAR 0 0 0.0 0.0 0.0 char
CREATE_CAR 0 0.0 0.0 0.0 veh
reput_char_in_veh: // FIX ME!
//CLEO_CALL get_char_current_seat_in_vehicle 0 (char, veh)(current_seat)
GET_OFFSET_FROM_CAR_IN_WORLD_COORDS veh 0.0 0.0 -20.0 x y z
WARP_CHAR_FROM_CAR_TO_COORD char x y z
//IF current_seat = -1
//TASK_WARP_CHAR_INTO_CAR_AS_DRIVER char veh
WARP_CHAR_INTO_CAR char veh
//ELSE
//TASK_WARP_CHAR_INTO_CAR_AS_PASSENGER char veh current_seat
//ENDIF
CLEO_RETURN 0
}
/*
{
LVAR_INT char // in
LVAR_INT veh // in
LVAR_INT cped cvehicle passengers_array passengers_element passenger counter
// var types
CREATE_CHAR 0 0 0.0 0.0 0.0 char
CREATE_CAR 0 0.0 0.0 0.0 veh
get_char_current_seat_in_vehicle:
GET_PED_POINTER char cped
GET_VEHICLE_POINTER veh cvehicle
passengers_array = cvehicle + 0x464
REPEAT 7 counter
passengers_element = passengers_array
READ_MEMORY passengers_element 4 FALSE passenger
IF passenger = cped
CLEO_RETURN 0 counter
ENDIF
ENDREPEAT
CLEO_RETURN 0 -1
}
*/
SCRIPT_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.