Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cat24max committed Jun 18, 2020
1 parent 87fad51 commit 9af5606
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ luac.out
*.x86_64
*.hex


# VEXT Compiled WebUI
*.vuic
20 changes: 20 additions & 0 deletions WebUI/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="script/script.js"></script>
<link rel="stylesheet" href="style/reset.css">
<link rel="stylesheet" href="style/style.css">
</head>

<body>
<div id="page">
<div id="orangeRect">
<label>FairRoundStart</label>
</div>
<ul id="playerList">
</ul>
</div>
</body>

</html>
45 changes: 45 additions & 0 deletions WebUI/script/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function addMedics(medics) {
// Just in case we make sure the medics param is an array, not an object. This happens when a lua table is empty, as the JSON encoder doesn't
// know if the table is supposed to be an array or an object.
if (typeof medics == 'object') {
medics = Object.values(medics);
}

// Clear previous elements first.
removeAllMedics();

// Now we want to create an element for each medic in the array.
for (let j = 0; j < medics.length; j++) {
let medic = medics[j];
let li = '<li class="nameBox" id="item' + j + '"><label>' + medic.name + '</label></li>';
// Attach it to the playerList element.
let el = document.getElementById("playerList");
el.innerHTML += li;
}
}

// Clears all player info elements.
function removeAllMedics(){
let el = document.getElementById("playerList");
el.innerHTML = '';
}

fontsize = function () {
// As the vanilla UI stops resizing at 720p we can't use percentages or vmin for font size, so we calculate it with the width of the orange rectangle.
// Check style.css to see how the UI mimics the fixed aspect ratio of the vanilla UI.
let el = document.getElementById("orangeRect");
let size = el.clientWidth * 0.06;

let pageEl = document.getElementById("page");
pageEl.style.fontSize = size + 'px';
};


window.onresize = function(event) {
fontsize();
};

window.onload = function(event) {
addMedics([{name: 'US: Waiting for 3 more... (13/32)'}, {name: 'RU: Waiting for 5 more... (11/32)'}])
fontsize();
};
Binary file added WebUI/style/bffont.ttf
Binary file not shown.
49 changes: 49 additions & 0 deletions WebUI/style/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
overflow: hidden;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
74 changes: 74 additions & 0 deletions WebUI/style/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@font-face {
font-family: "bffont";
src: url("bffont.ttf");
}
::-webkit-scrollbar {
display: none;
}



/* Vanilla UI keeps a fixed aspect ratio of 16/9 that fits the whole screen
Above 720p this aspect ratio is kept at that resolution and doesn't grow any longer.
*/
#page {
width: 100vw;
height: 56.25vw; /* height:width ratio = 9/16 = .5625 */
/*background-color: rgba(0,0,0,0.5);*/
max-height: 100vh;
max-width: 177.78vh; /* 16/9 = 1.778 */
margin: auto;
position: absolute;
top:0;bottom:0; /* vertical center */
left:0;right:0; /* horizontal center */
overflow: visible;
}


/* For resolutions higher than 720p */
@media screen and (min-height: 720px) and (min-width: 1280px){
#page {
width: 1280px;
height: 720px;
}
}

#orangeRect {
background: linear-gradient(rgba(255, 156, 55, 0.96), rgba(181,109,35,0.96));
margin-top: -2%;
margin-left: 39.5%;
width:20.5%;
height: 4.3%;

}

#playerList{
/*height: 4.3%;*/
/*background-color: rgba(41,0,63,0.4); */
display: flex;
flex-direction: column;
margin-left: 39.5%;
bottom: 0;
}

.nameBox{
border:0;
background-color: rgba(41,56,63,0.8);
margin-top: 0px;
margin-right: 5px;
width:33.9%;
height: 4.3%;
}
label{
/*font-family: '$MENU_medium';*/
font-family: bffont;
color: white;
text-shadow:2px 2px 10px #7fccff;
display: block;
overflow: hidden;
white-space: nowrap;
vertical-align: middle;
line-height:1.7em;
margin-left:3%;
letter-spacing: 0.3px;
}
44 changes: 44 additions & 0 deletions ext/Client/__init__.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
class 'FairRoundStart'

