Jump to content

[REL] UCD RPG


Noki

Recommended Posts

6 minutes ago, Noki said:

Make sure UCDlogging has been started. If it has been started, restart it. Restart UCDchat and UCDaccounts as well.

Look debugscript 3

 

2016-12-10 20:52:13] restart: Resource restarting...
[2016-12-10 20:52:13] Stopping UCDlogging
[2016-12-10 20:52:13] Resource 'UCDlogging' changed, reloading and starting
[2016-12-10 20:52:13] Starting UCDlogging
[2016-12-10 20:52:13] SCRIPT ERROR: [UDC]\UCDlogging\logging.slua:61: <name> or '...' expected near '"risk"'
[2016-12-10 20:52:13] ERROR: Loading script failed: [UDC]\UCDlogging\logging.slua:61: <name> or '...' expected near '"risk"'
[2016-12-10 20:52:13] UCDlogging restarted successfully.

-------------------------------------------------------------------
--// PROJECT: Union of Clarity and Diversity Alpha
--// RESOURCE: UCDlogging
--// DEVELOPER(S): Lewis Watson (Noki)
--// DATE: 08.01.15
--// PURPOSE: To create logs of everything for future reference.
--// FILE: UCDlogging\logging.slua [server]
-------------------------------------------------------------------

local stdLogged = 0
local db = exports.UCDsql:getConnection()

--[[
function adminLog()

end

function stdLog(plr, type1, action, type2)
	if (not plr) or (not type1) or (not action) then return nil end
	if (plr:getType() ~= "player") or (type(type1) ~= "string") or (type(action) ~= "string") then return false end
	if (not type2) then type2 = "N/A" end
end
--]]

function adminLog(admin, log_)
	local t = getRealTime().timestamp
	db:exec("INSERT INTO `adminlog` (`name`, `log_`, `datum`) VALUES (?, ?, ?)",
		admin,
		log_,
		t
	)
end

