Skip to content

Commit

Permalink
Custom reticles
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron1a12 committed Mar 1, 2021
1 parent 91c0a28 commit bd5027e
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 4 deletions.
Binary file added Client.net.dll
Binary file not shown.
Binary file added Server.net.dll
Binary file not shown.
6 changes: 5 additions & 1 deletion __resource.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ client_scripts {
'global.lua',
'respawn.lua',
'mood.lua',
'client.lua'
'reticule.lua',
'client.lua',
'Client.net.dll',
}

server_scripts {
'config.lua',
'server.lua',
'Server.net.dll',
}

dependencies {
Expand All @@ -21,6 +24,7 @@ ui_page('html/index.html')

files {
'html/index.html',
'html/img/reticle.png',
'html/css/main.css',
'html/css/DIN-Medium.ttf',
'html/js/howler.min.js',
Expand Down
13 changes: 13 additions & 0 deletions html/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,16 @@ body,html {margin:0;padding:0;height:100%;}
.scoreboard tbody td {
padding-top: 20px;
}


#reticle-container {
position: absolute;
top:0;
left:0;
right:0;
height:100%;
display: flex;
align-items: center;
justify-content: center;
display: none;
}
Binary file added html/img/reticle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 28 additions & 2 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</head>

<body>
<div id="reticle-container"><img id="reticle"></div>

<div id="timer">08:59</div>

Expand Down Expand Up @@ -49,14 +50,39 @@
document.getElementById("scoreboard-container").style.display = "flex";
break;
case "onResetRound":
document.getElementById("scoreboard-container").style.display = "none";
document.getElementById("scoreboard-container").style.display = "none";
break;

case "showReticule":
ShowReticle(Number(event.data.type));
break;
case "hideReticule":
HideReticle();
break;
}

});
});

function ShowReticle(type) {
var reticuleImg = document.getElementById("reticle");
var reticuleCont = document.getElementById("reticle-container");

switch(type) {
default:
case 0:
reticuleImg.src = "img/reticle.png";
break;
case 1:
reticuleImg.src = "img/reticle_shotgun.png";
break;
}

reticuleCont.style.display = "flex";
}

function HideReticle() {
document.getElementById("reticle-container").style.display = "none";
}

function UpdateTime(sec_num) {
var timerDiv = document.getElementById("timer");
Expand Down
11 changes: 11 additions & 0 deletions reticule.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Citizen.CreateThread(function()
while true do
if IsPlayerFreeAiming(PlayerId()) then
SendNUIMessage({name = 'showReticule', type = 0})
else
SendNUIMessage({name = 'hideReticule'})
end

Citizen.Wait(100)
end
end)
2 changes: 1 addition & 1 deletion server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ end)
AddEventHandler("factions:foo", function(args, cbId)
TriggerClientEvent('factions:cl_onCallback_OneParam', source, cbId, "bar")
end)
RegisterServerEvent("factions:foo")
RegisterServerEvent("factions:foo")

0 comments on commit bd5027e

Please sign in to comment.