Scaleform question

Hey sorry to bother you I was just reading this topic and was wondering if you knew how to get the phone into the hand with the animations. This is as far as I have gotten.

As you can see the phone works but stuck on how to put it into the hand with the animations like this

2 Likes

You might want to talk to @manups4e. He’s gotten way further with this than me. He even wanted help with the applications.

If you’d be so kind and share the code once you’re done, that would be great :slightly_smiling_face:. I’ve sent my code to manups, but it looks like you are already further than what he initially was, so that won’t be much help to you

this is what i’ve done so far
phoneGTAC#.zip (16.5 KB)
to use the phone in animation (real object) you must use renderer id and render the scaleform into the phone object :slight_smile: it’s easy

Hi thanks for the replies I’ve put together a fairly straight forward API to go with the phone so once I’ve got it a bit more fully featured ill look to sharing what I’ve learned thank you so much for the help!

2 Likes

@manups4e

What animation do you use for the phone as the animation / object I am using requires me to look down to actually see the phone. Here is a screenshot :smile:

CreateMobilePhone((int)ModelPhone.Micheal)

That’s really strange, I did the same thing yet it doesn’t create the phone in your hand

                SetMobilePhonePosition(0.0f, 0.0f, 0.0f);
                CreateMobilePhone(0);
1 Like
using System;
using System.Threading.Tasks;
using CitizenFX.Core;
using client.Main.Phone.Applications;
using shared.Phone;
using static CitizenFX.Core.Native.API;
using shared.Util;

namespace client.Main.Phone
{
    class ClientPhone : BaseScript
    {
        public static PhoneData Phone;

        private static int VisibleAnimProgress = 0;

        public ClientPhone()
        {
            Phone = new PhoneData
            {
                Scaleform = RequestScaleformMovie("CELLPHONE_IFRUIT"),
                Theme = 3,
                Wallpaper = 5
            };
            AppFactory.CreateAllApps();
            Tick += OnTick;
        }

        private async Task OnTick()
        {
            if (Phone == null) // NPE Protection.
            {
                await Delay(100);
            }
            if (Phone.Visible)
            {
                SetMobilePhonePosition(60f, -21f - VisibleAnimProgress, -60f);
                SetMobilePhoneRotation(-90f, VisibleAnimProgress * 2f, 0f, 0);

                if (VisibleAnimProgress > 0)
                    VisibleAnimProgress -= 3;

                int h = 0;
                int m = 0;
                int s = 0;
                NetworkGetServerTime(ref h, ref m, ref s);
                PushScaleformMovieFunction(Phone.Scaleform, "SET_TITLEBAR_TIME");
                PushScaleformMovieFunctionParameterInt(h);
                PushScaleformMovieFunctionParameterInt(m);
                PopScaleformMovieFunctionVoid();

                PushScaleformMovieFunction(Phone.Scaleform, "SET_SLEEP_MODE");
                PushScaleformMovieFunctionParameterBool(Phone.SleepMode);
                PopScaleformMovieFunctionVoid();

                PushScaleformMovieFunction(Phone.Scaleform, "SET_THEME");
                PushScaleformMovieFunctionParameterInt(Phone.Theme);
                PopScaleformMovieFunctionVoid();

                PushScaleformMovieFunction(Phone.Scaleform, "SET_BACKGROUND_IMAGE");
                PushScaleformMovieFunctionParameterInt(Phone.Wallpaper);
                PopScaleformMovieFunctionVoid();

                PushScaleformMovieFunction(Phone.Scaleform, "SET_SIGNAL_STRENGTH");
                Vector3 playerCoords = GetEntityCoords(PlayerPedId(),true);
                PushScaleformMovieFunctionParameterInt(GetZoneScumminess(GetZoneAtCoords(playerCoords.X, playerCoords.Y, playerCoords.Z)));
                PopScaleformMovieFunctionVoid();

                int renderID = 0;
                GetMobilePhoneRenderId(ref renderID);
                SetTextRenderId(renderID);
                DrawScaleformMovie(Phone.Scaleform, 0.0998f, 0.1775f, 0.1983f, 0.364f, 255, 255, 255, 255, 0);
                SetTextRenderId(1);

                // This allows the render target to switch between first and third person.
                float scale = 0;
                if (GetFollowPedCamViewMode() == 4)
                    scale = 0f;
                else
                    scale = 285f;
                SetMobilePhoneScale(scale);
            }
            else if (IsControlJustPressed(0,300))
            {
                PlaySoundFrontend(-1, "Pull_Out", "Phone_SoundSet_Default", true);
                while (!HasScaleformMovieLoaded(Phone.Scaleform))
                {
                    await Delay(0);
                }
                VisibleAnimProgress = 21;
                Phone.Visible = true;

                SetMobilePhonePosition(0.0f, 0.0f, 0.0f);
                CreateMobilePhone(0);
            }
        }

        public static void KillPhone()
        {
            Phone.Visible = false;
            DestroyMobilePhone();
            Game.PlayerPed.Task.ClearAll();
        }
    }
}

I’m going to make this public as others may benefit from this conversation or be able to help.

I’VE RELEASED MY CODE SO FAR… YOU CAN SEE IT HERE

Awesome work so far I managed to get a bit further with mine so I’ll release what I have learnt about at some point!