function FairRoundStart:__init()
print("Initializing FairRoundStart by cat24max/AllianceApps V1")
self:RegisterVars()
self:RegisterEvents()
end


function FairRoundStart:RegisterVars()
self.roundStarted = false
self.movementBlocker = nil
end

function FairRoundStart:RegisterEvents()
Events:Subscribe('Level:Loaded', function(levelName, gameMode)
WebUI:Init()
end)
self.movementBlocker = Events:Subscribe('Player:Respawn', self, self.onPlayerRespawn)
NetEvents:Subscribe('FairRoundStart:Start', function()
self.movementBlocker:Unsubscribe()
self:DisableInput(PlayerManager:GetLocalPlayer(), true)
end)
end

function FairRoundStart:DisableInput(player, newbool)
if player == nil then return end
player:EnableInput(7, newbool) -- EIAFire
player:EnableInput(1, newbool) -- EIAStrafe
player:EnableInput(0, newbool) -- EIAThrottle
player:EnableInput(35, newbool) -- EIAInteract
player:EnableInput(31, newbool) -- EIAThrowGrenade
end


function FairRoundStart:onPlayerRespawn(player)
self:DisableInput(player, false)
WebUI:ExecuteJS("WebUI.Call('Show')")
WebUI:ExecuteJS('app.$data.message = "<strong>FairRoundStart</strong><br>Waiting for 50% of players to spawn...<br>RU: 8/16<br>US: 13/15";')
end



g_FairRoundStart = FairRoundStart()
65 changes: 65 additions & 0 deletions ext/Server/__init__.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class 'FairRoundStart'

function FairRoundStart:__init()
print("Initializing FairRoundStart by cat24max/AllianceApps V1")
self:RegisterVars()
self:RegisterEvents()





Events:Subscribe('Player:Chat', function(player, recipientMask, message)
if message == "GO" then
self:StartRound()
end
end)

end

function FairRoundStart:RegisterVars()
self.roundStarted = false
self.movementBlocker = nil
end

function FairRoundStart:RegisterEvents()
-- Events:Subscribe('Player:Respawn', self, self.onPlayerRespawn)
self.movementBlocker = Events:Subscribe('Player:UpdateInput', function(player, dt)
player.input:SetLevel(EntryInputActionEnum.EIAThrottle, 0)
player.input:SetLevel(EntryInputActionEnum.EIAStrafe, 0)
if not self.roundStarted then
self:DisableInput(player, false)
end
end)
end

function FairRoundStart:DisableInput(player, newbool)
if player == nil then return end
player:EnableInput(7, newbool) -- EIAFire
player:EnableInput(1, newbool) -- EIAStrafe
player:EnableInput(0, newbool) -- EIAThrottle
player:EnableInput(35, newbool) -- EIAInteract
player:EnableInput(31, newbool) -- EIAThrowGrenade
end

function FairRoundStart:StartRound()
self.roundStarted = true
self.movementBlocker:Unsubscribe()
NetEvents:Broadcast("FairRoundStart:Start")
ChatManager:SendMessage("------- LIVE -------")
ChatManager:SendMessage("------- LIVE -------")
ChatManager:SendMessage("------- LIVE -------")
for _,player in pairs(PlayerManager:GetPlayers()) do
self:DisableInput(player, true)
end
end

function FairRoundStart:onPlayerRespawn(player)
if not self.roundStarted then
ChatManager:SendMessage("Round has not started yet, not enough players have joined")
self:DisableInput(player, false)
end
end


g_FairRoundStart = FairRoundStart()
9 changes: 9 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Name": "FairRoundStart",
"Authors": ["cat24max", "AllianceApps"],
"Description": "Blocks player movement until 50% of players have spawned",
"URL": "",
"Version": "0",
"HasWebUI": true,
"HasVeniceEXT": true
}

0 comments on commit 9af5606

Please sign in to comment.