Skip to content

Commit

Permalink
Added new update, version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
0x3r1k authored Feb 21, 2022
1 parent ddaa81e commit 3feb89a
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cfg.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Config = {
Debug = false,
Framework = 'qb', --[[
Valid options:
'esx' (es_extended)
'qb' (qb-core)
]]
Language = 'es', --[[
Valid options:
'es' (Español / Spanish)
'en' (Ingles / English)
'custom' (Custom)
]]
Command = {
Enabled = true,
Keybind = false,
Name = 'togglestreet',
DefaultKey = '' -- Input Parameter: https://docs.fivem.net/docs/game-references/input-mapper-parameter-ids/keyboard/
},
Notification = 'qb' --[[
Valid options:
't-notify' -- https://github.com/TasoOneAsia/t-notify
'mythic_notify' -- https://github.com/wowpanda/mythic_notify
'okokNotify' -- https://forum.cfx.re/t/okoknotify-standalone-paid/3907758
'esx' -- Default esx
'qb' -- Default qbcore
]]
}

Locales = {
['es'] = { -- Spanish locale
['activated_command'] = 'Has activado el hud de las calles',
['desactivated_command'] = 'Has desactivado el hud de las calles',
['keybind_command'] = 'Desactivar/activar hud de las calles'
},
['en'] = { -- English locale
['activated_command'] = 'You have enabled the street hud',
['desactivated_command'] = 'You have disabled the street hud',
['keybind_command'] = 'Disable/enable street hud'
},
['custom'] = { -- Custom locale
['activated_command'] = '',
['desactivated_command'] = '',
['keybind_command'] = ''
}
}
118 changes: 118 additions & 0 deletions client/cl.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
local CreateThread = CreateThread
local PlayerPedId = PlayerPedId
local GetEntityCoords = GetEntityCoords
local Wait = Wait

local showing = true
local lastStreet1, lastStreet2 = nil, nil

if Config.Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject()
elseif Config.Framework == 'qb' then
QBCore = exports['qb-core']:GetCoreObject()
end

-- https://github.com/Leah-UK/bixbi_core/blob/main/client.lua#L30-#L44 ^^
local function Notification(msg, type, duration)
if (duration == nil) then duration = 5000 end
if Config.Notification == "t-notify" then
if type == '' or type == nil then type = 'info' end
exports['t-notify']:Alert({style = type, message = string.gsub(msg, '(~[rbgypcmuonshw]~)', '')})
elseif Config.Notification == "mythic_notify" then
if type == '' or type == nil then type = 'inform' end
exports['mythic_notify']:DoCustomHudText(type, string.gsub(msg, '(~[rbgypcmuonshw]~)', ''), duration)
elseif Config.Notification == "okokNotify" then
if type == '' or type == nil then type = 'info' end
exports['okokNotify']:Alert("", string.gsub(msg, '(~[rbgypcmuonshw]~)', ''), duration, type)
elseif Config.Notification == "esx" then
ESX.ShowNotification(msg)
elseif Config.Notification == "qb" then
QBCore.Functions.Notify(msg, type, duration)
else
print('^5[ERROR]:^0 Check your configuration, you have something wrong.')
end
end

CreateThread(function()
while true do
local sleep = 750
local ped = PlayerPedId()
local pedc = GetEntityCoords(ped)
local street
local street1, street2 = GetStreetNameAtCoord(pedc.x, pedc.y, pedc.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger())

lastStreet1 = street1
lastStreet2 = street2

if street1 ~= 0 and street2 ~= 0 and (street1.. ' & ' ..street2) ~= (lastStreet1.. ' & ' ..lastStreet1) then
street = (GetStreetNameFromHashKey(street1).. ' & ' ..GetStreetNameFromHashKey(street2))
elseif street1 ~= 0 and street2 == 0 then
street = GetStreetNameFromHashKey(street1)
elseif street1 == 0 and street2 ~= 0 then
street = GetStreetNameFromHashKey(street2)
end

if showing and IsPedInAnyVehicle(ped) and not IsPauseMenuActive() then
sleep = 100

if Config.Debug then
print(street, street1, street2)
end

SendNUIMessage({
action = 'showStreet',
street = street
})
else
SendNUIMessage({
action = 'hideStreet'
})
end

Wait(sleep)
end
end)

if Config.Framework == 'esx' then
if Config.Command.Enabled then
RegisterCommand(Config.Command.Name, function()
if showing then
showing = false
Notification(Locales[Config.Language]['desactivated_command'])

if Config.Debug then
print(showing)
end
else
showing = true
Notification(Locales[Config.Language]['activated_command'])

if Config.Debug then
print(showing)
end
end
end)
end

if Config.Command.Keybind then
RegisterKeyMapping(Config.Command.Name, Locales[Config.Language]['keybind_command'], 'keyboard', Config.Command.DefaultKey)
end
elseif Config.Framework == 'qb' then
RegisterCommand(Config.Command.Name, function()
if showing then
showing = false
Notification(Locales[Config.Language]['desactivated_command'], 'success', 5000)

if Config.Debug then
print(showing)
end
else
showing = true
Notification(Locales[Config.Language]['activated_command'], 'success', 5000)

if Config.Debug then
print(showing)
end
end
end)
end
24 changes: 24 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
fx_version 'cerulean'

game 'gta5'

author 'LittleFishy#0001'

lua54 'yes'

shared_scripts {
'cfg.lua'
}

client_scripts {
'client/*.lua'
}

ui_page 'html/index.html'

files {
'html/*.html',
'html/js/*.js',
'html/css/*.css',
'html/fonts/*.ttf'
}
28 changes: 28 additions & 0 deletions html/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@font-face {
font-family: fuente;
src: url('../fonts/fuente.ttf');
}

body {
overflow: hidden;
}

.container {
display: none;
position: absolute;
top: 1vw;
left: 50vw;
padding: .3vw;
transform: translate(-50%);
background: rgba(0, 0, 0, 0.7);
box-shadow: 0 0 10px black;
border-radius: .5vh;
}

.text {
margin-bottom: .1vw;
font-family: fuente;
text-align: center;
color: white;
text-shadow: 4px rgb(0, 0, 0);
}
Binary file added html/fonts/fuente.ttf
Binary file not shown.
21 changes: 21 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LittleFishy#0001</title>
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/gh/hung1001/font-awesome-pro-v6@18657a9/css/all.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/style.css">
<!-- JS -->
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
<script src="js/app.js"></script>
</head>
<body>
<div class="container">
<div class="text"></div>
</div>
</body>
</html>
24 changes: 24 additions & 0 deletions html/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$(function(){
$('.container').draggable()

window.addEventListener('message', function(event){
let v = event.data

switch (v.action) {
case 'showStreet':
$('.container').fadeIn(500)
$('.text').html(v.street)
break;

case 'hideStreet':
$('.container').fadeOut(500)
break;
}
})

document.onkeyup = function(event) {
if (event.key == 'Escape') {
$.post('https://fs_streethud/close', JSON.stringify({}));
}
}
})

0 comments on commit 3feb89a

Please sign in to comment.