Skip to content

Commit

Permalink
Update v1.9.7
Browse files Browse the repository at this point in the history
* Finally fixed new Callbacks
* New Design for MSK.Input
* Bugfixes for MSK.Input
  • Loading branch information
Musiker15 committed Mar 5, 2024
1 parent b5416b2 commit d13d619
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 81 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.6
1.9.7
16 changes: 13 additions & 3 deletions client/cl_callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ local CallbackHandler = {}

AddEventHandler('onResourceStop', function(resource)
if CallbackHandler[resource] then
RemoveEventHandler(CallbackHandler[resource])
for k, handler in pairs(CallbackHandler[resource]) do
RemoveEventHandler(handler)
end
end
end)

Expand All @@ -14,14 +16,22 @@ MSK.RegisterClientCallback = function(eventName, cb)
end)

local script = GetInvokingResource()
if script then CallbackHandler[script] = handler end
if script then
if CallbackHandler[script] then
table.insert(CallbackHandler[script], handler)
else
CallbackHandler[script] = {}
table.insert(CallbackHandler[script], handler)
end
end
end
MSK.Register = MSK.RegisterClientCallback
exports('RegisterClientCallback', MSK.RegisterClientCallback)

-- NEW Method for Server Callbacks
MSK.Trigger = function(eventName, ...)
local p = promise.new()
local ticket = GetGameTimer() .. GetPlayerServerId(PlayerId())
local ticket = tostring(GetGameTimer() .. GetPlayerServerId(PlayerId()))

SetTimeout(5000, function()
p:reject("Request Timed Out (408)")
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_core'
description 'Core functions for MSK Scripts'
version '1.9.6'
version '1.9.7'

lua54 'yes'

Expand Down
10 changes: 7 additions & 3 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<script src="script.js"></script>

<div class="msk-input-container"><span id="msk-input-title">Das ist eine Überschrift</span>
<span id="close" onclick="closeInputUI()"><i class="fa-solid fa-xmark"></i></span>
<div class="msk-input-container">
<div class="msk-input-title-box">
<div class="msk-input-title">
<span class="msk-input-title-text"><i class="fa-solid fa-chevrons-left arrow-left"></i><span id="msk-input-title">This is a title</span><i class="fa-solid fa-chevrons-right arrow-right"></i></span>
</div>
</div>
<textarea class="msk-input" rows="5" cols="50" id="big-input" placeholder=""></textarea>
<textarea class="msk-input" rows="1" cols="50" id="small-input" placeholder=""></textarea>
<button class="msk-submit-button" onclick="input()">Confirm</button>
<button class="msk-submit-button"onclick="input()"><span class="msk-submit-button-text">Confirm</span></button>
</div>

<div class="progress-container">
Expand Down
19 changes: 13 additions & 6 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ window.addEventListener('message', (event) => {
document.getElementById(input).placeholder = data.placeholder;
$(".msk-input-container").fadeIn()
$("#msk-input-title").text(data.header)

document.getElementById('small-input').addEventListener("keydown", function(e) {
if (e.key === "Enter") {
if (e.shiftKey) {
return;
}
e.preventDefault();
}
})
} else if (event.data.action == 'progressBarStart') {
event.data.id = currID
progressBarStart(event.data);
Expand Down Expand Up @@ -119,16 +128,14 @@ closeInputUI = (send) => {

document.onkeyup = (data) => {
if (data.which == 27) {
var textfield = '#small-input'
if (field) {textfield = '#big-input'}
$(textfield).val('');

closeInputUI()
}
}

$("#small-input").keydown((event) => {
if (event.keyCode == 13) {
event.preventDefault();
}
})

input = () => {
var textfield = '#small-input'
if (field) {textfield = '#big-input'}
Expand Down
Loading

0 comments on commit d13d619

Please sign in to comment.