What are scaleforms?
Scaleforms are an amazing part of GTA V, and make up nearly any display used in the game. For example, the entire web browser and pages themselves are done using scaleforms, which in this little guide, I will show you how to obtain their wonderful powers!
Well that sounds pretty neat, so how do we go about using them?
First of all, like most things, we will need to request the scaleform. This can be done using something such as:
local scaleform = RequestScaleformMovie("SCALEFORM") while not HasScaleformMovieLoaded(scaleform) do Citizen.Wait(0) end
Once this is done, we now can go onto pushing scaleform functions! This is the part where having the decompiled scaleforms comes in real handy.
To start off with, we will use the scaleform
"mp_big_message_freemode", so make sure to request that scaleform if following along! Now, here comes the tedious part, looking at the decompiled script for this scaleform, we can see that one of the functions are
"SHOW_SHARD_WASTED_MP_MESSAGE", this means that we can push this function, and maybe get something that looks neat from it, so lets try it!
Now, to begin with, we first push the scaleform function (Make sure to request the scaleform before doing this!) :
As you can see, we pass it the handle of the requested scaleform, and then push the function. So far, this isnt that complex is it? Who knew something so cool and neat can be done so simply!
Now, we need to feed it the parameters it wants, but wait, whats this? The function itself looks like it doesnt want any params, how strange? Don’t worry though, its not the end of the world! It just means we have to dig a bit deeper! So, looking at the function, it seems to take the 3rd argument (as it starts at index 0) and then pass that along with the other arguments to a variable called
Now, looking at this function, we can see a lot more useful information!
DO_SHARD(args, isCenter, colID, shardColID, useLargeShard)
It actually has arguments there! So, “SHOW_SHARD_WASTED_MP_MESSAGE” passes
arguments,true,_loc3_,undefined,true to DO_SHARD, and looking closer, uses the first two parameters as the large text and small text below. And now we can also see that the 3rd parameter it took is used for the colID (This seems to be what the large text colour starts as then transitions to the default text colour)! Neat, huh? Now, all this information means nothing without putting it to use, so lets do just that!
So we currently request the scaleform, and push one of the functions, now, we need to give it parameters to use. This can be accomplished like so:
BeginScaleformMovieMethod(scaleform, "SHOW_SHARD_WASTED_MP_MESSAGE") PushScaleformMovieMethodParameterString("SOME TEXT") PushScaleformMovieMethodParameterString("SOME MORE TEXT") PushScaleformMovieMethodParameterInt(5)
This will now push the parameters that the scaleform requires (Make sure that you push the right type as some scaleforms wont work if you push the wrong type of data), however, there is one last step we need to do before we can start drawing, which is to end it! This can be achieved by using two different natives, which should be used depending on the situation:
The only difference between these two, are that one will not return anything (
EndScaleformMovieMethod) while the other will return something, which wont be useful unless the function pushed actually have a
return in it.
Right, we have all this, now, can we set it all up and get drawing?
Sure! Now its time to sandwich it all together, the end result will look something like:
local scaleform = RequestScaleformMovie("mp_big_message_freemode") while not HasScaleformMovieLoaded(scaleform) do Citizen.Wait(0) end BeginScaleformMovieMethod(scaleform, "SHOW_SHARD_WASTED_MP_MESSAGE") PushScaleformMovieMethodParameterString("SOME TEXT") PushScaleformMovieMethodParameterString("SOME MORE TEXT") PushScaleformMovieMethodParameterInt(5) EndScaleformMovieMethod()
We’re getting so close! Now all that’s left to do is to draw it! There are quite a few different ways of drawing, however, for this one we will be drawing it 2D and fullscreen, therefore we will be using the native
DrawScaleformMovieFullscreen, as we dont want anything funky with the drawing, we will just pass it 255 for r,g,b and a, while also giving it the scaleform handle, like so:
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255)
Make sure to draw it in a loop too! And dont push the parameters in the loop unless necessary, as that can also cause issues with the scaleform!