Merge pull request #13 from Re-Ignited-Development/fix/animations

Fix/animations
This commit is contained in:
Christopher Gjelten authored and GitHub committed 2020-10-17 22:35:44 +02:00
commit 65285c1d02
1 file changed
+9 -13
+9 -13
View File
@@ -62,11 +62,11 @@ async function loadAnimDict(dict: any) { //-- Loads the animation dict. Used in
} }
async function phoneOpenAnim() { //Phone Open Animation async function phoneOpenAnim() { //Phone Open Animation
console.log("phoneOpenAnim") //Left for testing purposes.
const flag = 50 //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94 const flag = 50 //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94
deletePhone() //Deleting before creating a new phone where itll be deleted again. deletePhone() //Deleting before creating a new phone where itll be deleted again.
if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) { //-- true refers to at get in. 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'
const kek = "pepein"
ClearPedTasks(GetPlayerPed(-1)) ClearPedTasks(GetPlayerPed(-1))
await loadAnimDict(dict) await loadAnimDict(dict)
@@ -76,7 +76,6 @@ async function phoneOpenAnim() { //Phone Open Animation
} }
else { //While not in a vehicle it will use this dict. else { //While not in a vehicle it will use this dict.
const dict = 'cellphone@' const dict = 'cellphone@'
const kek = "pepeout"
ClearPedTasks(GetPlayerPed(-1)) ClearPedTasks(GetPlayerPed(-1))
await loadAnimDict(dict) await loadAnimDict(dict)
@@ -87,28 +86,27 @@ async function phoneOpenAnim() { //Phone Open Animation
} }
async function phoneCloseAnim() { //Phone Close Animation async function phoneCloseAnim() { //Phone Close Animation
console.log("phoneCloseAnim") //Left for testing purposes.
const flag = 50 //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94 const flag = 50 //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94
const anim = 'cellphone_text_out' const anim = 'cellphone_text_out'
if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) { //true refers to at get in. 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'
const kek = "pepein"
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, 1, false, false, false) //puts phone into pocket TaskPlayAnim(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(GetPlayerPed(-1), dict, anim, 1.0) //clears the animation
} }
else { //While not in a vehicle it will use this dict. else { //While not in a vehicle it will use this dict.
const dict = 'cellphone@' const dict = 'cellphone@'
const kek = "pepeout"
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, 1, false, false, false) //puts phone into pocket TaskPlayAnim(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(GetPlayerPed(-1), dict, anim, 1.0) //clears the animation
deletePhone() //Deletes the prop. deletePhone() //Deletes the prop.
@@ -146,12 +144,12 @@ setTick(() => {
async function Phone() { async function Phone() {
if (config.PhoneAsItem) { if (config.PhoneAsItem) {
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()
console.log("phone is now open") //Left for testing purposes.
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
@@ -168,7 +166,7 @@ async function Phone() {
} }
else { else {
isPhoneOpen = false isPhoneOpen = false
console.log("phone is now closed") //Left for testing purposes. await phoneCloseAnim()
SendNuiMessage( //Hides phone SendNuiMessage( //Hides phone
JSON.stringify({ JSON.stringify({
app: "PHONE", app: "PHONE",
@@ -177,7 +175,6 @@ async function Phone() {
}) })
) )
SetNuiFocus(false, false) SetNuiFocus(false, false)
phoneCloseAnim()
} }
} }
else { else {
@@ -186,10 +183,10 @@ async function Phone() {
}) })
} }
else if (!config.PhoneAsItem) { else if (!config.PhoneAsItem) {
console.log("CONFIG OFF")
if (!isPhoneOpen) { if (!isPhoneOpen) {
isPhoneOpen = true isPhoneOpen = true
await phoneOpenAnim() await phoneOpenAnim()
console.log("phone is now open") //Left for testing purposes.
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
@@ -206,7 +203,7 @@ async function Phone() {
} }
else { else {
isPhoneOpen = false isPhoneOpen = false
console.log("phone is now closed") //Left for testing purposes. await phoneCloseAnim()
SendNuiMessage( //Hides phone SendNuiMessage( //Hides phone
JSON.stringify({ JSON.stringify({
app: "PHONE", app: "PHONE",
@@ -215,7 +212,6 @@ async function Phone() {
}) })
) )
SetNuiFocus(false, false) SetNuiFocus(false, false)
await phoneCloseAnim()
} }
} }
} }