local animDic = nil local animName = nil local IsTyping = false local phoneAnimations = { default = { base = { dict = "cellphone@", anim = "cellphone_text_read_base" }, enter = { dict = "cellphone@", anim = "cellphone_text_in" }, exit = { dict = "cellphone@", anim = "cellphone_text_out" }, readBase = { dict = "cellphone@", anim = "cellphone_text_read_base" }, car = { dict = "anim@cellphone@in_car@ps", anim = "cellphone_text_in" } }, camera = { selfie = { dict = "cellphone@self", anim = "selfie" }, photo = { dict = "cellphone@", anim = "cellphone_photo_idle" } }, call = { base = { dict = "cellphone@", anim = "cellphone_call_listen_base" } }, typing = { base = { dict = "amb@world_human_stand_mobile@male@text@base", anim = "base" } } } local function LoadAnimation(dict) if dict ~= nil then LoadAnimDict(dict) end end local function CheckAnimLoop() CreateThread(function() local carin = false local readDict = phoneAnimations["default"]["readBase"].dict local readAnim = phoneAnimations["default"]["readBase"].anim local carDict = phoneAnimations["default"]["car"].dict local carAnim = phoneAnimations["default"]["car"].anim local typingDict = phoneAnimations["typing"]["base"].dict local typingAnim = phoneAnimations["typing"]["base"].anim while animDic ~= nil and animName ~= nil do local ped = PlayerPedId() local vehicleIn = IsPedInAnyVehicle(ped, true) if not carin and vehicleIn and not CameraOpen then carin = true LoadAnimation(carDict) TaskPlayAnim(ped, carDict, carAnim, 7.0, -1, -1, 50, 0, false, false, false) elseif not vehicleIn and carin and not CameraOpen then carin = false elseif not carin and not IsEntityPlayingAnim(ped, readDict, readAnim, 3) and (IsPedRunning(ped) or IsPedSprinting(ped)) and not CameraOpen and not Incall and not IsTyping then LoadAnimation(readDict) TaskPlayAnim(ped, readDict, readAnim, 3.0, 3.0, -1, 50, 0, false, false, false) elseif not carin and IsTyping and not IsEntityPlayingAnim(ped, typingDict, typingAnim, 3) and not (IsPedRunning(ped) or IsPedSprinting(ped)) and not CameraOpen and not Incall then LoadAnimation(typingDict) TaskPlayAnim(ped, typingDict, typingAnim, 8.0, -8.0, -1, 49, 0, false, false, false) elseif not carin and not IsTyping and not IsEntityPlayingAnim(ped, animDic, animName, 3) and not (IsPedRunning(ped) or IsPedSprinting(ped)) and not CameraOpen then LoadAnimation(animDic) TaskPlayAnim(ped, animDic, animName, 8.0, -8.0, -1, 49, 0, false, false, false) end Wait(500) end end) end function PhoneDoAnim(anim) local player = PlayerId() local ped = GetPlayerPed(player) LoadModel(GetHashKey(propName)) if IsInCall() and anim ~= "selfie" and anim ~= "camera" then anim = "call" end if anim == "phone" then if PhoneProp ~= nil then DeleteEntity(PhoneProp) PhoneProp = nil end animDic = phoneAnimations["default"]["base"].dict animName = phoneAnimations["default"]["base"].anim local enterDic = phoneAnimations["default"]["enter"].dict local enterName = phoneAnimations["default"]["enter"].anim LoadAnimation(enterDic) LoadModel(GetHashKey(propName)) PhoneProp = CreateObject(GetHashKey(propName), 1.0, 1.0, 1.0, true, true, false) AttachEntityToEntity(PhoneProp, ped, GetPedBoneIndex(ped, 28422), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true) TaskPlayAnim(PlayerPedId(), enterDic, enterName, 8.0, 1.0, -1, 49, 0, false, false, false) Wait(800) if animDic == nil then return end LoadAnimation(animDic) if not CameraOpen then TaskPlayAnim(PlayerPedId(), animDic, animName, 8.0, -8.0, -1, 49, 0, false, false, false) end elseif anim == "selfie" then animDic = phoneAnimations["camera"]["selfie"].dict animName = phoneAnimations["camera"]["selfie"].anim LoadAnimation(animDic) TaskPlayAnim(ped, animDic, animName, 8.0, -8.0, -1, 49, 0, false, false, false) elseif anim == "camera" then animDic = phoneAnimations["camera"]["photo"].dict animName = phoneAnimations["camera"]["photo"].anim LoadAnimation(animDic) TaskPlayAnim(ped, animDic, animName, 8.0, -8.0, -1, 49, 0, false, false, false) elseif anim == "exit" then animDic = nil animName = nil IsTyping = false local exitDic = phoneAnimations["default"]["exit"].dict local exitName = phoneAnimations["default"]["exit"].anim LoadAnimation(exitDic) TaskPlayAnim(PlayerPedId(), exitDic, exitName, 8.0, 1.0, -1, 49, 0, false, false, false) Wait(500) if PhoneProp ~= nil then DeleteEntity(PhoneProp) end PhoneProp = nil ClearPedSecondaryTask(PlayerPedId()) return elseif anim == "call" then if PhoneProp == nil then LoadModel(GetHashKey(propName)) PhoneProp = CreateObject(GetHashKey(propName), 1.0, 1.0, 1.0, true, true, false) AttachEntityToEntity(PhoneProp, ped, GetPedBoneIndex(ped, 28422), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true) end animDic = phoneAnimations["call"]["base"].dict animName = phoneAnimations["call"]["base"].anim LoadAnimation(animDic) TaskPlayAnim(ped, animDic, animName, 8.0, -8.0, -1, 49, 0, false, false, false) elseif anim == "base" then if PhoneProp ~= nil then DeleteEntity(PhoneProp) PhoneProp = nil end animDic = phoneAnimations["default"]["base"].dict animName = phoneAnimations["default"]["base"].anim LoadAnimation(animDic) LoadModel(GetHashKey(propName)) PhoneProp = CreateObject(GetHashKey(propName), 1.0, 1.0, 1.0, true, true, false) AttachEntityToEntity(PhoneProp, ped, GetPedBoneIndex(ped, 28422), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true) TaskPlayAnim(PlayerPedId(), animDic, animName, 8.0, -8.0, -1, 49, 0, false, false, false) end CheckAnimLoop() end function PhoneTypingAnim(isTyping) IsTyping = isTyping local ped = PlayerPedId() local vehicleIn = IsPedInAnyVehicle(ped, true) if vehicleIn or CameraOpen or Incall then return end if isTyping then local typingDict = phoneAnimations["typing"]["base"].dict local typingAnim = phoneAnimations["typing"]["base"].anim LoadAnimation(typingDict) TaskPlayAnim(ped, typingDict, typingAnim, 8.0, -8.0, -1, 49, 0, false, false, false) else if animDic ~= nil and animName ~= nil then LoadAnimation(animDic) TaskPlayAnim(ped, animDic, animName, 8.0, -8.0, -1, 49, 0, false, false, false) end end end