[RELEASE] Simple Scaleform Testing

I’ve been playing around with scaleforms for a little while now and wanted to make it easier to experiment with them so I decided to make it easier to experiment with.

Here’s a function i’ve created that makes it much tidier to invoke scaleform methods (with or without parameters.

local natives = {
    ["float"] = "0xD69736AAE04DB51A", -- ScaleformMovieMethodAddParamFloat
    ["integer"] = "0xC3D0841A0CC546A6", -- ScaleformMovieMethodAddParamInt
    ["boolean"] = "0xC58424BA936EB458", -- ScaleformMovieMethodAddParamBool
    ["string"] = "0x77FE3402004CD1B0" -- PushScaleformMovieMethodParameterString_2
}

function scaleform_function(...)
    local args = {...}

    local scaleform = args[1]
    local method = args[2]

    BeginScaleformMovieMethod(scaleform, method)
    for i = 3, #args do
        local pType = type(args[i])
        if pType == "number" then
            pType = math.type(args[i])
        end
        local pInvoke = natives[pType]

        Citizen.InvokeNative(pInvoke, args[i])
    end
    EndScaleformMovieMethod()

    return true
end

Here’s an example to load the POPUP_WARNING scaleform.

local loaded = false
local scaleform = nil

Citizen.CreateThread(function()
	while true do
        Citizen.Wait(0)
        if loaded then
            DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
        end
	end
end)

function testScaleform()
    newSetting = not loaded
    if not loaded then
        Citizen.CreateThread(function()
            Citizen.Wait(10)

            scaleform = RequestScaleformMovie("POPUP_WARNING")
            if not HasScaleformMovieLoaded(scaleform) then
                print(".")
                Citizen.Wait(10)
            end


            --SHOW_POPUP_WARNING(msecs, titleMsg, warningMsg, promptMsg, showBg, alertType, errorMsg)
            scaleform_function(scaleform, "SHOW_POPUP_WARNING", 1000, "alert", "scaleform loading", "made easy", true, 0, "err404")
        end)
    else
        scaleform = nil
    end

    loaded = newSetting
end
RegisterCommand("testform", testScaleform)

Result:

1 Like