mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
optimize(scripts/anims): Optimized and organized open/close animations
This commit is contained in:
1 parent
47e1f2950e
commit
368a8c57f8
1 file changed
+47
-60
+47
-60
@@ -29,9 +29,9 @@ const newPhoneProp = async () => {
|
|||||||
deletePhone(); //deletes the already existing prop before creating another.
|
deletePhone(); //deletes the already existing prop before creating another.
|
||||||
if (!propCreated) {
|
if (!propCreated) {
|
||||||
RequestModel(phoneModel);
|
RequestModel(phoneModel);
|
||||||
|
|
||||||
while (!HasModelLoaded(phoneModel)) {
|
while (!HasModelLoaded(phoneModel)) {
|
||||||
await Delay(1);
|
await Delay(1);
|
||||||
console.log('MODEL HASNT LOADED');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const playerPed = PlayerPedId();
|
const playerPed = PlayerPedId();
|
||||||
@@ -78,7 +78,6 @@ function deletePhone() {
|
|||||||
DeleteEntity(prop);
|
DeleteEntity(prop);
|
||||||
prop = 0;
|
prop = 0;
|
||||||
propCreated = false;
|
propCreated = false;
|
||||||
console.log('prop destroyed');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,25 +89,19 @@ async function loadAnimDict(dict: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function phoneOpenAnim() {
|
const handleOpenVehicleAnim = async (playerPed: number): Promise<void> => {
|
||||||
//Phone Open Animation
|
|
||||||
console.log('phoneOpenAnim'); //Left for testing purposes.
|
|
||||||
const flag = 50; //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94
|
|
||||||
deletePhone(); //Deleting before creating a new phone where itll be deleted again.
|
|
||||||
if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) {
|
|
||||||
//-- true refers to at get in.
|
|
||||||
const dict = 'anim@cellphone@in_car@ps';
|
const dict = 'anim@cellphone@in_car@ps';
|
||||||
|
|
||||||
ClearPedTasks(GetPlayerPed(-1));
|
ClearPedTasks(playerPed);
|
||||||
await loadAnimDict(dict);
|
await loadAnimDict(dict);
|
||||||
TaskPlayAnim(
|
TaskPlayAnim(
|
||||||
GetPlayerPed(-1),
|
playerPed,
|
||||||
dict,
|
dict,
|
||||||
'cellphone_text_in',
|
'cellphone_text_in',
|
||||||
8.0,
|
8.0,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
flag,
|
50,
|
||||||
0,
|
0,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
@@ -116,20 +109,22 @@ async function phoneOpenAnim() {
|
|||||||
);
|
);
|
||||||
await Delay(300); //Gives time for animation starts before creating the phone
|
await Delay(300); //Gives time for animation starts before creating the phone
|
||||||
await newPhoneProp(); //Creates the phone and attaches it.
|
await newPhoneProp(); //Creates the phone and attaches it.
|
||||||
} else {
|
};
|
||||||
|
|
||||||
|
const handleOpenNormalAnim = async (playerPed: number): Promise<void> => {
|
||||||
//While not in a vehicle it will use this dict.
|
//While not in a vehicle it will use this dict.
|
||||||
const dict = 'cellphone@';
|
const dict = 'cellphone@';
|
||||||
|
|
||||||
ClearPedTasks(GetPlayerPed(-1));
|
ClearPedTasks(playerPed);
|
||||||
await loadAnimDict(dict);
|
await loadAnimDict(dict);
|
||||||
TaskPlayAnim(
|
TaskPlayAnim(
|
||||||
GetPlayerPed(-1),
|
playerPed,
|
||||||
dict,
|
dict,
|
||||||
'cellphone_text_in',
|
'cellphone_text_in',
|
||||||
8.0,
|
8.0,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
flag,
|
50,
|
||||||
0,
|
0,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
@@ -137,61 +132,53 @@ async function phoneOpenAnim() {
|
|||||||
);
|
);
|
||||||
await Delay(300); //Gives time for animation starts before creating the phone
|
await Delay(300); //Gives time for animation starts before creating the phone
|
||||||
await newPhoneProp(); //Creates the phone and attaches it.
|
await newPhoneProp(); //Creates the phone and attaches it.
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
async function phoneCloseAnim() {
|
const handleCloseVehicleAnim = async (playerPed: number): Promise<void> => {
|
||||||
//Phone Close Animation
|
|
||||||
console.log('phoneCloseAnim'); //Left for testing purposes.
|
|
||||||
const flag = 50; //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94
|
|
||||||
const anim = 'cellphone_text_out';
|
|
||||||
if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) {
|
|
||||||
//true refers to at get in.
|
//true refers to at get in.
|
||||||
const dict = 'anim@cellphone@in_car@ps';
|
const DICT = 'anim@cellphone@in_car@ps';
|
||||||
|
const ANIM = 'cellphone_text_out';
|
||||||
|
|
||||||
StopAnimTask(GetPlayerPed(-1), dict, 'cellphone_text_in', 1.0); //Stop the pull out animation
|
StopAnimTask(playerPed, DICT, 'cellphone_text_in', 1.0); //Stop the pull out animation
|
||||||
deletePhone(); //Deletes the prop early incase they get out of the vehicle.
|
deletePhone(); //Deletes the prop early incase they get out of the vehicle.
|
||||||
await Delay(250); //lets it get to a certain point
|
await Delay(250); //lets it get to a certain point
|
||||||
loadAnimDict(dict); //loads the new animation
|
await loadAnimDict(DICT); //loads the new animation
|
||||||
TaskPlayAnim(
|
TaskPlayAnim(playerPed, DICT, ANIM, 8.0, -1, -1, 50, 0, false, false, false); //puts phone into pocket
|
||||||
GetPlayerPed(-1),
|
|
||||||
dict,
|
|
||||||
anim,
|
|
||||||
8.0,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
flag,
|
|
||||||
0,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
); //puts phone into pocket
|
|
||||||
await Delay(200); //waits until the phone is in the pocket
|
await Delay(200); //waits until the phone is in the pocket
|
||||||
StopAnimTask(GetPlayerPed(-1), dict, anim, 1.0); //clears the animation
|
StopAnimTask(playerPed, DICT, ANIM, 1.0); //clears the animation
|
||||||
} else {
|
};
|
||||||
//While not in a vehicle it will use this dict.
|
|
||||||
const dict = 'cellphone@';
|
|
||||||
|
|
||||||
StopAnimTask(GetPlayerPed(-1), dict, 'cellphone_text_in', 1.0); //Stop the pull out animation
|
const handleCloseNormalAnim = async (playerPed: number): Promise<void> => {
|
||||||
|
const DICT = 'cellphone@';
|
||||||
|
const ANIM = 'cellphone_text_out';
|
||||||
|
StopAnimTask(playerPed, DICT, 'cellphone_text_in', 1.0); //Stop the pull out animation
|
||||||
await Delay(100); //lets it get to a certain point
|
await Delay(100); //lets it get to a certain point
|
||||||
loadAnimDict(dict); //loads the new animation
|
await loadAnimDict(DICT); //loads the new animation
|
||||||
TaskPlayAnim(
|
TaskPlayAnim(playerPed, DICT, ANIM, 8.0, -1, -1, 50, 0, false, false, false); //puts phone into pocket
|
||||||
GetPlayerPed(-1),
|
|
||||||
dict,
|
|
||||||
anim,
|
|
||||||
8.0,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
flag,
|
|
||||||
0,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
); //puts phone into pocket
|
|
||||||
await Delay(200); //waits until the phone is in the pocket
|
await Delay(200); //waits until the phone is in the pocket
|
||||||
StopAnimTask(GetPlayerPed(-1), dict, anim, 1.0); //clears the animation
|
StopAnimTask(playerPed, DICT, ANIM, 1.0); //clears the animation
|
||||||
deletePhone(); //Deletes the prop.
|
deletePhone(); //Deletes the prop.
|
||||||
|
};
|
||||||
|
|
||||||
|
// Determines the phoneOpen animation to play
|
||||||
|
async function phoneOpenAnim(): Promise<void> {
|
||||||
|
const playerPed = PlayerPedId();
|
||||||
|
console.log('phoneOpenAnim'); //Left for testing purposes.
|
||||||
|
deletePhone(); //Deleting before creating a new phone where itll be deleted again.
|
||||||
|
if (IsPedInAnyVehicle(playerPed, true)) {
|
||||||
|
return await handleOpenVehicleAnim(playerPed);
|
||||||
}
|
}
|
||||||
|
return await handleOpenNormalAnim(playerPed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determines the phoneClose animation to play
|
||||||
|
async function phoneCloseAnim() {
|
||||||
|
const playerPed = PlayerPedId();
|
||||||
|
console.log('phoneCloseAnim'); //Left for testing purposes.
|
||||||
|
if (IsPedInAnyVehicle(playerPed, true)) {
|
||||||
|
return await handleCloseVehicleAnim(playerPed);
|
||||||
|
}
|
||||||
|
await handleCloseNormalAnim(playerPed);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function carryingPhone(cb: any) {
|
async function carryingPhone(cb: any) {
|
||||||
|
|||||||
Reference in new issue
Block a user