Jump to content

Script group system last name


AnnaBelle

Recommended Posts

--Client
function addToList(account, rank, joined, lastTime, nick, online)
	local row = guiGridListAddRow(adminMembsList)
	guiGridListSetItemText(adminMembsList, row, 1, tostring(nick), false, false)
	guiGridListSetItemText(adminMembsList, row, 2, tostring(account), false, false)
	guiGridListSetItemText(adminMembsList, row, 3, tostring(rank), false, false)
	guiGridListSetItemText(adminMembsList, row, 4, tostring(lastTime), false, false)
	
	if (online) then
		guiGridListSetItemColor(adminMembsList, row, 1, 0, 255, 0)
		guiGridListSetItemColor(adminMembsList, row, 2, 0, 255, 0)
		guiGridListSetItemColor(adminMembsList, row, 3, 0, 255, 0)
		guiGridListSetItemColor(adminMembsList, row, 4, 0, 255, 0)
	else
		guiGridListSetItemColor(adminMembsList, row, 1, 255, 0, 0)
		guiGridListSetItemColor(adminMembsList, row, 2, 255, 0, 0)
		guiGridListSetItemColor(adminMembsList, row, 3, 255, 0, 0)
		guiGridListSetItemColor(adminMembsList, row, 4, 255, 0, 0)
	end
end
addEvent("groupSystem.addToList", true)
addEventHandler("groupSystem.addToList", root, addToList)

--Server
function printManagment(player)
	if (player) then player = client end
	local group = getPlayerGroup(client)
	for ind, data in pairs(GAC) do
		if (data[1] == group) then
			local rank, joined, lastTime = GAC[ind][2], GAC[ind][3],GAC[ind][4], GAC[ind][5]
			triggerClientEvent(client, "groupSystem.addToList", client, tostring(ind), rank, joined, lastTime, getAccountPlayer(getAccount(ind)), getGroupBankAmount(group))
		end
	end
end
addEvent("groupSystem.print", true)
addEventHandler("groupSystem.print", root, printManagment)

http://prntscr.com/g4ef8q

Two player connected, but shows my game name for two

Edited by AnnaBelle
Link to comment

I modified code for this

