mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 06:14:09 +01:00
initial
This commit is contained in:
18
resources/[gameplay]/channelfeed/__resource.lua
Normal file
18
resources/[gameplay]/channelfeed/__resource.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
description 'output lists for game content'
|
||||
|
||||
SetResourceInfo('uiPage', 'client/html/index.html')
|
||||
|
||||
client_script 'client/channelfeed.lua'
|
||||
|
||||
export 'printTo'
|
||||
export 'addChannel'
|
||||
export 'removeChannel'
|
||||
|
||||
files
|
||||
{
|
||||
'client/html/index.html',
|
||||
'client/html/feed.js',
|
||||
'client/html/feed.css',
|
||||
'client/fonts/roboto-regular.ttf',
|
||||
'client/fonts/roboto-condensed.ttf',
|
||||
}
|
||||
40
resources/[gameplay]/channelfeed/client/channelfeed.lua
Normal file
40
resources/[gameplay]/channelfeed/client/channelfeed.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
local eventBuffer = {}
|
||||
|
||||
AddUIHandler('getNew', function(data, cb)
|
||||
local localBuf = eventBuffer
|
||||
eventBuffer = {}
|
||||
|
||||
cb(localBuf)
|
||||
end)
|
||||
|
||||
function printTo(channel, data)
|
||||
table.insert(eventBuffer, {
|
||||
meta = 'print',
|
||||
channel = channel,
|
||||
data = data
|
||||
})
|
||||
|
||||
PollUI()
|
||||
end
|
||||
|
||||
function addChannel(id, options)
|
||||
if not options.template then
|
||||
return
|
||||
end
|
||||
|
||||
options.id = id
|
||||
|
||||
table.insert(eventBuffer, {
|
||||
meta = 'addChannel',
|
||||
data = options
|
||||
})
|
||||
|
||||
PollUI()
|
||||
end
|
||||
|
||||
function removeChannel(id)
|
||||
table.insert(eventBuffer, {
|
||||
meta = 'removeChannel',
|
||||
data = id
|
||||
})
|
||||
end
|
||||
Binary file not shown.
BIN
resources/[gameplay]/channelfeed/client/fonts/roboto-regular.ttf
Normal file
BIN
resources/[gameplay]/channelfeed/client/fonts/roboto-regular.ttf
Normal file
Binary file not shown.
118
resources/[gameplay]/channelfeed/client/html/feed.js
Normal file
118
resources/[gameplay]/channelfeed/client/html/feed.js
Normal file
@@ -0,0 +1,118 @@
|
||||
(function() {
|
||||
var getLock = 0;
|
||||
|
||||
var channels = {};
|
||||
|
||||
var zoomLevel = '100%';
|
||||
|
||||
$(function()
|
||||
{
|
||||
zoomLevel = Math.round(($(window).height() / 720) * 100) + '%'; // yay dynamic typing
|
||||
});
|
||||
|
||||
function refetchData()
|
||||
{
|
||||
getLock = 0;
|
||||
|
||||
$.get('http://channelfeed/getNew', function(data)
|
||||
{
|
||||
if (getLock > 1)
|
||||
{
|
||||
setTimeout(refetchData, 50);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
getLock++;
|
||||
|
||||
data.forEach(function(item)
|
||||
{
|
||||
switch (item.meta)
|
||||
{
|
||||
case 'print':
|
||||
var channel = item.channel;
|
||||
|
||||
if (!(channel in channels))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
channel = channels[channel];
|
||||
|
||||
var elem = $($.Mustache.render(item.channel, item.data, { method: channel.method })).appendTo(channel.$elem);
|
||||
|
||||
setTimeout(function()
|
||||
{
|
||||
elem.fadeOut(400, function()
|
||||
{
|
||||
elem.remove();
|
||||
});
|
||||
}, 7500);
|
||||
|
||||
break;
|
||||
|
||||
case 'addChannel':
|
||||
var channel = item.data;
|
||||
|
||||
if (channel.id in channels)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
channel.$elem = $('<div></div>').attr('id', 'channel-' + channel.id).appendTo('#channels');
|
||||
|
||||
if (channel.styles !== undefined)
|
||||
{
|
||||
channel.$elem.css(channel.styles);
|
||||
}
|
||||
|
||||
channel.$elem = $('<div></div>').css('zoom', zoomLevel).appendTo(channel.$elem);
|
||||
|
||||
if (channel.styleUrl !== undefined)
|
||||
{
|
||||
$('<link>').appendTo('head').attr({ type: 'text/css', rel: 'stylesheet' }).attr('href', channel.styleUrl);
|
||||
}
|
||||
|
||||
$.Mustache.add(channel.id, channel.template);
|
||||
|
||||
channels[channel.id] = channel;
|
||||
|
||||
break;
|
||||
case 'removeChannel':
|
||||
var channelId = item.data;
|
||||
|
||||
if (channelId in channels)
|
||||
{
|
||||
channel.$elem.parent().remove();
|
||||
|
||||
delete channels[channelId];
|
||||
}
|
||||
|
||||
break;
|
||||
case 'clear':
|
||||
var channel = item.channel;
|
||||
|
||||
if (!(channel in channels))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
channel = channels[channel];
|
||||
|
||||
channel.$elem.html();
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('message', function(event)
|
||||
{
|
||||
if (event.data.type != 'poll')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
refetchData();
|
||||
});
|
||||
})();
|
||||
13
resources/[gameplay]/channelfeed/client/html/index.html
Normal file
13
resources/[gameplay]/channelfeed/client/html/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<script src="nui://game/ui/mustache.js" type="text/javascript"></script>
|
||||
<script src="nui://game/ui/jquery.mustache.js" type="text/javascript"></script>
|
||||
<script src="feed.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="channels">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
BIN
resources/[gameplay]/irc/ChatSharp.dll
Normal file
BIN
resources/[gameplay]/irc/ChatSharp.dll
Normal file
Binary file not shown.
1
resources/[gameplay]/irc/__resource.lua
Normal file
1
resources/[gameplay]/irc/__resource.lua
Normal file
@@ -0,0 +1 @@
|
||||
server_script 'irc.lua'
|
||||
4
resources/[gameplay]/irc/irc.lua
Normal file
4
resources/[gameplay]/irc/irc.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
local reflection = clr.System.Reflection
|
||||
local assembly = reflection.Assembly.LoadFrom('resources/[gameplay]/irc/ChatSharp.dll')
|
||||
|
||||
dofile('resources/[gameplay]/irc/irc_run.lua')
|
||||
91
resources/[gameplay]/irc/irc_run.lua
Normal file
91
resources/[gameplay]/irc/irc_run.lua
Normal file
@@ -0,0 +1,91 @@
|
||||
local chatSharp = clr.ChatSharp
|
||||
|
||||
local client = chatSharp.IrcClient('irc.rizon.net', chatSharp.IrcUser('citimate', 'mateyate'), false)
|
||||
|
||||
-- temporary workaround for connections that never triggered playerActivated but triggered playerDropped
|
||||
local activatedPlayers = {}
|
||||
|
||||
client.ConnectionComplete:add(function(s : object, e : System.EventArgs) : void
|
||||
client:JoinChannel('#meow')
|
||||
end)
|
||||
|
||||
-- why is 'received' even misspelled here?
|
||||
client.ChannelMessageRecieved:add(function(s : object, e : ChatSharp.Events.PrivateMessageEventArgs) : void
|
||||
local msg = e.PrivateMessage
|
||||
|
||||
TriggerClientEvent('chatMessage', -1, msg.User.Nick, { 0, 0x99, 255 }, msg.Message)
|
||||
end)
|
||||
|
||||
AddEventHandler('playerActivated', function()
|
||||
client:SendMessage('* ' .. GetPlayerName(source) .. '(' .. GetPlayerGuid(source) .. '@' .. GetPlayerEP(source) .. ') joined the server', '#fourdeltaone')
|
||||
table.insert(activatedPlayers, GetPlayerGuid(source))
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
-- find out if this connection ever triggered playerActivated
|
||||
for index,guid in pairs(activatedPlayers) do
|
||||
if guid == playerGuid then
|
||||
-- show player dropping connection in chat
|
||||
client:SendMessage('* ' .. GetPlayerName(source) .. '(' .. GetPlayerGuid(source) .. '@' .. GetPlayerEP(source) .. ') left the server', '#fourdeltaone')
|
||||
table.remove(activatedPlayers, index)
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('chatMessage', function(source, name, message)
|
||||
print('hey there ' .. name)
|
||||
|
||||
local displayMessage = gsub(message, '^%d', '')
|
||||
|
||||
-- ignore zero-length messages
|
||||
if string.len(displayMessage) == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- ignore chat messages that are actually commands
|
||||
if string.sub(displayMessage, 1, 1) == "/" then
|
||||
return
|
||||
end
|
||||
|
||||
client:SendMessage('[' .. tostring(GetPlayerName(source)) .. ']: ' .. displayMessage, '#fourdeltaone')
|
||||
end)
|
||||
|
||||
AddEventHandler('onPlayerKilled', function(playerId, attackerId, reason, position)
|
||||
local player = GetPlayerByServerId(playerId)
|
||||
local attacker = GetPlayerByServerId(attackerId)
|
||||
|
||||
local reasonString = 'killed'
|
||||
|
||||
if reason == 0 or reason == 56 or reason == 1 or reason == 2 then
|
||||
reasonString = 'meleed'
|
||||
elseif reason == 3 then
|
||||
reasonString = 'knifed'
|
||||
elseif reason == 4 or reason == 6 or reason == 18 or reason == 51 then
|
||||
reasonString = 'bombed'
|
||||
elseif reason == 5 or reason == 19 then
|
||||
reasonString = 'burned'
|
||||
elseif reason == 7 or reason == 9 then
|
||||
reasonString = 'pistoled'
|
||||
elseif reason == 10 or reason == 11 then
|
||||
reasonString = 'shotgunned'
|
||||
elseif reason == 12 or reason == 13 or reason == 52 then
|
||||
reasonString = 'SMGd'
|
||||
elseif reason == 14 or reason == 15 or reason == 20 then
|
||||
reasonString = 'assaulted'
|
||||
elseif reason == 16 or reason == 17 then
|
||||
reasonString = 'sniped'
|
||||
elseif reason == 49 or reason == 50 then
|
||||
reasonString = 'ran over'
|
||||
end
|
||||
|
||||
client:SendMessage('* ' .. attacker.name .. ' ' .. reasonString .. ' ' .. player.name, '#fourdeltaone')
|
||||
end)
|
||||
|
||||
client:ConnectAsync()
|
||||
|
||||
AddEventHandler('onResourceStop', function(name)
|
||||
if name == GetInvokingResource() then
|
||||
client:Quit('Resource stopping.')
|
||||
end
|
||||
end)
|
||||
5
resources/[gameplay]/obituary-deaths/__resource.lua
Normal file
5
resources/[gameplay]/obituary-deaths/__resource.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
dependency 'obituary'
|
||||
|
||||
description 'death messages using the obituary resource'
|
||||
|
||||
client_script 'deathmessages.lua'
|
||||
42
resources/[gameplay]/obituary-deaths/deathmessages.lua
Normal file
42
resources/[gameplay]/obituary-deaths/deathmessages.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
AddEventHandler('onPlayerDied', function(playerId, reason, position)
|
||||
local player = GetPlayerByServerId(playerId)
|
||||
|
||||
if player then
|
||||
exports.obituary:printObituary('<b>%s</b> died.', player.name)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('onPlayerKilled', function(playerId, attackerId, reason, position)
|
||||
local player = GetPlayerByServerId(playerId)
|
||||
local attacker = GetPlayerByServerId(attackerId)
|
||||
|
||||
local reasonString = 'killed'
|
||||
|
||||
if reason == 0 or reason == 56 or reason == 1 or reason == 2 then
|
||||
reasonString = 'meleed'
|
||||
elseif reason == 3 then
|
||||
reasonString = 'knifed'
|
||||
elseif reason == 4 or reason == 6 or reason == 18 or reason == 51 then
|
||||
reasonString = 'bombed'
|
||||
elseif reason == 5 or reason == 19 then
|
||||
reasonString = 'burned'
|
||||
elseif reason == 7 or reason == 9 then
|
||||
reasonString = 'pistoled'
|
||||
elseif reason == 10 or reason == 11 then
|
||||
reasonString = 'shotgunned'
|
||||
elseif reason == 12 or reason == 13 or reason == 52 then
|
||||
reasonString = 'SMGd'
|
||||
elseif reason == 14 or reason == 15 or reason == 20 then
|
||||
reasonString = 'assaulted'
|
||||
elseif reason == 16 or reason == 17 then
|
||||
reasonString = 'sniped'
|
||||
elseif reason == 49 or reason == 50 then
|
||||
reasonString = 'ran over'
|
||||
end
|
||||
|
||||
echo("obituary-deaths: onPlayerKilled\n")
|
||||
|
||||
if player and attacker then
|
||||
exports.obituary:printObituary('<b>%s</b> %s <b>%s</b>.', attacker.name, reasonString, player.name)
|
||||
end
|
||||
end)
|
||||
7
resources/[gameplay]/obituary/__resource.lua
Normal file
7
resources/[gameplay]/obituary/__resource.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
dependency 'channelfeed'
|
||||
|
||||
client_script 'obituary.lua'
|
||||
|
||||
export 'printObituary'
|
||||
|
||||
files 'obituary.css'
|
||||
46
resources/[gameplay]/obituary/obituary.css
Normal file
46
resources/[gameplay]/obituary/obituary.css
Normal file
@@ -0,0 +1,46 @@
|
||||
@font-face {
|
||||
font-family: 'Roboto Condensed';
|
||||
src: url('nui://channelfeed/client/fonts/roboto-condensed.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Roboto';
|
||||
src: url('nui://channelfeed/client/fonts/roboto-regular.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
#channel-obituary
|
||||
{
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#channel-obituary > div
|
||||
{
|
||||
width: 100%;
|
||||
|
||||
font-family: 'Roboto';
|
||||
}
|
||||
|
||||
#channel-obituary div.item
|
||||
{
|
||||
background-color: rgba(50, 50, 50, .6);
|
||||
padding: 4px;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
border-radius: 4px;
|
||||
color: #eee;
|
||||
margin-bottom: 3px;
|
||||
|
||||
font-size: 65%;
|
||||
}
|
||||
|
||||
#channel-obituary div.item b
|
||||
{
|
||||
font-family: 'Roboto Condensed';
|
||||
font-size: 125%;
|
||||
font-weight: normal;
|
||||
color: #09f;
|
||||
}
|
||||
51
resources/[gameplay]/obituary/obituary.lua
Normal file
51
resources/[gameplay]/obituary/obituary.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
AddEventHandler('onClientResourceStart', function(name)
|
||||
if name == GetCurrentResource() then
|
||||
local x, y = GetHudPosition('HUD_RADAR')
|
||||
local w, h = GetHudSize('HUD_RADAR')
|
||||
|
||||
x = x - 0.01
|
||||
w = w + 0.02
|
||||
|
||||
if GetIsWidescreen() then
|
||||
x = x / 1.333
|
||||
w = w / 1.333
|
||||
end
|
||||
|
||||
exports.channelfeed:addChannel('obituary', {
|
||||
method = 'append',
|
||||
styleUrl = 'nui://obituary/obituary.css',
|
||||
styles = { -- temporary
|
||||
left = tostring(x * 100) .. '%',
|
||||
bottom = 'calc(' .. tostring((1 - y) * 100) .. '% + 10px)',
|
||||
width = tostring(w * 100) .. '%'
|
||||
},
|
||||
template = '<div class="item">{{{text}}}</div>'
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
function printObituary(format, ...)
|
||||
local args = table.pack(...)
|
||||
|
||||
for i = 1, args.n do
|
||||
if type(args[i]) == 'string' then
|
||||
args[i] = args[i]:gsub('<', '<')
|
||||
end
|
||||
end
|
||||
|
||||
echo("obituary: printObituary\n")
|
||||
|
||||
exports.channelfeed:printTo('obituary', {
|
||||
text = string.format(format, table.unpack(args))
|
||||
})
|
||||
end
|
||||
|
||||
--[[AddEventHandler('chatMessage', function(name, color, message)
|
||||
exports.channelfeed:printTo('obituary', {
|
||||
text = message:gsub('<', '<')
|
||||
})
|
||||
end)]]
|
||||
|
||||
AddEventHandler('onClientResourceStop', function()
|
||||
-- todo: remove channel
|
||||
end)
|
||||
Reference in New Issue
Block a user