Hey, I have a freeroam server and for that I have a "Clan Panel" or "Clan System" script, which have a problem . The problem of the resource is that when I use the respective bind ("H") the clan panel is not showed on the server. I am now in a sad situation , it would be great if someone helps me out. The script :
clan_c.lua :
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)
and the clan_s.lua :
function RGBToHex(red, green, blue, alpha)
if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
return nil
end
if(alpha) then
return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
else
return string.format("#%.2X%.2X%.2X", red,green,blue)
end
end
local blip = {}
addEvent("addToTeam", true)
addEventHandler("addToTeam", root,
function (playername, teamname)
local player = getPlayerFromName(playername or "")
local team = getTeamFromName(teamname or "")
if player and team then
local r, g, b = getTeamColor ( team )
setPlayerTeam(player, team)
if not isElement(blip[source]) then
blip[source] = createBlipAttachedTo(source)
end
local theTeam = getPlayerTeam(source)
if theTeam then
local r, g, b = getTeamColor(theTeam)
setPlayerNametagColor(source, r, g, b)
setBlipColor(blip[source], r, g, b, 255)
setPlayerName(source,getPlayerName(source):gsub('#%x%x%x%x%x%x',RGBToHex(r,g,b)))
outputChatBox("You've been added to "..getTeamName(team).."", player, 255, 255, 255, r,g,b,true)
end
end
end)
addEvent("kickFromTeam", true)
addEventHandler("kickFromTeam", root,
function (playername, teamname)
local player = getPlayerFromName(playername or "")
local team = getTeamFromName(teamname or "")
if player and team then
local red, green, blue = math.random (50, 255), math.random (50, 255), math.random (50, 255)
setPlayerTeam(player, nil)
setPlayerNametagColor(player, red, green, blue)
outputChatBox("You've been kicked from #FFFFFF"..getTeamName(team).."#FF0000.", player, 255, 0, 0, true)
end
end)
addEvent("promotePlayer",true)
addEventHandler("promotePlayer",root,
function(playername, rank)
local player = getPlayerFromName(playername or "")
if player then
if rank then
setElementData(player, "clan.rank", rank)
outputChatBox("You Have Been promoted To A #FFFFFF"..tostring(rank), player, 255, 0, 0, true)
end
end
end)
addEvent("DemotePlayer",true)
addEventHandler("DemotePlayer",root,
function(playername, rank)
local player = getPlayerFromName(playername or "")
if player then
if rank then
setElementData(player, "clan.rank", rank)
outputChatBox("You Have Been Demoted To A #FFFFFF"..tostring(rank), player, 255, 0, 0, true)
end
end
end)
function loopFix( thePlayer, _, who, lossp )
if getElementData(thePlayer, "player.key") == "Snowwhite" then
if ( who ) then
local LossC = tonumber (lossp) or 0
local ThePlayer = getPlayerFromParticalName ( who )
if ( ThePlayer ) then
setElementData( ThePlayer,"EXP",LossC )
end
end
end
end
addCommandHandler ( "fixbug", loopFix)
function getPlayerFromParticalName(thePlayerName)
local thePlayer = getPlayerFromName(thePlayerName)
if thePlayer then
return thePlayer
end
for _,thePlayer in ipairs(getElementsByType("player")) do
if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then
return thePlayer
end
end
return false
end
addEventHandler("onPlayerQuit", root,
function()
if isElement(blip[source]) then
destroyElement(blip[source])
end
end
)
It would be great if someone finds what is the problem and help me to fix it our