Created
August 1, 2018 17:11
-
-
Save throwarray/643c84a7af6bc88a3729a421e96d2ffb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function LoadScaleform(scaleform) | |
local scaleform = RequestScaleformMovie(scaleform) | |
if scaleform ~= 0 then | |
while not HasScaleformMovieLoaded(scaleform) do | |
Citizen.Wait(0) | |
end | |
end | |
return scaleform | |
end | |
local function CreateNamedRenderTargetForModel(name, model) | |
local handle = 0 | |
if not IsNamedRendertargetRegistered(name) then | |
RegisterNamedRendertarget(name, 0) | |
end | |
if not IsNamedRendertargetLinked(model) then | |
LinkNamedRendertarget(model) | |
end | |
if IsNamedRendertargetRegistered(name) then | |
handle = GetNamedRendertargetRenderId(name) | |
end | |
return handle | |
end | |
function CallScaleformMethod (scaleform, method, ...) | |
local t | |
local args = { ... } | |
BeginScaleformMovieMethod(scaleform, method) | |
for k, v in ipairs(args) do | |
t = type(v) | |
if t == 'string' then | |
PushScaleformMovieMethodParameterString(v) | |
elseif t == 'number' then | |
if string.match(tostring(v), "%.") then | |
PushScaleformMovieFunctionParameterFloat(v) | |
else PushScaleformMovieFunctionParameterInt(v) end | |
elseif t == 'boolean' then PushScaleformMovieMethodParameterBool(v) end | |
end | |
EndScaleformMovieMethod() | |
end | |
-------------------------------------------------------------------------------- | |
local scaleform = 0 | |
local selected = 0 | |
local shown = false | |
local APPS = { | |
{ | |
id = 'cam', displayName = "Camera", icon = 1, onopen = function () | |
print('LAUNCH MESSAGES') | |
for i = 0, 32, 1 do | |
if NetworkIsPlayerActive(i) then | |
CallScaleformMethod(scaleform, "SET_DATA_SLOT", 2, i, -1, GetPlayerName(player)) | |
end | |
end | |
CallScaleformMethod(scaleform, "DISPLAY_VIEW", 2, 0); | |
end | |
}, | |
{ id = 'cam', displayName = "Camera", icon = 1 }, | |
{ id = 'cam', displayName = "Camera", icon = 1 }, | |
{ id = 'cam', displayName = "Camera", icon = 1 }, | |
} | |
local ROWS = math.floor(#APPS / 3) | |
local COLS_BOTTOM = #APPS % 3 | |
local Navigate = { | |
UP = function () | |
selected = selected - 3 | |
if selected < 0 then selected = 9 - math.abs(selected) end | |
CallScaleformMethod(scaleform, "DISPLAY_VIEW", 1, selected) | |
PlaySoundFrontend("Menu_Navigate", "Phone_SoundSet_Default", -1) | |
end; | |
DOWN = function () | |
selected = selected + 3 | |
if selected > 8 then selected = selected - 9 end | |
CallScaleformMethod(scaleform, "DISPLAY_VIEW", 1, selected) | |
PlaySoundFrontend("Menu_Navigate", "Phone_SoundSet_Default", -1) | |
end; | |
LEFT = function () | |
selected = selected - 1 | |
if selected < 0 then selected = #APPS - 1 end | |
CallScaleformMethod(scaleform, "DISPLAY_VIEW", 1, selected) | |
PlaySoundFrontend("Menu_Navigate", "Phone_SoundSet_Default", -1) | |
end; | |
RIGHT = function () | |
selected = selected + 1 | |
if selected > #APPS - 1 then selected = 0 end | |
CallScaleformMethod(scaleform, "DISPLAY_VIEW", 1, selected) | |
PlaySoundFrontend("Menu_Navigate", "Phone_SoundSet_Default", -1) | |
end; | |
SELECT = function () | |
local selected = APPS[selected + 1] | |
if selected and selected.onopen then | |
selected:onopen() | |
end | |
end; | |
} | |
local CONTROLS = { | |
INPUT_CELLPHONE_UP = 172, --ARROWUP | |
INPUT_CELLPHONE_DOWN = 173, --ARROWDOWN | |
INPUT_CELLPHONE_LEFT = 174, --ARROWLEFT | |
INPUT_CELLPHONE_RIGHT = 175, --ARROWRIGHT | |
INPUT_PHONE = 27, --ARROWUP | |
INPUT_CELLPHONE_SELECT = 176, --ENTER | |
INPUT_CELLPHONE_CANCEL = 177, --BACKSPACE | |
-- 178 INPUT_CELLPHONE_OPTION DELETE | |
} | |
-- public enum PhoneAppIcon | |
-- { | |
-- APP_CAMERA = 1, | |
-- APP_CHAT, | |
-- APP_EMPTY, | |
-- APP_MESSAGING = 4, | |
-- APP_CONTACTS, | |
-- APP_INTERNET, | |
-- APP_CONTACTS_PLUS = 11, | |
-- APP_TASKS, | |
-- APP_GROUP = 14, | |
-- APP_SETTINGS = 24, | |
-- APP_WARNING = 27, | |
-- APP_GAMES = 35, | |
-- APP_RIGHT_ARROW = 38, | |
-- APP_TASKS_2, | |
-- APP_TARGET, | |
-- APP_TRACKIFY = 42, | |
-- APP_CLOUD, | |
-- APP_BROADCAST = 49, | |
-- APP_VLSI = 54, | |
-- APP_BENNYS = 56, | |
-- APP_SECUROSERV, | |
-- APP_COORDS, | |
-- APP_RSS | |
-- } | |
function CreatePhone () | |
SetMobilePhonePosition(58.0, -21.0, -60.0) | |
SetMobilePhoneRotation(-90.0, 0.0, 0.0, 0) | |
SetMobilePhoneScale(285.0) | |
CreateMobilePhone(0) | |
CallScaleformMethod(scaleform, "SET_HEADER", "FREEMODE") | |
CallScaleformMethod(scaleform, "SET_TITLEBAR_TIME", 0, 0) | |
CallScaleformMethod(scaleform, "SET_SLEEP_MODE", false) | |
CallScaleformMethod(scaleform, "SET_SOFT_KEYS", 3, true, 4) | |
CallScaleformMethod(scaleform, "SET_BACKGROUND_IMAGE", 0) | |
for i,v in ipairs(APPS) do | |
CallScaleformMethod(scaleform, "SET_DATA_SLOT", 1, i - 1, v.icon) | |
end | |
CallScaleformMethod(scaleform, "DISPLAY_VIEW", 1, selected) | |
end | |
Citizen.CreateThread(function () | |
local id = 0 | |
while true do | |
if shown then | |
id = GetMobilePhoneRenderId() | |
if IsControlJustPressed(0, CONTROLS.INPUT_CELLPHONE_CANCEL) then | |
PlaySoundFrontend("Hang_Up", "Phone_SoundSet_Michael", -1) | |
DestroyMobilePhone() | |
SetScaleformMovieAsNoLongerNeeded(scaleform) | |
shown = false | |
elseif IsControlJustPressed(0, CONTROLS.INPUT_CELLPHONE_SELECT) then Navigate.SELECT() | |
elseif IsControlJustPressed(0, CONTROLS.INPUT_CELLPHONE_UP) then Navigate.UP() | |
elseif IsControlJustPressed(0, CONTROLS.INPUT_CELLPHONE_RIGHT) then Navigate.RIGHT() | |
elseif IsControlJustPressed(0, CONTROLS.INPUT_CELLPHONE_DOWN) then Navigate.DOWN() | |
elseif IsControlJustPressed(0, CONTROLS.INPUT_CELLPHONE_LEFT) then Navigate.LEFT() end | |
ClearDrawOrigin() | |
SetTextRenderId(id) | |
DrawScaleformMovie(scaleform, 0.0998, 0.1775, 0.1983, 0.364, 255, 255, 255, 255, 0) | |
SetTextRenderId(GetDefaultScriptRendertargetRenderId()) | |
elseif IsControlJustPressed(0, CONTROLS.INPUT_PHONE) then | |
scaleform = LoadScaleform("CELLPHONE_IFRUIT") | |
shown = true | |
CreatePhone() | |
CallScaleformMethod(scaleform, 'DISPLAY_VIEW', 2, -1082130432, -1082130432, -1082130432, -1082130432) | |
--CallScaleformMethod(scaleform, "DISPLAY_VIEW", 0, 0) | |
end | |
Wait(0) | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment