Skip to content

Instantly share code, notes, and snippets.

@PatrickBoy
Created May 1, 2017 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickBoy/25a422888b6678255aa5d7a2a9796212 to your computer and use it in GitHub Desktop.
Save PatrickBoy/25a422888b6678255aa5d7a2a9796212 to your computer and use it in GitHub Desktop.
Clan = {
Button = {},
Window = {},
Gridlist = {},
Edit = {}
}
Clan.Window[1] = guiCreateWindow(306, 174, 320, 346, "Clan panel", false)
guiWindowSetSizable(Clan.Window[1], false)
Clan.Window[2] = guiCreateWindow(401, 281, 252, 99, "Set Player Rank", false)
guiWindowSetSizable(Clan.Window[2], false)
Clan.Window[3] = guiCreateWindow(401, 281, 252, 99, "Set Player Rank", false)
guiWindowSetSizable(Clan.Window[3], false)
Clan.Gridlist[1] = guiCreateGridList(9, 25, 188, 311, false, Clan.Window[1])
local column = guiGridListAddColumn(Clan.Gridlist[1], "Players", 0.9)
if ( column ) then --If the column has been created, fill it with players
for _,v in ipairs(getElementsByType("player"))do
local row = guiGridListAddRow(Clan.Gridlist[1])
local players = getPlayerName(v)
guiGridListSetItemText(Clan.Gridlist[1],row,column,players,false,false)
end
end
Clan.Button[1] = guiCreateButton(204, 51, 106, 38, "Add", false, Clan.Window[1])
Clan.Button[2] = guiCreateButton(204, 96, 106, 38, "Kick", false, Clan.Window[1])
Clan.Button[3] = guiCreateButton(204, 144, 106, 38, "Promote", false, Clan.Window[1])
Clan.Button[4] = guiCreateButton(204, 192, 106, 38, "Demote", false, Clan.Window[1])
Clan.Button[5] = guiCreateButton(204, 288, 106, 38, "Close", false, Clan.Window[1])
Clan.Button[6] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[2])
Clan.Button[7] = guiCreateButton(143, 62, 87, 23, "Set", false, Clan.Window[2])
Clan.Button[8] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[3])
Clan.Button[9] = guiCreateButton(143, 62, 87, 23, "Set", false, Clan.Window[3])
Clan.Edit[1] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[2])
Clan.Edit[2] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[3])
guiSetVisible(Clan.Window[1], false)
guiSetVisible(Clan.Window[2], false)
guiSetVisible(Clan.Window[3], false)
showCursor(false)
if getElementData(localPlayer, "clan.rank") == "leader" or getElementData(localPlayer, "player.key") == "Snowwhite" or getElementData(localPlayer, "player.key") == "danksta" or getElementData(localPlayer, "player.key") == "[ET]Snowwhite" or getElementData(localPlayer, "player.key") == "[ET]Danksta" or getElementData(localPlayer, "player.key") == "Danksta" then
guiSetEnabled(Clan.Button[3], true)
guiSetEnabled(Clan.Button[4], true)
else
guiSetEnabled(Clan.Button[3], false)
guiSetEnabled(Clan.Button[4], false)
end
function toggleClanControl( source )
if getElementData(localPlayer, "player.key") == "Snowwhite" or getElementData(localPlayer, "player.key") == "[ET]Snowwhite" or getElementData(localPlayer, "player.key") == "danksta" or getElementData(localPlayer, "player.key") == "[ET]Danksta" or getElementData(localPlayer, "player.key") == "Danksta" then
if not guiGetVisible( Clan.Window[1] ) then
showCursor ( true )
guiSetVisible( Clan.Window[1], true )
guiGridListClear ( Clan.Gridlist[1] )
if ( column ) then
guiGridListClear ( Clan.Gridlist[1] )
for _,v in ipairs(getElementsByType("player"))do
local row = guiGridListAddRow(Clan.Gridlist[1])
local playerName = getPlayerName(v)
guiGridListSetItemText(Clan.Gridlist[1],row,column,playerName,false,false)
end
end
if getElementData(localPlayer, "clan.rank") == "leader" or getElementData(localPlayer, "player.key") == "Snowwhite" or getElementData(localPlayer, "player.key") == "danksta" or getElementData(localPlayer, "player.key") == "[ET]Snowwhite" or getElementData(localPlayer, "player.key") == "Danksta" or getElementData(localPlayer, "player.key") == "[ET]Danksta" then
guiSetEnabled(Clan.Button[3], true)
guiSetEnabled(Clan.Button[4], true)
else
guiSetEnabled(Clan.Button[3], false)
guiSetEnabled(Clan.Button[4], false)
end
else
showCursor ( false )
guiSetVisible( Clan.Window[1], false )
end
end
end
bindKey( "H", "down", toggleClanControl )
addCommandHandler("clan", toggleClanControl)
addEventHandler("onClientGUIClick", guiRoot,
function()
if source == Clan.Button[1] then
local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
if row == -1 then return end
local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
local player = getPlayerFromName(playerName)
local team = getPlayerTeam(localPlayer)
local teamName = getTeamName(team)
if not playerName then
guiGridListRemoveRow(row)
return
end
triggerServerEvent("addToTeam", localPlayer,playerName,teamName)
end
end)
addEventHandler("onClientGUIClick", guiRoot,
function()
if source == Clan.Button[2] then
local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
if row == -1 then return end
local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
local player = getPlayerFromName(playerName)
local team = getPlayerTeam(localPlayer)
local teamName = getTeamName(team)
if not playerName then
guiGridListRemoveRow(row)
return
end
triggerServerEvent("kickFromTeam", localPlayer,playerName,teamName)
end
end)
function closeClan()
if guiGetVisible(Clan.Window[1]) then
guiSetVisible(Clan.Window[1],false)
showCursor(false)
end
end
addEventHandler ("onClientGUIClick", Clan.Button[5], closeClan, false)
function togglePromote( source )
-- Show the panel
if not guiGetVisible( Clan.Window[2] ) then
showCursor ( true )
guiSetVisible( Clan.Window[2], true )
guiMoveToBack( Clan.Window[1] )
else
showCursor ( true )
guiSetVisible( Clan.Window[2], false )
end
end
addEventHandler ( "onClientGUIClick", Clan.Button[3], togglePromote, false )
addEventHandler("onClientGUIClick",Clan.Button[7],
function()
local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
if row == -1 then return end
local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
local player = getPlayerFromName(playerName)
if not playerName then
guiGridListRemoveRow(row)
return
end
triggerServerEvent("promotePlayer",localPlayer,playerName,tostring(guiGetText(Clan.Edit[1])) or "Member")
guiSetVisible( Clan.Window[2], false )
showCursor ( true )
end,false)
function closeClan()
if guiGetVisible(Clan.Window[2]) then
guiSetVisible(Clan.Window[2],false)
showCursor(true)
end
end
addEventHandler ("onClientGUIClick", Clan.Button[6], closeClan, false)
function toggleDemote( source )
-- Show the panel
if not guiGetVisible( Clan.Window[2] ) then
showCursor ( true )
guiSetVisible( Clan.Window[2], true )
guiMoveToBack( Clan.Window[1] )
else
showCursor ( true )
guiSetVisible( Clan.Window[2], false )
end
end
addEventHandler ( "onClientGUIClick", Clan.Button[4], toggleDemote, false )
addEventHandler("onClientGUIClick",Clan.Button[9],
function()
local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
if row == -1 then return end
local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
local player = getPlayerFromName(playerName)
if not playerName then
guiGridListRemoveRow(row)
return
end
triggerServerEvent("DemotePlayer",localPlayer,playerName,tostring(guiGetText(Clan.Edit[2])) or "Member")
guiSetVisible( Clan.Window[3], false )
showCursor ( true )
end,false)
function closeClan()
if guiGetVisible(Clan.Window[3]) then
guiSetVisible(Clan.Window[3],false)
showCursor(true)
end
end
addEventHandler ("onClientGUIClick", Clan.Button[8], closeClan, false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment