Skip to content

Commit

Permalink
Merge pull request #60 from FiveM-Scripts/dev
Browse files Browse the repository at this point in the history
1.1.2
  • Loading branch information
ghermans authored Oct 20, 2019
2 parents d9f62f8 + 079bbfb commit f7a2c2c
Show file tree
Hide file tree
Showing 34 changed files with 1,532 additions and 906 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# Changelog
## 1.1.2

### Added
- Added Smoke on the Water, a pharmacy that sells prescription marijuana for "medical" purposes.
- Added convenience stores where players can purchase items.

## Fixed
vf_phone: Display current time instead of network time
vf_baseapps: Change new text message text
vf_baseapps: Show no players item in playerlist
vf_phone: Change no items screen deletion logic
vf_phone: Update native names
vf_phone: Control & Pause Menu related improvements

## 1.1.1

Expand Down
4 changes: 2 additions & 2 deletions [phone]/vf_baseapps/__resource.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
resource_debugmode "0"
resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"
resource_debugmode "1"

client_scripts {
"cl_main.lua",
Expand Down
2 changes: 1 addition & 1 deletion [phone]/vf_baseapps/apps/cl_appmessages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AddEventHandler("vf_phone:ReceivePlayerMessage", function(playerServer, message)
if not _Phone.IsSleepModeOn() then
SetNotificationTextEntry("STRING")
AddTextComponentString(message)
SetNotificationMessage(headshotTxd, headshotTxd, true, 1, "New Message!", playerName)
SetNotificationMessage(headshotTxd, headshotTxd, true, 1, "New Message", playerName)
DrawNotification(true, true)
PlaySound(-1, "Text_Arrive_Tone", "Phone_SoundSet_Default")
end
Expand Down
14 changes: 13 additions & 1 deletion [phone]/vf_baseapps/apps/cl_appplayerlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,24 @@ AddEventHandler("vf_phone:setup", function(phone)
while _App == loopApp do -- Destroy this loop (and coroutine) on vf_phone restart
Wait(1000)
_PlayerListScreen.ClearItems()
for i = 0, 64 do

local hasPlayers = false
for i = 0, 255 do
if NetworkIsPlayerConnected(i) and (IsDebug or i ~= PlayerId()) then
hasPlayers = true

local playerName = GetPlayerName(i)
local playerOptionsMenu = _App.CreateListScreen(playerName)

_PlayerListScreen.AddScreenItem(playerName, 0, playerOptionsMenu)
playerOptionsMenu.AddCallbackItem(GetLabelText("collision_uy2q01"), 0, function()
Wait(0) -- Stop from instantly confirming message

DisplayOnscreenKeyboard(6, "FMMC_KEY_TIP8", "", "", "", "", "", 60)
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Wait(0)
end

if UpdateOnscreenKeyboard() == 1 then
local message = GetOnscreenKeyboardResult()
SetNotificationTextEntry("STRING")
Expand All @@ -31,11 +38,16 @@ AddEventHandler("vf_phone:setup", function(phone)
TriggerServerEvent("vf_phone:SendPlayerMessage", GetPlayerServerId(i), message)
AddTextComponentString("~g~Message sent!")
end

DrawNotification(true, true)
end
end)
end
end

if not hasPlayers then
_PlayerListScreen.AddCallbackItem("No Players")
end
end
end)
end)
2 changes: 1 addition & 1 deletion [phone]/vf_phone/__resource.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"

client_scripts {
"phone/cl_phone.lua",
Expand Down
13 changes: 10 additions & 3 deletions [phone]/vf_phone/phone/app/api/cl_api_item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,37 @@ local function _CreateBaseItem(screen, data, callback)
return item
end

function Item.RemoveItem(app, screen, item)
function Item.RemoveItem(app, screen, item, doNotRemoveScreen)
local itemIndex
-- Check if screen isn't being used anywhere else
local removeScreen = true
local removeScreen = not doNotRemoveScreen
for _, screen in ipairs(app.Screens) do
for i, screenItem in ipairs(screen.Items) do
if screenItem == item then
itemIndex = i

-- Don't bother continuing if removeScreen is false already
if not removeScreen then
break
end
elseif screenItem.Callback == item.Callback then
removeScreen = false
end
end
end

-- Remove screen if possible
if removeScreen then
table.remove(app.Screens, item.Callback)
end

-- Remove item
table.remove(screen.Items, itemIndex)
end

function Item.RemoveItemsInScreen(app, screen)
for i = #screen.Items, 1, -1 do -- Reverse looping for safe table content removal
Item.RemoveItem(app, screen, screen.Items[i])
Item.RemoveItem(app, screen, screen.Items[i], true)
end
end

Expand Down
53 changes: 30 additions & 23 deletions [phone]/vf_phone/phone/app/cl_app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,66 +37,72 @@ Citizen.CreateThread(function()
screenFound = true
end
end

if not screenFound then -- No existing screen found
Apps.Kill()
end
end
else
PushScaleformMovieFunction(Phone.Scaleform, "SET_DATA_SLOT_EMPTY")
PushScaleformMovieFunctionParameterInt(_CurrentScreen.Type)
PopScaleformMovieFunctionVoid()
BeginScaleformMovieMethod(Phone.Scaleform, "SET_DATA_SLOT_EMPTY")
ScaleformMovieMethodAddParamInt(_CurrentScreen.Type)
EndScaleformMovieMethod()

local header
local header = ""
if _CurrentScreen.Header then
header = _CurrentScreen.Header
else
elseif _CurrentApp.Name then
header = _CurrentApp.Name
end
PushScaleformMovieFunction(Phone.Scaleform, "SET_HEADER")
PushScaleformMovieFunctionParameterString(header)
PopScaleformMovieFunctionVoid()
BeginScaleformMovieMethod(Phone.Scaleform, "SET_HEADER")
BeginTextCommandScaleformString("STRING")
AddTextComponentString(header)
EndTextCommandScaleformString()
EndScaleformMovieMethod()

for i, item in ipairs(_CurrentScreen.Items) do
PushScaleformMovieFunction(Phone.Scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(_CurrentScreen.Type)
PushScaleformMovieFunctionParameterInt(i - 1)
BeginScaleformMovieMethod(Phone.Scaleform, "SET_DATA_SLOT")
ScaleformMovieMethodAddParamInt(_CurrentScreen.Type)
ScaleformMovieMethodAddParamInt(i - 1)
for _, data in ipairs(item.Data) do
if type(data) == "number" then
if math.type(data) == "integer" then
PushScaleformMovieFunctionParameterInt(data)
ScaleformMovieMethodAddParamInt(data)
else
PushScaleformMovieFunctionParameterFloat(data)
ScaleformMovieMethodAddParamFloat(data)
end
elseif type(data) == "string" then
PushScaleformMovieFunctionParameterString(data)
BeginTextCommandScaleformString("STRING")
AddTextComponentString(data)
EndTextCommandScaleformString()
elseif not data then
PushScaleformMovieFunctionParameterInt()
ScaleformMovieMethodAddParamInt()
end
end
PopScaleformMovieFunctionVoid()
EndScaleformMovieMethod()
end

PushScaleformMovieFunction(Phone.Scaleform, "DISPLAY_VIEW")
PushScaleformMovieFunctionParameterInt(_CurrentScreen.Type)
PushScaleformMovieFunctionParameterInt(_SelectedItem)
BeginScaleformMovieMethod(Phone.Scaleform, "DISPLAY_VIEW")
ScaleformMovieMethodAddParamInt(_CurrentScreen.Type)
ScaleformMovieMethodAddParamInt(_SelectedItem)
EndScaleformMovieMethod()

-- Fix _SelectedItem in case last item got removed while it was selected
if _SelectedItem > #_CurrentScreen.Items - 1 then
_SelectedItem = #_CurrentScreen.Items - 1
end

local navigated = true
if IsControlJustPressed(0, 300) then -- Up
if IsControlJustPressed(3, 172) then -- INPUT_CELLPHONE_UP (arrow up)
_SelectedItem = _SelectedItem - 1
if _SelectedItem < 0 then
_SelectedItem = #_CurrentScreen.Items - 1
end
elseif IsControlJustPressed(0, 299) then -- Down
elseif IsControlJustPressed(3, 173) then -- INPUT_CELLPHONE_DOWN (arrow down)
_SelectedItem = _SelectedItem + 1
if _SelectedItem > #_CurrentScreen.Items - 1 then
_SelectedItem = 0
end
elseif IsControlJustPressed(0, 255) then -- Enter
elseif IsControlJustPressed(3, 176) then -- INPUT_CELLPHONE_SELECT (enter / lmb)
if #_CurrentScreen.Items > 0 then
local item = _CurrentScreen.Items[_SelectedItem + 1]
if type(item.Callback) == "table" then -- Action (Should be function, but it isn't because it's a table according to Msgpack!)
Expand All @@ -107,7 +113,7 @@ Citizen.CreateThread(function()
_SelectedItem = 0
end
end
elseif IsControlJustPressed(0, 202) then -- Back
elseif IsControlJustPressed(3, 177) then -- INPUT_CELLPHONE_CANCEL (backspace / esc / rmb)
if #_PrevScreens > 0 then
_CurrentScreen = _PrevScreens[#_PrevScreens]
table.remove(_PrevScreens)
Expand All @@ -120,6 +126,7 @@ Citizen.CreateThread(function()
else
navigated = false
end

if navigated then
PlaySoundFrontend(-1, "Menu_Navigate", "Phone_SoundSet_Default")
end
Expand Down
45 changes: 25 additions & 20 deletions [phone]/vf_phone/phone/app/cl_appmain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,60 @@ Citizen.CreateThread(function()

if Phone.Visible and not Phone.InApp then
for i = 0, 8 do
PushScaleformMovieFunction(Phone.Scaleform, "SET_DATA_SLOT")
PushScaleformMovieFunctionParameterInt(1)
PushScaleformMovieFunctionParameterInt(i)
BeginScaleformMovieMethod(Phone.Scaleform, "SET_DATA_SLOT")
ScaleformMovieMethodAddParamInt(1)
ScaleformMovieMethodAddParamInt(i)
if Apps[i + 1] and Apps[i + 1].Icon then
PushScaleformMovieFunctionParameterInt(Apps[i + 1].Icon)
ScaleformMovieMethodAddParamInt(Apps[i + 1].Icon)
else
PushScaleformMovieFunctionParameterInt(3)
ScaleformMovieMethodAddParamInt(3)
end
PopScaleformMovieFunctionVoid()
EndScaleformMovieMethod()
end

PushScaleformMovieFunction(Phone.Scaleform, "DISPLAY_VIEW")
PushScaleformMovieFunctionParameterInt(1)
PushScaleformMovieFunctionParameterInt(selectedItem)
PopScaleformMovieFunctionVoid()
BeginScaleformMovieMethod(Phone.Scaleform, "DISPLAY_VIEW")
ScaleformMovieMethodAddParamInt(1)
ScaleformMovieMethodAddParamInt(selectedItem)
EndScaleformMovieMethod()

PushScaleformMovieFunction(Phone.Scaleform, "SET_HEADER")
BeginScaleformMovieMethod(Phone.Scaleform, "SET_HEADER")
if Apps[selectedItem + 1] and Apps[selectedItem + 1].Name then
PushScaleformMovieFunctionParameterString(Apps[selectedItem + 1].Name)
BeginTextCommandScaleformString("STRING")
AddTextComponentString(Apps[selectedItem + 1].Name)
EndTextCommandScaleformString()
else
PushScaleformMovieFunctionParameterString("")
BeginTextCommandScaleformString("STRING")
AddTextComponentString("")
EndTextCommandScaleformString()
end
PopScaleformMovieFunctionVoid()
EndScaleformMovieMethod()

local navigated = true
if IsControlJustPressed(0, 300) then -- Up
if IsControlJustPressed(3, 172) then -- INPUT_CELLPHONE_UP (arrow up)
selectedItem = selectedItem - 3
if selectedItem < 0 then
selectedItem = 9 + selectedItem
end
elseif IsControlJustPressed(0, 299) then -- Down
elseif IsControlJustPressed(3, 173) then -- INPUT_CELLPHONE_DOWN (arrow down)
selectedItem = selectedItem + 3
if selectedItem > 8 then
selectedItem = selectedItem - 9
end
elseif IsControlJustPressed(0, 307) then -- Right
elseif IsControlJustPressed(3, 175) then -- INPUT_CELLPHONE_RIGHT (arrow right)
selectedItem = selectedItem + 1
if selectedItem > 8 then
selectedItem = 0
end
elseif IsControlJustPressed(0, 308) then -- Left
elseif IsControlJustPressed(3, 174) then -- INPUT_CELLPHONE_LEFT (arrow left)
selectedItem = selectedItem - 1
if selectedItem < 0 then
selectedItem = 8
end
else
if IsControlJustPressed(0, 255) then -- Enter
if IsControlJustPressed(3, 176) then -- INPUT_CELLPHONE_SELECT (enter / lmb)
Wait(0) -- Workaround to next app from registering enter press too
Apps.Start(selectedItem + 1)
elseif IsControlJustPressed(0, 202) then -- Back
elseif IsControlJustPressed(3, 177) then -- INPUT_CELLPHONE_CANCEL (backspace / esc / rmb)
Phone.Kill()
end
navigated = false
Expand Down
45 changes: 26 additions & 19 deletions [phone]/vf_phone/phone/cl_phone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,40 @@ Citizen.CreateThread(function()
Wait(0)

if Phone.Visible then
SetPauseMenuActive(false)
SetMobilePhonePosition(58.0, -21.0 - Phone.VisibleAnimProgress, -60.0)
SetMobilePhoneRotation(-90.0, Phone.VisibleAnimProgress * 4.0, 0.0)
if Phone.VisibleAnimProgress > 0 then
Phone.VisibleAnimProgress = Phone.VisibleAnimProgress - 3
end

local h, m = NetworkGetServerTime()
PushScaleformMovieFunction(Phone.Scaleform, "SET_TITLEBAR_TIME")
PushScaleformMovieFunctionParameterInt(h)
PushScaleformMovieFunctionParameterInt(m)
PopScaleformMovieFunctionVoid()
local h, m = GetClockHours(), GetClockMinutes()
BeginScaleformMovieMethod(Phone.Scaleform, "SET_TITLEBAR_TIME")
ScaleformMovieMethodAddParamInt(h)
ScaleformMovieMethodAddParamInt(m)
EndScaleformMovieMethod()

PushScaleformMovieFunction(Phone.Scaleform, "SET_SLEEP_MODE")
PushScaleformMovieFunctionParameterBool(Phone.SleepMode)
PopScaleformMovieFunctionVoid()
BeginScaleformMovieMethod(Phone.Scaleform, "SET_SLEEP_MODE")
ScaleformMovieMethodAddParamBool(Phone.SleepMode)
EndScaleformMovieMethod()

PushScaleformMovieFunction(Phone.Scaleform, "SET_THEME")
PushScaleformMovieFunctionParameterInt(Phone.Theme)
PopScaleformMovieFunctionVoid()
BeginScaleformMovieMethod(Phone.Scaleform, "SET_THEME")
ScaleformMovieMethodAddParamInt(Phone.Theme)
EndScaleformMovieMethod()

PushScaleformMovieFunction(Phone.Scaleform, "SET_BACKGROUND_IMAGE")
PushScaleformMovieFunctionParameterInt(Phone.Wallpaper)
PopScaleformMovieFunctionVoid()
BeginScaleformMovieMethod(Phone.Scaleform, "SET_BACKGROUND_IMAGE")
ScaleformMovieMethodAddParamInt(Phone.Wallpaper)
EndScaleformMovieMethod()

PushScaleformMovieFunction(Phone.Scaleform, "SET_SIGNAL_STRENGTH")
PushScaleformMovieFunctionParameterInt(GetZoneScumminess(GetZoneAtCoords(GetEntityCoords(PlayerPedId()))))
PopScaleformMovieFunctionVoid()
BeginScaleformMovieMethod(Phone.Scaleform, "SET_SIGNAL_STRENGTH")
ScaleformMovieMethodAddParamInt(GetZoneScumminess(GetZoneAtCoords(GetEntityCoords(PlayerPedId()))))
EndScaleformMovieMethod()

local renderID = GetMobilePhoneRenderId()
SetTextRenderId(renderId)
DrawScaleformMovie(Phone.Scaleform, 0.0998, 0.1775, 0.1983, 0.364, 255, 255, 255, 255);
SetTextRenderId(1)
elseif IsControlJustPressed(0, 300) then
elseif IsControlJustPressed(3, 27) then -- INPUT_PHONE (arrow up / mmb)
PlaySoundFrontend(-1, "Pull_Out", "Phone_SoundSet_Default")
Phone.Scaleform = RequestScaleformMovie("CELLPHONE_IFRUIT")
while not HasScaleformMovieLoaded(Phone.Scaleform) do
Expand All @@ -60,7 +61,7 @@ Citizen.CreateThread(function()
Phone.Visible = true
SetMobilePhonePosition()
SetMobilePhoneScale(285.0)
CreateMobilePhone(0)
CreateMobilePhone()
end
end
end)
Expand All @@ -71,4 +72,10 @@ function Phone.Kill()
Phone.Scaleform = nil
Phone.Visible = false
DestroyMobilePhone()

-- Prevent esc from immediately opening the pause menu
while IsControlPressed(3, 177) do
Wait(0)
SetPauseMenuActive(false)
end
end
Loading

0 comments on commit f7a2c2c

Please sign in to comment.