Here are some codes for people that are starting to code. Feel free to post your own codes too.
Hijack players vehicle
Spectate Selected Player
Maybe these codes have been released before but not sure sorry if they have its just a few you help people if you need help comment below.
Hijack players vehicle
Code:
void Freeze(Ped selectedPed)
{
AI::CLEAR_PED_TASKS_IMMEDIATELY(selectedPed);
AI::CLEAR_PED_SECONDARY_TASK(selectedPed);
}
void JackCar(Ped selectedPlayer)
{
Vehicle selectedPlayerVeh = PED::GET_VEHICLE_PED_IS_IN(selectedPlayer, 0);
if (PED::IS_PED_IN_ANY_VEHICLE(selectedPlayer, false))
{
if (ENTITY::DOES_ENTITY_EXIST(selectedPlayer))
{
if (PED::IS_PED_IN_ANY_VEHICLE(selectedPlayer, 0))
{
Freeze(selectedPlayer);
Objects::RequestNetworkControl(selectedPlayerVeh);
Vector3 playerPedPos = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), 0);
for (int i = 0; i < 18; i++)
{
if (PED::IS_PED_IN_VEHICLE(PLAYER::GET_PLAYER_PED(i), selectedPlayerVeh, 0))
{
Freeze(PLAYER::GET_PLAYER_PED(i));
}
}
ENTITY::SET_ENTITY_COORDS(selectedPlayerVeh, playerPedPos.x, playerPedPos.y, playerPedPos.z, 0, 0, 0, 1);
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), selectedPlayerVeh, -1);
}
}
}
}
Code:
void SpectateMode(bool Active, Ped selectedPed)
{
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(Active, selectedPed);
}
void AIWanderCar(Ped playerPed)
{
Vehicle playerVeh = PED::GET_VEHICLE_PED_IS_USING(playerPed);
AI::TASK_VEHICLE_DRIVE_WANDER(playerPed, playerVeh, 100.0f, 0);
}
void SpectatePlayer(Ped playerped)
{
Any SpectateCam;
Vector3 playerPosition = ENTITY::GET_ENTITY_COORDS(playerped, false);
SpectateCam = CAM::CREATE_CAM_WITH_PARAMS("DEFAULT_SCRIPTED_FLY_CAMERA", playerPosition.x, playerPosition.y, playerPosition.z, 0.0, 0.0, 0.0, 50.0, 0, 2);
CAM::ATTACH_CAM_TO_ENTITY(SpectateCam, playerped, 0, -5, 1, 1);
CAM::SET_CAM_ACTIVE(playerped, 1);
}
example: addBoolOption("Spectate Player", SPECTATE);
if (SPECTATE == true)
{
AIWanderCar(PLAYER::PLAYER_PED_ID());
SpectateMode(true, PLAYER::GET_PLAYER_PED(selectedPlayer));
}
if (SPECTATE == false)
{
SpectateMode(false, PLAYER::GET_PLAYER_PED(selectedPlayer));
AI::CLEAR_PED_TASKS(PLAYER::PLAYER_ID());
}
Maybe these codes have been released before but not sure sorry if they have its just a few you help people if you need help comment below.
Code:
if (Fresh)
{
Notify("FBModderFresh");
Notify("SanjuroDev");
}