function printManagment(player)
	if (not player) then player = client end
	local group = getPlayerGroup(client)
	for ind, data in pairs(GAC) do
		if (data[1] == group) then
			local rank, joined, lastTime = GAC[ind][2], GAC[ind][3],GAC[ind][4], GAC[ind][5]
			triggerClientEvent(client, "groupSystem.addToList", client, tostring(ind), rank, joined, lastTime, getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x',''), getAccountPlayer(getAccount(ind)), getGroupBankAmount(group))
		end
	end
end
addEvent("groupSystem.print", true)
addEventHandler("groupSystem.print", root, printManagment)

but it did not work :/
 

Link to comment
local groupTable = {}
local logging = false
local debugInfo = false
local GAC = {} 
local users = {}
local myGang = {}
local char = "09azAZ"
local rankCache = {}
local db = dbConnect("sqlite", "database.db")
dbExec(db, "CREATE TABLE IF NOT EXISTS groupmember (account TEXT, groupName TEXT, rank TEXT,  joined TEXT, lastTime TEXT)")
dbExec(db, "CREATE TABLE IF NOT EXISTS groups (name TEXT, leader TEXT, message TEXT, chatcolor TEXT, notecolor TEXT, date TEXT, turfcolor TEXT, cashflow TEXT)")
dbExec(db, "CREATE TABLE IF NOT EXISTS groupRanks (groupName TEXT, name TEXT, permissions TEXT)")
dbExec(db, "CREATE TABLE IF NOT EXISTS groupVault (groupName TEXT, leader TEXT)")
playerTeam = createTeam("Player")

_outputDebugString = outputDebugString
function outputDebugString(string)
	if (debugInfo) then _outputDebugString(string) end
end

function getTheTime()
    local time = getRealTime()
    local date = string.format("%02d/%02d/%02d", time.monthday, (time.month+1), (time.year-100) )
    local time = string.format("%02d:%02d", time.hour, time.minute)
    return date, time
end

MTAoutput = outputChatBox
function outputChatBox(message, player, r, g, b, bool)
	if (isElement(message) and getElementType(message) == "player") then
		MTAoutput(player, message, r, g, b, bool)
	else
		MTAoutput(message, player, r, g, b, bool)
	end
end

function groupLog(group, message)
	if (logging) then
		outputServerLog("GROUP: "..group.." - "..message)
	end
end

local permToTable = {
	[1] = "permissionModifyRank",
	[2] = "permissionKickOut",
	[3] = "permissionInvitePlay",
	[4] = "permissionOfRank",
	[5] = "permissionMensegeofDay",
}

function GetAccount(plr)
	if (plr and isElement(plr)) then
		return getAccountName(getPlayerAccount(plr))
	end
end

function loadGroupRanks(query)
	local the_table = dbPoll(query, 0)
	if (the_table) then
		for ind, data in pairs(the_table) do
			if (not rankCache[data.groupName]) then rankCache[data.groupName] = {} end
			if (not rankCache[data.groupName][data.name]) then rankCache[data.groupName][data.name] = {} end
			local JSONtable = fromJSON(data.permissions)
			for ind, value in pairs(JSONtable) do
				if (value and ind) then
					rankCache[data.groupName][data.name][ind] = true
				end
			end
		end
	end
end
dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks")

function loadGroupStuff(query)
	local g_table = dbPoll(query, 0)
	
	if (not g_table) then return end
	
	for ind, data in ipairs(g_table) do
		groupTable[data.name] = {data.leader, data.message, data.chatcolor, data.notecolor, data.date, data.turfcolor, data.cashflow}
	end
end
dbQuery(loadGroupStuff, db, "SELECT * FROM groups")

function loadClientGroup(query)
	local g_table = dbPoll(query, 0)
	
	if (not g_table) then return end
	
	for ind, data in ipairs(g_table) do
		if (getAccount(data.account)) then
			local player = getAccountPlayer(getAccount(data.account))
			users[data.groupName] = {}
			table.insert(users[data.groupName], data.account)
			if (player) then
				setElementData(player, "Group", data.groupName)
				myGang[player] = data.groupName
			end
			GAC[data.account] = {data.groupName, data.rank, data.joined, data.lastTime or 0}
		end
	end
end
dbQuery(loadClientGroup, db, "SELECT * FROM groupmember")

function addRank(group, rank, permissionTable)
	if (not rankCache[group]) then rankCache[group] = {} end
	dbExec(db, "INSERT INTO groupRanks VALUES (?, ?, ?)", tostring(group), tostring(rank), permissionTable)
	dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks")
end

function removeRank(group, rank)
	if (not rankCache[group]) then return true end
	if (rankCache[group][rank]) then
		rankCache[group][rank] = nil
		dbExec(db, "DELETE FROM groupRanks WHERE name=? AND groupName=?", tostring(rank), tostring(group))
		dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks")
		return true
	end
end

function isRank(group, rank)
	if (not rankCache[group]) then return false end
	return rankCache[group][rank]
end

function groupMemberLogin()
	if (GAC[GetAccount(source)]) then
		myGang[source] = GAC[GetAccount(source)][1]
		setElementData(source, "Group", GAC[GetAccount(source)][1])
		setPlayerTeam(source,playerTeam)
		local date, time = getTheTime()
		local date = date.." - "..time
		GAC[GetAccount(source)][5] = date
	end
end
addEventHandler("onPlayerLogin", root, groupMemberLogin)

function groupMemberQuit()
	if (GAC[GetAccount(source)]) then
		local date, time = getTheTime()
		local date = date.." - "..time
		GAC[GetAccount(source)][5] = date
	end
end
addEventHandler("onPlayerQuit", root, groupMemberQuit)

function getGroupMembers(group)
	local temp = {}
	for ind, data in pairs(users) do
		if (ind == group) then
			table.insert(temp, data[1])
		end
	end
	return temp
end

function getPlayerGroup(player)
	if (not GAC[GetAccount(player)]) then return false end
	return GAC[GetAccount(player)][1]
end

function getPlayerGroupRank(player)
	if (not GAC[GetAccount(player)]) then return false end
	return GAC[GetAccount(player)][2]
end

--function getPlayerWarningLevel(player)
--	if (not GAC[GetAccount(player)]) then return false end
--	return GAC[GetAccount(player)][3]
--end

function getGroupBankAmount(group)
	if (not groupTable[group]) then return end
	return groupTable[group][7]
end

function getPlayerJoinDate(player)
	if (not GAC[GetAccount(player)]) then return false end
	return GAC[GetAccount(player)][4]
end

function getHexCode(r, g, b)
	if (r and g and b) then
		return string.format("#%.2X%.2X%.2X", r, g, b)
	end
end

function getGroupChatColor(group)
	if (not groupTable[group]) then return 255, 255, 255 end
	local color = fromJSON(groupTable[group][3])
	return color[1], color[2], color[3]
end

function outputGroupMessage(message, group)
	for ind, data in pairs(GAC) do
		if (data[1] == group) then
			local acc = getAccount(ind)
			if (getAccountPlayer(acc)) then
				local color = fromJSON(groupTable[group][3])
				local hex = getHexCode(color[1], color[2], color[3])
				outputChatBox("#FF0000[#FFFFFFGroup System#FF0000]#FFFFFF "..message, getAccountPlayer(acc), 9,249,17, true)
				groupLog(group, message)
			end
		end
	end
end

function checkGroupAccess(player, actionID)
	local rank = getPlayerGroupRank(player)
	local group = getPlayerGroup(player)
	if (not rankCache[group]) then return false end
	if (rankCache[group] and rankCache[group][rank]) then
		if (tostring(actionID)) then
			for ind, data in pairs(permToTable) do
				if (data == actionID) then
					actionID = ind
					break
				end
			end
		end
		local actionID = tonumber(actionID)
		if (rankCache[group][rank][actionID]) then
			return true
		end
	end
end

function getPermissionCount(group, rank)
	if (not rankCache[group]) then return false end
	local count = 0
	
	if (rankCache[group] and rankCache[group][rank]) then
		for ind, data in pairs(rankCache[group][rank]) do
			count = count + 1
		end
	end
	
	return count
end

function getGroupRankCount(group)
	if (not rankCache[group]) then return end
	local count = 0
	for ind, v in pairs(rankCache[group]) do
		count = count + 1
	end
	return tonumber(count) or 1
end

function doSomethingWithBank(stuff, amount)
	if (not stuff) then return end
	if (not tonumber(amount)) then
		outputChatBox(tostring(amount).. " is an invalid amount of money", client, 255, 0, 0)
		return
	end
	
	local group = getPlayerGroup(client)
	
	if (not group) then
		outputChatBox("You are not in a group at the moment", client, 255, 0, 0)
		return
	end
	
	if (stuff == "deposit") then
		if (getPlayerMoney(client) >= tonumber(amount)) then
			takePlayerMoney(client, amount)
			dbExec(db, "UPDATE groups SET cashflow=? WHERE name=?", tostring(getGroupBankAmount(group) + amount), tostring(group))
			groupTable[group][7] = tostring(getGroupBankAmount(group) + amount)
			outputGroupMessage(getPlayerName(client).. " deposited $"..amount.." into "..group.." the total balance is now: $".. getGroupBankAmount(group), group)
			viewWindow(client)
		else
			outputChatBox("You are missing $" ..amount - getPlayerMoney(client).." therefor you are unable to withdraw.", client, 255, 0, 0)
		end
	elseif(stuff == "withdraw") then
		if (not checkGroupAccess(client, 16)) then
			outputChatBox("You are not allowed to perform this action.", client, 255, 0, 0)
			return
		end
		if (tonumber(amount) > tonumber(groupTable[group][7])) then
			outputChatBox("You are trying to withdraw too much, your group bank balance is: $" ..groupTable[group][7], client, 255, 255, 0)
			return
		end
		dbExec(db, "UPDATE groups SET cashflow=? WHERE name=?", tostring(getGroupBankAmount(group) - amount), tostring(group))
		groupTable[group][7] = tostring(tonumber(getGroupBankAmount(group)) - amount)
		outputGroupMessage(getPlayerName(client).. " withdrew $"..amount.." from "..group.." bank, the total balance is now: $".. groupTable[group][7], group)
		viewWindow(client)
	end
end
addEvent("groupsys.doSomethingWithBank", true)
addEventHandler("groupsys.doSomethingWithBank", root, doSomethingWithBank)
	
function viewWindow(player)
	if (player) then client = player end
	local group = getPlayerGroup(client)
	local rank = getPlayerGroupRank(client)
	local dateJoined = getPlayerJoinDate(client)
	local cash = getGroupBankAmount(group)
	local permRank = false
	local msg = ""
	if (group and group ~= "none" and groupTable[group] and groupTable[group][2]) then
		msg = groupTable[group][2]
	end
	
	if (group and rank and rankCache[group] and rankCache[group][rank]) then
		permRank = rankCache[group][rank]
	end
	
	triggerClientEvent(client, "groupSystem.done", client, group, rank, dateJoined, msg, permRank, cash)
end
addEvent("groupSystem.viewWindow", true)
addEventHandler("groupSystem.viewWindow", root, viewWindow)

function attemptMakeGroup(name)
	if (isGuestAccount(getPlayerAccount(client))) then return end
	
	if (groupTable[name]) then
		outputChatBox("There is already a group with this name", client, 255, 0, 0)
		return
	end
	
	local name = string.gsub(name, char, "")
	if (#name > 20) then
		outputChatBox("#FF0000[#FFFFFFERRO#FF0000]#FFFFFF Só é permitido 20 caracteres no nome do grupo", client, 255, 0, 0,true)
		return
	end
	
	if (not getPlayerGroup(client) or getPlayerGroup(client) == "None" or getPlayerGroup == "nil") then
		local date, time = getTheTime()
		local date = date.." - "..time
		createGroup(name, client, date)
		setGroup(client, name, date, "Founder")
		outputChatBox("#FF0000[#FFFFFFGroup System#FF0000]#FFFFFF Grupo criado com sucesso! Nome: "..name, client, 0, 255, 0,true)
	end
end
addEvent("groupSystem.attemptMakeGroup", true)
addEventHandler("groupSystem.attemptMakeGroup", root, attemptMakeGroup)

function createGroup(name, creator, date)
	if (not users[name]) then
		users[name] = {}
	end
	local permissionsFounder = {1,2,3,4,5}
	local permissionsMembro = {}
	local color = {math.random(255), math.random(255), math.random(255)}
	addRank(name, "Founder", toJSON(permissionsFounder))
	addRank(name, "Membro", toJSON(permissionsMembro))
	groupTable[name] = {GetAccount(creator), "", toJSON(color), toJSON(color), date, toJSON(color)}
	myGang[creator] = name
	table.insert(users[name], GetAccount(creator))
	dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks")
	dbExec(db, "INSERT INTO groups VALUES (?, ?, ?, ?, ?, ?, ?, ?)", name, GetAccount(creator), "", toJSON(color), toJSON(color), date, toJSON(color), 0)
	setPlayerTeam(creator,playerTeam)
	outputDebugString(getPlayerName(creator).." created group: "..name.." at: "..date)
end

function setGroup(player, group, date, rank)
	if (not users[group]) then
		users[group] = {}
	end
	local date, time = getTheTime()
	local date = date.." - "..time
	local color = {math.random(255), math.random(255), math.random(255)}
	myGang[player] = gang
	GAC[GetAccount(player)] = {group, rank, 0, date, 0}
	table.insert(users[group], GetAccount(player))
	dbExec(db, "INSERT INTO groupmember VALUES (?, ?, ?, ?, ?)", tostring(GetAccount(player)), tostring(group), tostring(rank), "0", date, "0")
	viewWindow(player)
	outputDebugString(getPlayerName(player).." joined group: "..group.." as: "..rank.." at: "..date)
	setElementData(player, "Group", group)
	setPlayerTeam(player,playerTeam)
end

function leaveGroup(player)
	if (not player) then player = client end
	
	local group = getPlayerGroup(player)
	if (not group) then return end
	
	if (getPlayerGroupRank(player) == "Founder") then
		outputGroupMessage(getPlayerName(player):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." Fecho o grupo/clã!", group)
		for ind, data in pairs(GAC) do
			if (data[1] == group) then
				if (getAccountPlayer(getAccount(ind))) then
					setElementData(getAccountPlayer(getAccount(ind)), "Group", nil)
				end
				dbExec(db, "DELETE FROM groupmember WHERE account=?", tostring(ind))
				GAC[ind] = nil
			end
		end
		dbExec(db, "DELETE FROM groupRanks WHERE groupName=?", tostring(group))
		dbExec(db, "DELETE FROM groups WHERE name=?", tostring(group))
		groupTable[group] = nil
		rankCache[group] = nil
	end
	dbExec(db, "DELETE FROM groupmember WHERE account=?", tostring(GetAccount(player)))
	GAC[GetAccount(player)] = nil
	viewWindow(player)
	myGang[player] = nil
	setPlayerTeam(player,nil)
end
addEvent("groupSystem.leaveGroup", true)
addEventHandler("groupSystem.leaveGroup", root, leaveGroup)
--------------------------------------------------------------------------//Permissao para expulsar jogador do grupo
function kickAccount(account)
	if (not checkGroupAccess(client, 2)) then 
			outputChatBox("#FF0000[System Group]#FFFFFF Permissão insuficiente.",client,255,0,0,true) 
		return
	end
	dbExec(db, "DELETE FROM groupmember WHERE account=?", tostring(account))
	GAC[account] = nil
	
	local plr = getAccountPlayer(getAccount(account))
	if (plr) then
		myGang[plr] = nil
		viewWindow(plr)
	end
end
addEvent("groupSystem.kickFromGroup",true)
addEventHandler("groupSystem.kickFromGroup",root,kickAccount)
--------------------------------------------------------------------------//Permissao para expulsar jogador do grupo
--------------------------------------------------------------------------//Permissao para editar mensagem do dia
function updateMessage(message)
	local group = getPlayerGroup(client)
	if (not groupTable[group]) then return end
	if (not checkGroupAccess(client, 5)) then return end
	groupTable[group][2] = message
	viewWindow(client)
	dbExec(db, "UPDATE groups SET message=? WHERE name=?", tostring(message), tostring(group))
	outputGroupMessage(getPlayerName(client).." has updated the encampment board!", group)
end
addEvent("groupSystem.updateMessage", true)
addEventHandler("groupSystem.updateMessage", root, updateMessage)
--------------------------------------------------------------------------//Permissao para editar mensagem do dia
function printManagment(player)
	if (not player) then player = client end
	local group = getPlayerGroup(client)
	for ind, data in pairs(GAC) do
		if (data[1] == group) then
			local rank, joined, lastTime = GAC[ind][2], GAC[ind][3],GAC[ind][4], GAC[ind][5]
			triggerClientEvent(client, "groupSystem.addToList", client, tostring(ind), rank, joined, lastTime, getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x',''), getAccountPlayer(getAccount(ind)), getGroupBankAmount(group))
		end
	end
end
addEvent("groupSystem.print", true)
addEventHandler("groupSystem.print", root, printManagment)
----------------------------------------------------------------------------------------------------//Convidar Membro
function makeInvite(player)
	if (getPlayerGroup(player)) then return end
	if (not getPlayerGroup(client)) then return end
	if (not checkGroupAccess(client, 1)) then return end
	local group = getPlayerGroup(client)
	outputChatBox(getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." has sent an invitation to join his encampment: "..group, player, 0, 255, 0)
	outputChatBox("Sent an invite to "..getPlayerName(player).." to join "..group, client, 0, 255, 0)
	triggerClientEvent(player, "groupSystem.addInviteToList", player, group, getPlayerName(client), time) 
end
addEvent("groupSystem.makeInvite", true)
addEventHandler("groupSystem.makeInvite", root, makeInvite)
----------------------------------------------------------------------------------------------------//Convidar Membro
function accepInvite(group)
	if (not groupTable[group]) then
		outputChatBox(tostring(group).." does no longer exist!", client, 255, 0, 0)
		return
	end
	setGroup(client, group, _, "Membro")
	outputGroupMessage(getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." has joined the encampment!", group)
end
addEvent("groupSystem.accepInvite", true)
addEventHandler("groupSystem.accepInvite", root, accepInvite)

function getGroupList()
	local count = {}
	for ind, data in pairs(groupTable) do
		for ind2, data2 in pairs(GAC) do
			if (data2[1] == ind) then
				if (not count[ind]) then count[ind] = 0 end
				count[ind] = count[ind] + 1
			end
		end
	end
	triggerClientEvent(client, "groupSystem.addGroupList", client, groupTable, count)
end
addEvent("groupSystem.getGroupList", true)
addEventHandler("groupSystem.getGroupList", root, getGroupList)


function groupChat(message, messageType)
	cancelEvent()
    if (messageType == 2) then
		local group = getPlayerGroup(source)
		if not (group) then return end
		--outputGroupMessage(getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','')..": "..message, group)
		outputChatBox("#00FF00[CHAT GRUPO]#FFFFFF "..getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').."#00FF00 : "..message:gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x',''),source,255,255,255,true)
	end	
end
addEventHandler( "onPlayerChat", getRootElement(), groupChat )
----------------------------------------------------------------------------------------------------//Can add/edit/remove ranks
function showRanks()
	if (not checkGroupAccess(client, 1)) then return end
	local group = getPlayerGroup(client)
	triggerClientEvent(client, "groupSystem.doneWithRanks", client, rankCache[group] or {})
end
addEvent("groupSystem.showRanks", true)
addEventHandler("groupSystem.showRanks", root, showRanks)

function addTheRank(name, selected)
	if (not checkGroupAccess(client, 1)) then return end
	local group = getElementData(client, "Group")
	if (not group) then return end
	local permissions = {false, false, false, false, false, false, false, false, false, false, false, false, false, false}
	addRank(group, name, toJSON(permissions))
	outputChatBox("Added the rank "..name.." successfully", client, 0, 255, 0)
	triggerClientEvent(client, "groupSystem.doneWithRanks", client, rankCache[group] or {}, name)
end
addEvent("groupSystem.addTheRank", true)
addEventHandler("groupSystem.addTheRank", root, addTheRank)

function editRank(name, newPerm)
	if (not checkGroupAccess(client, 1)) then return end
	local group = getPlayerGroup(client)
	if (isRank(group, name)) then
		removeRank(group, name)
	else
		return
	end
	addRank(group, name, toJSON(newPerm))
	outputChatBox("Edited permissions for rank '"..name.."'", client, 0, 255, 0)
	groupLog(group, getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." edited permissions for rank '"..name.."'")
end
addEvent("groupSystem.editRank", true)
addEventHandler("groupSystem.editRank", root, editRank)

function deleteRank(rank)
	if (not checkGroupAccess(client, 1)) then return end
	local group = getPlayerGroup(client)
	if (getGroupRankCount(group) == 1) then
		outputChatBox("Cannot delete the only rank you have", client, 255, 0, 0)
		return
	end
	if (isRank(group, rank)) then
		removeRank(group, rank)
	else
		return
	end
	outputGroupMessage(getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." deleted the rank: "..rank)
	groupLog(group, getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." deleted the rank: "..rank)
	triggerClientEvent(client, "groupSystem.doneWithRanks", client, rankCache[group] or {})
end
addEvent("groupSystem.deleteRank", true)
addEventHandler("groupSystem.deleteRank", root, deleteRank)

function setTheRank(rank, account)
	if (not account or not getAccount(account)) then
		outputChatBox("No account was selected from the list", client, 255, 0, 0)
		return
	end
	local group = getPlayerGroup(client)
	local mine = getPermissionCount(group, getPlayerGroupRank(client))
	local his = getPermissionCount(group, rank)
	if (not rankCache[group] or rankCache[group] and not rankCache[group][rank]) then
		outputChatBox("This rank ("..tostring(rank)..") was not found in your group", client, 255, 0, 0)
		return
	end
	local online = getAccountPlayer(getAccount(account))
	if (not checkGroupAccess(client, 1)) then outputChatBox("Insufficient permission!",client,255,0,0,true) return end
	if (tonumber(his) > tonumber(mine)) then
		outputChatBox("You cannot set the rank of this account because it has more permissions attributes than you!", client, 255, 0, 0)
		return
	end
	if (not GAC[account]) then outputChatBox("No GAC[GetAccount]!",client,255,0,0,true) return end
	if (GAC[account][1] ~= group) then outputChatBox("No GAC[GetAccount][1] ~= group!",client,255,0,0,true) return end
	if (GAC[account][2] == rank) then
		outputChatBox("This account already has the rank "..rank, client, 255, 0, 0)
		return
	end
	if (online) then
		outputGroupMessage(getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." has set "..getPlayerName(online):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').."'s rank to: "..rank, group)
	else
		outputGroupMessage(getPlayerName(client):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." has set account: "..account.."'s rank to: "..rank, group)
	end
	dbExec(db, "UPDATE groupmember SET rank=? WHERE account=?", tostring(rank), tostring(account))
	outputChatBox("You have set the rank of account "..account.." to "..rank, client, 0, 255, 0)
	GAC[account][2] = rank
end
addEvent("groupSystem.setTheRank", true)
addEventHandler("groupSystem.setTheRank", root, setTheRank)
----------------------------------------------------------------------------------------------------//Can add/edit/remove ranks
----------------------------------------------------------------------------------------------------//Permissao para dar cargo
function getMyRanks()
	if (checkGroupAccess(client, 4)) then
		local group = getPlayerGroup(client)
		triggerClientEvent(client, "groupSystem.printTheRanks", client, rankCache[group] or {})
	end
end
addEvent("groupSystem.getMyRanks", true)
addEventHandler("groupSystem.getMyRanks", root, getMyRanks)
----------------------------------------------------------------------------------------------------//Permissao para dar cargo

function changeGroupColor(plr, cmd, r, g, b)
	local r, g, b = r or 255, g or 255, b or 255
	local group = getPlayerGroup(plr)
	if (not group) then return end
	if (not checkGroupAccess(plr, 12)) then return end
	if (not groupTable[group]) then return end
	local color = {r, g, b}
	dbExec(db, "UPDATE groups SET chatcolor=? WHERE name=?", toJSON(color), group)
	groupTable[group][3] = toJSON(color)
	outputGroupMessage(getPlayerName(plr).." has changed the group chat R: "..r.." G: "..g.." B: "..b, group)
	outputChatBox("Group colour changed to R: "..r.." G: "..g.." B: "..b, r, g, b, "default-bold", plr, true, 0.15)
	groupLog(group, getPlayerName(plr).." has set chat color to: "..r..", "..g..", "..b)
end

function changeTurfColor(plr, cmd, r, g, b)
	local r, g, b = r or 255, g or 255, b or 255
	local group = getPlayerGroup(plr)
	if (not group) then return end
	if (not checkGroupAccess(plr, 12)) then return end
	if (not groupTable[group]) then return end
	local color = {r, g, b}
	dbExec(db, "UPDATE groups SET turfcolor=? WHERE name=?", toJSON(color), group)
	groupTable[group][6] = toJSON(color)
	outputChatBox("Turf colour changed to R: "..r.." G: "..g.." B: "..b, plr, r, g, b, "default-bold", true, 0.15)
	groupLog(group, getPlayerName(plr).." has set turf color to: "..r..", "..g..", "..b)
end
	
function setCorrectElementData()
	for ind, plr in pairs(getElementsByType("player")) do
		if (not GAC[GetAccount(plr)]) then
			setElementData(plr, "Group", false)
		end
	end
end
setTimer(setCorrectElementData, 2500, 0)

function onPlayerOpenVault()
	outputChatBox("Success",root,255,0,0)
end
addEvent("onPlayerOpenVault",true)
addEventHandler("onPlayerOpenVault",root,onPlayerOpenVault)

Look at the complete code

Link to comment

Then you should try to fix it yourself, we won't really help you if you don't try fixing it yourself. If you are stuck after you tried it multiple times, and you don't know why it's not working, we'll help ya as we can.

On 4/13/2017 at 19:48, Dutchman101 said:

The Scripting section is not meant for those unwilling to learn, whose only intent is to try get others to finish the scripts they need, line by line. We see this happening way too often -  someone with seemingly zero scripting skills does not react on-topic to the set of functions they can use that other users provide them, and does not seem to take any pushes in the right direction forward; they are just waiting for a collective effort from other scripters to develop what they want. This is what we do not want to see. 

 

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...