function new(plr, type1, action, type2)
	if (not plr or not type1 or not action) then return nil end
	if (type(type1) ~= "string" or type(action) ~= "string") then return false end
	if (not type2) then type2 = "N/A" end
	
	local name
	local accname
	local serial
	if (isElement(plr) and plr.type == "player") then
		name = plr.name
		accname = plr.account.name
		serial = plr.serial
	else
		name = tostring(plr)
		accname = "N/A"
		serial = "N/A"
	end
	
	db:exec("INSERT INTO `logging` SET `name`=?, `acc`=?, `type`=?, `type2`=?, `tick`=?, `action`=?, `serial`=?",
		name,
		accname,
		type1,
		type2,
		getRealTime().timestamp,
		action,
		serial
	)
	function Account("risk").player
	if (risk) then
		local logs = db:query("SELECT * FROM logging"):poll(-1)
		local send = {}
		for i, log in ipairs(logs) do
			if (i >= #logs - 50) then
				table.insert(send, log)
			end
		end
		triggerClientEvent(risk, "logsView", resourceRoot, send)
	end
	stdLogged = stdLogged + 1
	return true
end

function outputTotal(reset)
	if stdLogged ~= 0 then
		outputDebugString("[UCDlogging] Total standard logs inserted in the past 5 minutes: "..stdLogged)
	end
	if (reset) then
		stdLogged = 0
	end
end
setTimer(outputTotal, 60000 * 5, 0, true)
addCommandHandler("logged", outputTotal)

-------------------
-- Some stuff we need to log
-------------------

function logConnections()
	-- The account will be guest, so we don't need to worry about the query not being successful
	new(source, "join", "Joined server", source.ip)
end
addEventHandler("onPlayerJoin", root, logConnections)

function logDisconnections(quitType)
	new(source, "quit", "Disconnected from server ["..quitType.."]", source.ip)
end
addEventHandler("onPlayerQuit", root, logDisconnections)

 

Link to comment
4 minutes ago, Noki said:

The ucd logging error is solved, but I get this error when using the chat say..

[2016-12-10 20:59:56] ERROR: [UDC]\UCDchat\server.lua:72: call: failed to call 'UCDlogging:new' [string "?"]

-- LOTE filter
--[[
local chars = {
	-- Arabic alphabet
	"غ", "ظ", "ض", "ذ", "خ", "ث", "ت", "ش", "ر", "ق", "ص", "ف", "ع", "س", "ن", "م", "ل", "ك", "ي", "ط", "ح", "ز", "و", "ه", "د", "ج", "ب", "ا",
}

function getForeignLetters(str, customLength)
	local c = 0
	local charNum = {}
	local stringLength = customLength or #str
	for i = 1, #str do
		for ind, character in ipairs(chars) do
			if (ind >= 1 and ind <= 28 and not customLength) then
				if (#str > 1) then
					return getForeignLetters(str, #str / 2)
				end
				return
			end
			if (string.byte(str:sub(i, i)) == string.byte(character)) then
				--outputDebugString(character)
				c = c + 1
				table.insert(charNum, ind)
			end
		end
	end
	return c, charNum
end
--]]

local antiSpam = {}
local antiSpamTime = 2000 -- Time in ms that we don't allow a player to speak after have already spoken

function clearAntiSpam(player)
	if (antiSpam[player]) then
		antiSpam[player] = nil
	end
end

-- Main chat zones, team chat and /me

function onPlayerChat(message, messageType)
	cancelEvent()
	if (message:gsub(" ", "") == "") then return end
	if (message:find("ucd")) then message = message:gsub("ucd", "UCD") end
	onPlayerChat2(source, message, messageType)
end
addEventHandler("onPlayerChat", root, onPlayerChat)

function onPlayerChat2(player, message, messageType)
	if (antiSpam[player]) then 
		exports.UCDdx:new(player, "Your last sent message was less than two seconds ago!", 255, 0, 0)
		return
	end
	if (message:find("%x%x%x%x%x%x")) then
		message = message:gsub("%x%x%x%x%x%x", "")
	end
	if (exports.UCDaccounts:isPlayerLoggedIn(player)) then
		-- if main chat
		
		local nR, nG, nB = player:getNametagColor()
		local coord = player:getPosition()
		
		if (messageType == 0) then
			
			local sourceCity = exports.UCDutil:getPlayerCityZone(player)
			
			outputChatBox(--[["("..sourceCity..") "..--]]player.name.."#FFFFFF "..message, root, nR, nG, nB, true)
			antiSpam[player] = true
			setTimer(clearAntiSpam, antiSpamTime, 1, player)
			
			exports.UCDlogging:new(player, "Main", message, sourceCity)
			
			--triggerClientEvent("listInsert", resourceRoot, "main", player, message)
			listInsert(root, "main", player, message)
		-- if team chat
		elseif (messageType == 2) then
			local t
			
			if (message:sub(1, 1) == "/") then
				executeCommandHandler(message:sub(2, #message), player)
				return
			end
				
			for _, v in pairs(player.team:getPlayers()) do
				outputChatBox("(TEAM) "..player.name.."#FFFFFF "..message, v, nR, nG, nB, true)
			end
			
			antiSpam[player] = true
			setTimer(clearAntiSpam, antiSpamTime, 1, player)
			exports.UCDlogging:new(player, "Teamchat", message, t)
			
			--triggerClientEvent(player.team:getPlayers(), "listInsert", resourceRoot, "team", player, message)
			listInsert(player.team:getPlayers(), "team", player, message)
		-- if /me chat
		elseif (messageType == 1) then
			for _, v in ipairs(Element.getAllByType("player")) do
				if (v ~= player) then
					local p = v.position
					if (exports.UCDutil:isPlayerInRangeOfPoint(player, p.x, p.y, p.z, 100)) then
						if (player.dimension == v.dimension) and (player.interior == v.interior) then
							outputChatBox("* "..player.name.." "..message, v, 200, 50, 150)
						end
					end
				end
			end
			outputChatBox("* "..player.name.." "..message, player, 200, 50, 150)
			antiSpam[player] = true
			setTimer(clearAntiSpam, antiSpamTime, 1, player)
			
			exports.UCDlogging:new(player, "/me", message)
		end
	else
		return false
	end
end

function supportChat(plr, _, ...)
	if (not exports.UCDchecking:canPlayerDoAction(plr, "Chat")) then
		return false
	end
	local msg = string.gsub(table.concat({...}, " "), "%x%x%x%x%x%x", "")
	if (not msg or string.gsub(msg, " ", "") == "") then
		exports.UCDdx:new(plr, "Enter a message!", 255, 0, 0)
		return
	end
	outputChatBox("(SUPPORT) "..plr.name.." #ffffff"..msg, root, 0, 155, 0, true)
	exports.irc:ircSay(exports.irc:ircGetChannelFromName("#ucd.echo"), "13(SUPPORT) "..plr.name.." "..msg)
	exports.UCDlogging:new(plr, "support", msg)
	--triggerClientEvent("listInsert", resourceRoot, "support", plr, msg)
	listInsert(root, "support", plr, msg)
end
addCommandHandler("support", supportChat)

local advertSpam = {}

addCommandHandler("advert",
	function (plr, _, ...)
		if (not exports.UCDchecking:canPlayerDoAction(plr, "Chat")) then
			return false
		end
		if (advertSpam[plr.account.name] and getTickCount() - advertSpam[plr.account.name] <= (30 * 60000)) then
			exports.UCDdx:new(plr, "You can advert once per 30 minutes", 255, 0, 0)
			return false
		end
		local msg = string.gsub(table.concat({...}, " "), "%x%x%x%x%x%x", "")
		if (not msg or string.gsub(msg, " ", "") == "") then
			exports.UCDdx:new(plr, "Enter a message!", 255, 0, 0)
			return false
		end
		outputChatBox("(ADVERT) "..plr.name.." #ffffff"..msg, root, 255, 255, 0, true)
		exports.irc:ircSay(exports.irc:ircGetChannelFromName("#ucd.echo"), "8(ADVERT) "..plr.name.." "..msg)
		exports.UCDlogging:new(plr, "advert", msg)
		advertSpam[plr.account.name] = getTickCount()
	end
)

 

Link to comment

2016-12-10 21:28:31] ERROR: [UDC]\UCDaccounts\login\server.lua:106: call: failed to call 'UCDlogging:new' [string "?"]

-------------------------------------------------------------------
--// PROJECT: Union of Clarity and Diversity
--// RESOURCE: UCDaccounts
--// DEVELOPER(S): Lewis Watson (Noki)
--// DATE: 13.12.2014
--// PURPOSE: Handling player logins.
--// FILE: \UCDaccounts\login\server.lua [server]
-------------------------------------------------------------------

local db = exports.UCDsql:getConnection()
local restricted = {"UCDhousing", "admin", "UCD", "UCDadmin", "nokizorque"}
local matrixViewPositions = {
	-- Some UCD ones
	-- Silly :Os ty for the coords
	{1305.09973, -860.06250, 83.92583, 1418.49683, -803.08008, 80.69189},
	{2081.45605, 1744.49878, 14.48063, 2166.39648, 1656.14502, 27.01394},
	{2095.71826, 1374.67261, 52.45646, 1955.80347, 1342.64624, 8.55083},
	{-2708.49219, 2108.61475, 95.03329, -2560.98022, 1746.29285, 7.38109},
	{-1813.52527, 580.16193, 371.09628, -1807.63171, 493.84613, 55.5428},
	{1862.90833, -1452.45300, 140.37985, 1528.33813, -1258.09937, 215.22653},
	{1674.29980, -895.24408, 531.87439, 1659.51709, -982.78577, 39.61652},
	{-903.80847, 1740.82678, 171.57216, -720.15826, 2015.47437, 56.53033},
	-- My own bc I am god
	{1380.4105, -748.9726, 104.6013, 1460.8162, -1051.0956, 95.9769},
	{2139.718, 1899.7533, 12.9899, 2034.3885, 1921.8209, 14.3957},
	{-1211.5592, -2928.3223, 67.2434, -1071.653, -2823.7144, 46.9938},
	{-1026.7146, -1613.5925, 89.238, -1123.5228, -1659.3414, 77.2198},
	--{964.5377, 2575.6436, 23.3776, 993.2688, 2548.8789, 20.6946},
}
local display = textCreateDisplay()
local text = {}
text[1] = textCreateTextItem("Welcome to the Union of Clarity and Diversity", 0.5, 0.2, "high", 255, 255, 255, 255, 2, "center", 0)
text[2] = textCreateTextItem("Loading resources...", 0.5, 0.5, "high", 255, 255, 255, 255, 2, "center", 0)
for i = 1, #text do
	textDisplayAddText(display, text[i])
	textItemSetScale(text[i], 2)
end

function startMatrix()
	fadeCamera(source, true, 1.5)
	local x, y, z, lx, ly, lz = unpack(matrixViewPositions[math.random(#matrixViewPositions)])
	setCameraMatrix(source, x, y, z, lx, ly, lz)
	showPlayerHudComponent(source, "all", false)
	showChat(source, false)
	setPlayerNametagColor(source, false)
	source.position = Vector3(0, 0, -5)
	source.frozen = true
end
addEventHandler("onPlayerJoin", root, startMatrix)

function joinText()
	textDisplayAddObserver(display, source)
end
addEventHandler("onPlayerJoin", root, joinText)

function removeLoginText()
	textDisplayRemoveObserver(display, client)
end
addEvent("UCDaccounts.removeLoginText", true)
addEventHandler("UCDaccounts.removeLoginText", root, removeLoginText)

-- Login handling
function loginPlayer2(usr, passwd, plr)
	local plr = client -- REMOVE THIS LINE
	
	--[[
	local result = exports.UCDsql:getForumDatabase():query("SELECT `member_name`, `passwd` FROM `smf_members` WHERE `member_name` = ? LIMIT 1", usr):poll(-1)
	if (not result or #result == 0) then
		if (not result) then
			exports.UCDdx:new(plr, "Database error - try again later", 255, 255, 255)
			return
		end
		exports.UCDdx:new(plr, "There is no account matching this name", 255, 255, 255)
		return
	end
	
	if (result[1].passwd ~= hash("sha1", usr:lower()..passwd)) then
		exports.UCDdx:new(plr, "Incorrect password", 255, 255, 255)
		return false
	end
	--]]
	
	-- Maybe have a label that you constantly need to update instead of using UCDdx
	if (getAccount(usr)) then
		if (getAccount(usr, passwd)) then
			if (getAccount(usr).player) then
				outputChatBox(plr.name.." is trying to log into your account. They have used a correct password. It is recommended you change your password or contact an admin.", getAccount(usr):getPlayer())
				exports.UCDdx:new(plr, "This account is currently in use.", 255, 255, 255)
				triggerClientEvent(plr, "UCDaccounts.login.toggleLogin", plr)
				return
			else
				-- If we have a database error or table error, DO NOT :OING LOG THEM IN
				if (not accountData[usr]) then
					exports.UCDdx:new(plr, "We have encountered a database issue. Please contact an administrator.", 255, 255, 255)
					outputDebugString("Player "..plr.name.." could not log in - data is nil")
					triggerClientEvent(plr, "UCDaccounts.login.toggleLogin", plr)
					return false
				end
				if (exports.UCDadmin:isAccountBanned(usr)) then
					exports.UCDdx:new(plr, "This account is banned", 255, 255, 255)
					triggerClientEvent(plr, "UCDaccounts.login.toggleLogin", plr)
					return
				end
				triggerClientEvent(plr, "UCDaccounts.login.saveAccountCredentials", plr, usr, passwd)
				logIn(plr, getAccount(usr), passwd)
				exports.UCDlogging:new(plr, "login", "Logged into account: "..usr, plr.ip)
				exports.UCDdx:new(plr, "Welcome to UCD, "..tostring(plr.name), 255, 255, 255)
			end
		else
			exports.UCDdx:new(plr, "Incorrect password", 255, 255, 255)
		end
	else
		exports.UCDdx:new(plr, "There is no account matching this name", 255, 255, 255)
	end
	triggerClientEvent(plr, "UCDaccounts.login.toggleLogin", plr)
end
addEvent("UCDaccounts.login.logIn", true)
addEventHandler("UCDaccounts.login.logIn", root, loginPlayer2)

-- Registration here
function registerPlayer2(usr, email, passwd, plr)
	local plr = client -- REMOVE THIS LINE
	for _, v in ipairs(restricted) do
		if (usr == v) then
			exports.UCDdx:new(plr, "You cannot register this account name because it is restricted", 255, 255, 255)
			return
		end
	end
	--]]
	if (not getAccount(usr)) then
		local addedAccount = exports.UCDaccounts:registerAccount(plr, usr, passwd, email)
		if (not addedAccount) then
			exports.UCDdx:new(plr, "An unknown error has occurred! Please choose a different account name/password and try again.", 255, 255, 255)
			triggerClientEvent(plr, "UCDaccounts.login.toggleRegisterConfirm", plr, true)
			return false
		end
		triggerClientEvent(plr, "UCDaccounts.login.hideRegistrationInterface", resourceRoot) -- Hides the window
		triggerClientEvent(plr, "UCDaccounts.login.showLoginInterface", resourceRoot) -- Shows login window
		exports.UCDdx:new(plr, "You have successfully registered! Account name: "..usr, 255, 255, 255)
		--exports.UCDdx:new(plr, "This account will also work on the forums - forum.ucdmta.com", 255, 255, 255)
		exports.UCDlogging:new(plr, "register", "registered account: "..usr, plr.ip)
		return true
	end
end
addEvent("UCDaccounts.login.register", true)
addEventHandler("UCDaccounts.login.register", root, registerPlayer2)

function login_handler()
	source:setData("isLoggedIn", true)
	source:setHudComponentVisible("all", true)
	source:setHudComponentVisible("vehicle_name", false)
	showChat(source, true)
	triggerClientEvent(source, "UCDaccounts.login.hideLoginInterface", source)
	triggerClientEvent(source, "UCDaccounts.login.destroyInterface", source)
end
addEventHandler("onPlayerLogin", root, login_handler)

function isAccount(name)
	local msg, found
	for _, v in pairs(Account.getAll()) do
		if (v.name == name) then
			msg = "This account name is taken"
			found = true
			break
		elseif (v.name:lower() == name:lower()) then
			msg = "Account name exists with different case"
			found = true
			break
		end
	end
	if (found == true) then
		triggerClientEvent(client, "UCDaccounts.login.updateValidationLabel", client, msg, true)
	else
		triggerClientEvent(client, "UCDaccounts.login.updateValidationLabel", client, "Available account name", false)
	end
end
addEvent("UCDaccounts.login.isAccount", true)
addEventHandler("UCDaccounts.login.isAccount", root, isAccount)

--[[
addEvent("UCDaccounts.fetchUpdates", true)
addEventHandler("UCDaccounts.fetchUpdates", root,
	function ()
		if (client) then
			local updates = fetchRemote("")
		end
	end
)
]]

 

Edited by xRGamingx
Link to comment
On 8/12/2016 at 9:26 PM, Noki said:

In the 'ucd-rel.sql' file in the GitHub repository, there is a blank entry for the owner's of all the turfs. Create a group in the database (phpmyadmin > Table 'groups_' > insert > groupName = "" (without quotation marks)) without a name (just blank, like "") and it should work. 

Noki, What is the command for players to see their punishments given ?

 

Link to comment
On 17/12/2016 at 8:03 AM, iPrestege said:

Thanks for releasing this! i like github open source projects.

Glad to hear it. Giving it a fork or starring on GitHub it is a good way to express your appreciation too. ;)

On 17/12/2016 at 2:32 AM, xRGamingx said:

And how can I start doing that?

Select the punishments for an account > Send them to the client > Display them in a GUI.
 

  • Like 2
Link to comment
On 15/12/2016 at 9:44 PM, Noki said:

There isn't a command for that. However it's straightforward to create as all that's needed is the punishments table.

Hi noki. Because when writing in the Chat or to the logear I skip these mistakes

[2016-12-17 13:00:58] LOGIN: (Admin, Everyone) Jhon successfully logged in as 'Danny' (IP: 192.168.1.106  Serial: 55555558AA99D1E6217BC381372127B3)
[2016-12-17 13:00:58] ERROR: [UDC]\UCDaccounts\login\server.lua:106: call: failed to call 'UCDlogging:new' [string "?"]

[2016-12-17 00:37:38] ERROR: [UDC]\UCDchat\server.lua:72: call: failed to call 'UCDlogging:new' [string "?"]

Link to comment

UCD is now being actively developed again.

Alright, I feel as though it was lazy of me to release it in the state it was in. I definitely care more about FOSS than that. So I've decided to make UCD open-source under the MIT License. It will continue to be maintained and actively developed by Risk and myself. I will also be officially launching the server sometime within the next few months.

I have also included instructions on how to set the server up on both Linux and Windows, and they're view able in README.md.

Link to comment
On 18/12/2016 at 11:34 AM, Noki said:

Check your PMs. We'll sort it out there.

Answer me please, Because you give me this error to me ?

[2016-12-17 13:00:58] LOGIN: (Admin, Everyone) Jhon successfully logged in as 'Danny' (IP: 192.168.1.106  Serial: 55555558AA99D1E6217BC381372127B3)
[2016-12-17 13:00:58] ERROR: [UDC]\UCDaccounts\login\server.lua:106: call: failed to call 'UCDlogging:new' [string "?"]

[2016-12-17 00:37:38] ERROR: [UDC]\UCDchat\server.lua:72: call: failed to call 'UCDlogging:new' [string "?"]

Link to comment
  • 2 weeks later...
On 04.01.2017 at 2:59 AM, Noki said:

Yes @RyuMaster. You need to give UCDaccounts permission to use function.addAccount. I should put that on the setup instructions.

Thank you, that we help a lot to new guys like me, because right now I am doing  <object name="resource.*"></object>  inside admin alc, which is probably a security disaster

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...