Skip to content

Commit

Permalink
Reworked last logins to be more logically sound; the GUI is also now …
Browse files Browse the repository at this point in the history
…brought to the front when opened
  • Loading branch information
itslewiswatson committed Dec 25, 2016
1 parent 44740c5 commit b799ecd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion UCDlastLogins/client.lua
Expand Up @@ -35,7 +35,7 @@ function onToggleGUI()
if (gui.window.visible) then
forceClose()
else
triggerServerEvent("UCDlastLogins.onRequestSelfLogins", resourceRoot)
triggerServerEvent("UCDlastLogins.onRequestLogins", resourceRoot)
end
end
addCommandHandler("lastlogins", onToggleGUI, false, false)
Expand Down Expand Up @@ -72,6 +72,7 @@ function onPopulateClient(account, serial, ip, data)
end
end
end
guiBringToFront(gui.window)
gui.window.visible = true
showCursor(true)
end
Expand Down
2 changes: 2 additions & 0 deletions UCDlastLogins/meta.xml
@@ -1,5 +1,7 @@
<meta>
<script src="server.lua" type="server"/>
<script src="client.lua" type="client"/>
<export function="sendPlayerLastLogins" type="server"/>
<export function="getLastLogins" type="server"/>
<oop>true</oop>
</meta>
13 changes: 8 additions & 5 deletions UCDlastLogins/server.lua
Expand Up @@ -29,16 +29,19 @@ function getLastLogins(account)
return lastLogins[account]
end

function sendToGUI(plr, receiver)
function sendPlayerLastLogins(receiver, plr)
local logins = getLastLogins(plr.account.name)
triggerLatentClientEvent(receiver, "UCDlastLogins.onPopulateClient", resourceRoot, plr.account.name, plr.serial, plr.ip, logins)
end

function getSelfLastLogins()
function onRequestLogins(plr)
if (not exports.UCDaccounts:isPlayerLoggedIn(client)) then
return
end
sendToGUI(client, client)
if (not plr) then
plr = client
end
sendPlayerLastLogins(client, plr)
end
addEvent("UCDlastLogins.onRequestSelfLogins", true)
addEventHandler("UCDlastLogins.onRequestSelfLogins", root, getSelfLastLogins)
addEvent("UCDlastLogins.onRequestLogins", true)
addEventHandler("UCDlastLogins.onRequestLogins", root, onRequestLogins)

0 comments on commit b799ecd

Please sign in to comment.