Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------
- -- COMMUNITY CONTRIBUTION FOR CIT2.NET
- -- PURPOSE: GAM review - Ability to review
- -- DEVELOPERS: Ryan (acc:hassam)
- ------------------------------------------------------------------------------------
- local groupInfo, plrSelected = {}, {}
- local groupName
- function createGAMGui()
- local sx, sh = guiGetScreenSize()
- gamWindow = guiCreateWindow((sx / 2) - (689 / 2), (sh / 2) - (306 / 2), 689, 306, "Group Review", false)
- guiWindowSetSizable(gamWindow, false)
- guiSetAlpha(gamWindow, 1.00)
- guiSetVisible(gamWindow, false)
- groupTabPanel = guiCreateTabPanel(9, 21, 670, 275, false, gamWindow)
- -- Group Informations Tab
- groupInfoTab = guiCreateTab("Group Information", groupTabPanel)
- groupSearchEdit = guiCreateEdit(3, 5, 99, 26, "", false, groupInfoTab)
- confirmButton = guiCreateButton(108, 4, 77, 27, "Confirm", false, groupInfoTab)
- groupInfoMemo = guiCreateMemo(5, 41, 180, 199, "Information: \nAmount Members: \nGroup Level:\nAmount players logged in last 2 months:\nLast Review:\nReviewed by: \nLeaders Name:\n", false, groupInfoTab)
- guiMemoSetReadOnly(groupInfoMemo, true)
- gMemberList = guiCreateGridList(200, 41, 456, 199, false, groupInfoTab)
- guiGridListAddColumn(gMemberList, "Name", 0.3)
- guiGridListAddColumn(gMemberList, "Account Name", 0.3)
- guiGridListAddColumn(gMemberList, "Rank", 0.3)
- guiGridListAddColumn(gMemberList, "WL", 0.05)
- getInfoButton = guiCreateButton(543, 4, 113, 27, "Get Informations", false, groupInfoTab)
- searchPlrOrRankEdit = guiCreateEdit(200, 5, 157, 26, "", false, groupInfoTab)
- selectPlrsRankButton = guiCreateButton(367, 4, 166, 27, "Select Players with same rank", false, groupInfoTab)
- --Copy Informations Tab (Without BBCodes)
- reviewTab = guiCreateTab("Reviewed", groupTabPanel)
- groupRevLabel = guiCreateLabel(10, 10, 238, 26, "Group Informations", false, reviewTab)
- guiLabelSetHorizontalAlign(groupRevLabel, "center", false)
- guiLabelSetVerticalAlign(groupRevLabel, "center")
- groupRevCopyMemo = guiCreateMemo(10, 42, 238, 199, "", false, reviewTab)
- guiMemoSetReadOnly(groupRevCopyMemo, true)
- leaderRevLabel = guiCreateLabel(276, 10, 238, 26, "Leaders Informations", false, reviewTab)
- guiLabelSetHorizontalAlign(leaderRevLabel, "center", false)
- guiLabelSetVerticalAlign(leaderRevLabel, "center")
- leaderRevCopyMemo = guiCreateMemo(276, 42, 238, 199, "", false, reviewTab)
- guiMemoSetReadOnly(leaderRevCopyMemo, true)
- --Copy Informations Tab (With BBCodes)
- infoTab = guiCreateTab("Reviewed + BBCodes ready", groupTabPanel)
- groupInfoLabel = guiCreateLabel(10, 10, 238, 26, "Group Informations", false, infoTab)
- guiLabelSetHorizontalAlign(groupInfoLabel, "center", false)
- guiLabelSetVerticalAlign(groupInfoLabel, "center")
- groupInfoCopyMemo = guiCreateMemo(10, 42, 238, 199, "", false, infoTab)
- guiMemoSetReadOnly(groupInfoCopyMemo, true)
- leaderInfoLabel = guiCreateLabel(276, 10, 238, 26, "Leaders Informations", false, infoTab)
- guiLabelSetHorizontalAlign(leaderInfoLabel, "center", false)
- guiLabelSetVerticalAlign(leaderInfoLabel, "center")
- leaderInfoCopyMemo = guiCreateMemo(276, 42, 238, 199, "", false, infoTab)
- guiMemoSetReadOnly(leaderInfoCopyMemo, true)
- copyGInfoButton = guiCreateButton(543, 134, 117, 29, "Copy Group Informations", false, infoTab)
- copyLInfoButton = guiCreateButton(543, 173, 117, 29, "Copy Leader Informations", false, infoTab)
- reviewedButton = guiCreateButton(543, 212, 117, 29, "Reviewed", false, infoTab)
- --Close Tab
- closeTab = guiCreateTab("Close", groupTabPanel)
- --Event handlers
- addEventHandler("onClientGUIClick", confirmButton, onGetCorrectGroup, false)
- addEventHandler("onClientGUIClick", getInfoButton, enabledInformations, false)
- addEventHandler("onClientGUIChanged", searchPlrOrRankEdit, searchPlrOrRank, false)
- addEventHandler("onClientGUIClick", selectPlrsRankButton, addLeadRankList, false)
- addEventHandler("onClientGUIDoubleClick", gMemberList, addLeader, false)
- --
- addEventHandler("onClientGUIClick", copyGInfoButton, copyInfos, false)
- addEventHandler("onClientGUIClick", copyLInfoButton, copyInfos, false)
- addEventHandler("onClientGUIClick", reviewedButton, reviewedGroup, false)
- --
- addEventHandler("onClientGUITabSwitched", closeTab, toggleMainGUI, false)
- end
- function toggleMainGUI()
- if (not gamWindow) then
- createGAMGui()
- end
- local state = not guiGetVisible(gamWindow)
- guiSetVisible(gamWindow, state)
- showCursor(state)
- if (not state) then
- return false
- end
- cleaningInfo()
- end
- addEvent("CITgamReview.showPanel", true)
- addEventHandler("CITgamReview.showPanel", root, toggleMainGUI)
- function onGetCorrectGroup()
- if (not guiGetText(groupSearchEdit) or guiGetText(groupSearchEdit) == "") then
- return false
- end
- groupName = guiGetText(groupSearchEdit)
- triggerServerEvent("CITgamReview.checkExistedGroup", resourceRoot, groupName)
- end
- function groupCorrectEnabled(groupT)
- if (not groupT) then
- return false
- end
- guiSetEnabled(selectPlrsRankButton, true)
- guiEditSetReadOnly(groupSearchEdit, true)
- guiEditSetReadOnly(searchPlrOrRankEdit, false)
- guiSetEnabled(getInfoButton, true)
- guiSetEnabled(confirmButton, false)
- groupInfo = groupT
- refreshGroupList()
- guiSetText(groupInfoMemo, "Information: Group Exist\nAmount Members: "..groupInfo["info"][1].."\nGroup Level: "..groupInfo["info"][2].."\nAmount players logged in last 2 months: "..groupInfo["info"][3].."\nLast Review: "..groupInfo["info"][4].."\nReviewed by: "..groupInfo["info"][5].."\nLeaders Name:")
- end
- addEvent("CITgamReview.groupCorrectEnabled", true)
- addEventHandler("CITgamReview.groupCorrectEnabled", root, groupCorrectEnabled)
- function enabledInformations()
- if (next(plrSelected) == nil) then
- outputChatBox("You didn't select any leader!", 255, 0, 0)
- return false
- end
- guiSetText(leaderInfoCopyMemo, "[size=18pt][color=green]Activity in-game[/color][/size]\n[b]Leaders Activity -[/b] [i]Provide number of logins/hours of their leaders for the last 2 months[/i][list]")
- for i, v in pairs(groupInfo["review"]) do
- if (plrSelected[v[1]]) then
- local totalHits = v[3][1][2] + v[3][2][2] + v[3][3][2]
- local totalPlay = math.ceil(((v[3][1][1] + v[3][2][1] + v[3][3][1])/24), 2)
- guiSetText(leaderInfoCopyMemo, guiGetText(leaderInfoCopyMemo).."\n[list][li]Leader Name (Acc: "..v[1].."): "..v[2].."\n[list]\n[li][i]LOGIN hits:[/i] "..totalHits.."\n[list]\n[li]First month: "..v[3][3][2].."[/li]\n[li]Second month: "..v[3][2][2].."[/li]\n[li]Third month (Currently): "..v[3][1][2].."[/li]\n[/list][/li]\n[li][i]Playtime played:[/i] "..totalPlay.."\n[list]\n[li]First month: "..math.ceil((v[3][3][1]/24), 2).."[/li]\n[li]Second month :"..math.ceil((v[3][2][1]/24), 2).."[/li]\n[li]Third month (Currently): "..math.ceil((v[3][1][1]/24), 2).."[/li]\n[/list][/li]\n[li][i]Hours and LOGIN hits comparison:[/i] "..math.ceil((totalPlay/totalHits), 3).."\n[list]\n[li]First month: "..math.ceil(((v[3][3][1]/24)/v[3][3][2]), 3) or (0).."[/li]\n[li]Second month :"..math.ceil(((v[3][2][1]/24)/v[3][2][2]), 3) or (0).."[/li]\n[li]Third month (Currently): "..math.ceil(((v[3][1][1]/24)/v[3][1][2]), 3) or (0).."[/li]\n[/list][/li]\n[/list][/list]\n")
- guiSetText(leaderRevCopyMemo, "Leader Name (Acc: "..v[1].."): "..v[2].."\nLOGIN hits: "..totalHits.."\nFirst month: "..v[3][3][2].."\nSecond month: "..v[3][2][2].."\nThird month (Currently): "..v[3][1][2].."\nPlaytime played: "..totalPlay.."\nFirst month: "..math.ceil((v[3][3][1]/24), 2).."\nSecond month :"..math.ceil((v[3][2][1]/24), 2).."\nThird month (Currently): "..math.ceil((v[3][1][1]/24), 2).."\nHours and LOGIN hits comparison:[/i] "..math.ceil((totalPlay/totalHits), 3).."\nFirst month: "..math.ceil(((v[3][3][1]/24)/v[3][3][2]), 3) or (0).."\nSecond month :"..math.ceil(((v[3][2][1]/24)/v[3][2][2]), 3) or (0).."\nThird month (Currently): "..math.ceil(((v[3][1][1]/24)/v[3][1][2]), 3) or (0))
- end
- end
- guiSetText(leaderInfoCopyMemo, guiGetText(leaderInfoCopyMemo).."\n[/list]")
- guiSetText(groupInfoCopyMemo, "[size=24pt][color=purple][b]"..groupName.."'s Auto-Review[/b][/color][/size]\n\n[b]Amount Members: [/b]"..groupInfo["info"][1].."\n[b]Group Level:[/b] "..groupInfo["info"][2].."\n[b]Amount players logged in last 2 months:[/b] "..groupInfo["info"][3].."\n[b]Last Review:[/b] "..groupInfo["info"][4].."\n[b]Reviewed by:[/b] "..groupInfo["info"][5])
- guiSetText(groupRevCopyMemo, "Amount Members: "..groupInfo["info"][1].."\nGroup Level: "..groupInfo["info"][2].."\nAmount players logged in last 2 months: "..groupInfo["info"][3].."\nLast Review: "..groupInfo["info"][4].."\nReviewed by: "..groupInfo["info"][5])
- guiSetEnabled(infoTab, true)
- guiSetEnabled(groupInfoTab, false)
- guiSetEnabled(reviewTab, true)
- guiSetSelectedTab(groupTabPanel, reviewTab)
- guiSetEnabled(reviewedButton, false)
- end
- function searchPlrOrRank()
- local text = string.lower(guiGetText(searchPlrOrRankEdit))
- if (text == "") then
- refreshGroupList()
- return false
- end
- local rankTable = {}
- for i, v in pairs(groupInfo["members"]) do
- local looping
- if (string.find(text, "%rank:")) then
- looping = string.lower("rank:"..v[3])
- else
- looping = string.lower(v[2])
- end
- if (string.find(looping, text)) then
- table.insert(rankTable, {v[1], v[2], v[3], v[4], v[5]})
- end
- end
- guiGridListClear(gMemberList)
- for i, v in pairs(rankTable) do
- local row = guiGridListAddRow(gMemberList)
- guiGridListSetItemText(gMemberList, row, 1, v[1], false, false)
- guiGridListSetItemText(gMemberList, row, 2, v[2], false, false)
- guiGridListSetItemText(gMemberList, row, 3, v[3], false, false)
- guiGridListSetItemText(gMemberList, row, 4, v[4], false, false)
- end
- end
- function addLeadRankList()
- local text = string.lower(guiGetText(searchPlrOrRankEdit))
- local count = 0
- for i, v in pairs(groupInfo["members"]) do
- if (string.find(text, "%rank:")) then
- local looping = string.lower("rank:"..v[3])
- if (string.find(looping, text)) then
- count = count + 1
- end
- end
- end
- if (count ~= 1) then
- outputChatBox("You should have just 1 rank selected or forgot use 'rank:'!", 255, 0, 0)
- return false
- end
- for i = 0, guiGridListGetRowCount(gMemberList) - 1 do
- local acc = guiGridListGetItemText(gMemberList, i, 2)
- if (not plrSelected[acc]) then
- plrSelected[acc] = true
- end
- end
- refreshLeaderList()
- end
- function addLeader()
- local r, c = guiGridListGetSelectedItem(gMemberList)
- if (r < 0) then
- return false
- end
- local name = guiGridListGetItemText(gMemberList, r, 1)
- local acc = guiGridListGetItemText(gMemberList, r, 2)
- plrSelected[acc] = not plrSelected[acc]
- refreshLeaderList()
- end
- function copyInfos()
- if (source == copyGInfoButton) then
- setClipboard(guiGetText(groupInfoCopyMemo))
- return true
- end
- setClipboard(guiGetText(leaderInfoCopyMemo))
- guiSetEnabled(reviewedButton, true)
- end
- function reviewedGroup()
- triggerServerEvent("CITgamReview.reviewedGroup", resourceRoot, groupName)
- cleaningInfo()
- end
- function cleaningInfo()
- guiSetEnabled(groupInfoTab, true)
- guiSetSelectedTab(groupTabPanel, groupInfoTab)
- guiSetEnabled(selectPlrsRankButton, false)
- guiSetEnabled(infoTab, false)
- guiSetEnabled(reviewTab, false)
- guiEditSetReadOnly(searchPlrOrRankEdit, true)
- guiEditSetReadOnly(groupSearchEdit, false)
- guiSetEnabled(confirmButton, true)
- guiSetEnabled(getInfoButton, false)
- guiGridListClear(gMemberList)
- guiSetText(groupSearchEdit, "")
- guiSetText(searchPlrOrRankEdit, "")
- groupInfo = {}
- plrSelected = {}
- guiSetText(groupInfoMemo, "")
- end
- --Refresh Time
- function refreshGroupList()
- if (not groupInfo["members"]) then
- return false
- end
- guiGridListClear(gMemberList)
- for i, val in pairs(groupInfo["members"]) do
- local row = guiGridListAddRow(gMemberList)
- guiGridListSetItemText(gMemberList, row, 1, val[1], false, false)
- guiGridListSetItemText(gMemberList, row, 2, val[2], false, false)
- guiGridListSetItemText(gMemberList, row, 3, val[3], false, false)
- guiGridListSetItemText(gMemberList, row, 4, val[4], false, false)
- end
- end
- function refreshLeaderList()
- guiSetText(groupInfoMemo, "Information: Group Exist\nAmount Members: "..groupInfo["info"][1].."\nGroup Level: "..groupInfo["info"][2].."\nAmount players logged in last 2 months: "..groupInfo["info"][3].."\nLast Review: "..groupInfo["info"][4].."\nReviewed by: "..groupInfo["info"][5].."\nLeaders Name:")
- if (next(plrSelected) == nil or not groupInfo["members"]) then
- return false
- end
- for i, val in pairs(groupInfo["members"]) do
- if (plrSelected[val[2]]) then
- guiSetText(groupInfoMemo, (guiGetText(groupInfoMemo).."\n"..val[1]))
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment