updated formatting on cl_main.ts

This commit is contained in:
erik-sn committed 2020-10-17 18:34:19 -04:00
1 parent 11f0302fea
commit 65dd1c03c2
1 file changed
+106 -67
+106 -67
View File
@@ -90,21 +90,35 @@ async function loadAnimDict(dict: any) {
} }
} }
async function phoneOpenAnim() { //Phone Open Animation async function phoneOpenAnim() {
console.log("phoneOpenAnim") //Left for testing purposes. //Phone Open Animation
const flag = 50 //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94 console.log("phoneOpenAnim"); //Left for testing purposes.
deletePhone() //Deleting before creating a new phone where itll be deleted again. const flag = 50; //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94
if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) { //-- true refers to at get in. deletePhone(); //Deleting before creating a new phone where itll be deleted again.
const dict = 'anim@cellphone@in_car@ps' if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) {
//-- true refers to at get in.
const dict = "anim@cellphone@in_car@ps";
ClearPedTasks(GetPlayerPed(-1)) ClearPedTasks(GetPlayerPed(-1));
await loadAnimDict(dict) await loadAnimDict(dict);
TaskPlayAnim(GetPlayerPed(-1), dict, 'cellphone_text_in', 8.0, -1, -1, flag, 0, false, false, false) TaskPlayAnim(
await Delay(300) //Gives time for animation starts before creating the phone GetPlayerPed(-1),
await newPhoneProp() //Creates the phone and attaches it. dict,
} "cellphone_text_in",
else { //While not in a vehicle it will use this dict. 8.0,
const dict = 'cellphone@' -1,
-1,
flag,
0,
false,
false,
false
);
await Delay(300); //Gives time for animation starts before creating the phone
await newPhoneProp(); //Creates the phone and attaches it.
} else {
//While not in a vehicle it will use this dict.
const dict = "cellphone@";
ClearPedTasks(GetPlayerPed(-1)); ClearPedTasks(GetPlayerPed(-1));
await loadAnimDict(dict); await loadAnimDict(dict);
@@ -126,32 +140,58 @@ async function phoneOpenAnim() { //Phone Open Animation
} }
} }
async function phoneCloseAnim() { //Phone Close Animation async function phoneCloseAnim() {
console.log("phoneCloseAnim") //Left for testing purposes. //Phone Close Animation
const flag = 50 //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94 console.log("phoneCloseAnim"); //Left for testing purposes.
const anim = 'cellphone_text_out' const flag = 50; //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94
if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) { //true refers to at get in. const anim = "cellphone_text_out";
const dict = 'anim@cellphone@in_car@ps' if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) {
//true refers to at get in.
const dict = "anim@cellphone@in_car@ps";
StopAnimTask(GetPlayerPed(-1), dict, 'cellphone_text_in', 1.0) //Stop the pull out animation StopAnimTask(GetPlayerPed(-1), 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 loadAnimDict(dict); //loads the new animation
TaskPlayAnim(GetPlayerPed(-1), dict, anim, 8.0, -1, -1, flag, 0, false, false, false) //puts phone into pocket TaskPlayAnim(
await Delay(200) //waits until the phone is in the pocket GetPlayerPed(-1),
StopAnimTask(GetPlayerPed(-1), dict, anim, 1.0) //clears the animation dict,
} anim,
else { //While not in a vehicle it will use this dict. 8.0,
const dict = 'cellphone@' -1,
-1,
flag,
0,
false,
false,
false
); //puts phone into pocket
await Delay(200); //waits until the phone is in the pocket
StopAnimTask(GetPlayerPed(-1), 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 StopAnimTask(GetPlayerPed(-1), 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 loadAnimDict(dict); //loads the new animation
TaskPlayAnim(GetPlayerPed(-1), dict, anim, 8.0, -1, -1, flag, 0, false, false, false) //puts phone into pocket TaskPlayAnim(
await Delay(200) //waits until the phone is in the pocket GetPlayerPed(-1),
StopAnimTask(GetPlayerPed(-1), dict, anim, 1.0) //clears the animation dict,
deletePhone() //Deletes the prop. 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
StopAnimTask(GetPlayerPed(-1), dict, anim, 1.0); //clears the animation
deletePhone(); //Deletes the prop.
}
} }
async function carryingPhone(cb: any) { async function carryingPhone(cb: any) {
@@ -188,12 +228,12 @@ setTick(() => {
async function Phone() { async function Phone() {
if (config.PhoneAsItem) { if (config.PhoneAsItem) {
console.log("CONFIG ON") console.log("CONFIG ON");
carryingPhone(async (carryingPhone: any) => { carryingPhone(async (carryingPhone: any) => {
if (carryingPhone) { if (carryingPhone) {
if (!isPhoneOpen) { if (!isPhoneOpen) {
isPhoneOpen = true isPhoneOpen = true;
await phoneOpenAnim() await phoneOpenAnim();
emitNet(events.CONTACTS_GET_CONTACTS); emitNet(events.CONTACTS_GET_CONTACTS);
emitNet("phone:getCredentials"); // Gets the credentials. Will eventually most likely only get the phone number and name, idk. emitNet("phone:getCredentials"); // Gets the credentials. Will eventually most likely only get the phone number and name, idk.
SetCursorLocation(0.936, 0.922); //Experimental SetCursorLocation(0.936, 0.922); //Experimental
@@ -204,32 +244,31 @@ async function Phone() {
method: "setVisibility", method: "setVisibility",
data: true, data: true,
}) })
) );
sendPhoneConfig() sendPhoneConfig();
SetNuiFocus(true, true) SetNuiFocus(true, true);
} } else {
else { isPhoneOpen = false;
isPhoneOpen = false await phoneCloseAnim();
await phoneCloseAnim() SendNuiMessage(
SendNuiMessage( //Hides phone //Hides phone
JSON.stringify({ JSON.stringify({
app: "PHONE", app: "PHONE",
method: "setVisibility", method: "setVisibility",
data: false, data: false,
}) })
) );
SetNuiFocus(false, false) SetNuiFocus(false, false);
} }
} else { } else {
noPhone(); noPhone();
} }
}) });
} } else if (!config.PhoneAsItem) {
else if (!config.PhoneAsItem) { console.log("CONFIG OFF");
console.log("CONFIG OFF")
if (!isPhoneOpen) { if (!isPhoneOpen) {
isPhoneOpen = true isPhoneOpen = true;
await phoneOpenAnim() await phoneOpenAnim();
emitNet(events.CONTACTS_GET_CONTACTS); emitNet(events.CONTACTS_GET_CONTACTS);
emitNet("phone:getCredentials"); emitNet("phone:getCredentials");
SetCursorLocation(0.936, 0.922); //Experimental SetCursorLocation(0.936, 0.922); //Experimental
@@ -240,21 +279,21 @@ async function Phone() {
method: "setVisibility", method: "setVisibility",
data: true, data: true,
}) })
) );
sendPhoneConfig() sendPhoneConfig();
SetNuiFocus(true, true) SetNuiFocus(true, true);
} } else {
else { isPhoneOpen = false;
isPhoneOpen = false await phoneCloseAnim();
await phoneCloseAnim() SendNuiMessage(
SendNuiMessage( //Hides phone //Hides phone
JSON.stringify({ JSON.stringify({
app: "PHONE", app: "PHONE",
method: "setVisibility", method: "setVisibility",
data: false, data: false,
}) })
) );
SetNuiFocus(false, false) SetNuiFocus(false, false);
} }
} }
} }