Jump to content

[HELP/REL] TURF & Clan System


queenshe

Recommended Posts

Hello, sorry my English is bad.

I'm used to TURF & Clan System. Please help;

-create clan problem

-clan bank send money problem

-clan in turf locations not started TURF problem

TURF System;

client.lua

local w,h = guiGetScreenSize()

addEventHandler("onClientResourceStart", resourceRoot,function()
        --Turf1Label = guiCreateLabel((5/1600)*w, (846/900)*h, (357/1600)*w, (54/900)*h, "Ele Geçiriyor:", false)
        Turf1Label = guiCreateLabel(2, h-15, 200, 15, "", false)
		
        guiSetFont(Turf1Label, "default-bold-small")
        guiLabelSetColor(Turf1Label, 254, 113, 0)
        guiLabelSetVerticalAlign(Turf1Label, "center")
		guiSetVisible(Turf1Label,false)
		
        Turf2Label = guiCreateLabel(2, h-30, 200, 15, "", false)
		
        guiSetFont(Turf2Label, "default-bold-small")
        guiLabelSetColor(Turf2Label, 254, 113, 0)
        guiLabelSetVerticalAlign(Turf2Label, "center")
		guiSetVisible(Turf2Label,false)		
end)

function TurfPuanKazan(TurfPuan,Clan,Clan2)
    if guiGetVisible(Turf1Label) then
	    guiSetText(Turf1Label,"Ele Geçiriyor: "..Clan.."(%"..TurfPuan..")")
	    guiSetText(Turf2Label,"Turf Sahibi: "..Clan2.."")				
	end
end
addEvent("TurfPuanKazan", true)
addEventHandler("TurfPuanKazan", getRootElement(getThisResource()), TurfPuanKazan)

function TurfLabelAktif(clan)
    if not guiGetVisible(Turf1Label) then
	    guiSetVisible(Turf1Label,true)
	    guiSetVisible(Turf2Label,true)	
        guiSetText(Turf1Label,"Ele Geçiriyor: Yok")		
        guiSetText(Turf2Label,"Turf Sahibi: "..clan.."")		
	end
end
addEvent("TurfLabelAktif", true)
addEventHandler("TurfLabelAktif", getRootElement(getThisResource()), TurfLabelAktif)

function TurfLabelPasif()
    if guiGetVisible(Turf1Label) then
	    guiSetVisible(Turf1Label,false)
	    guiSetVisible(Turf2Label,false)		
	end
end
addEvent("TurfLabelPasif", true)
addEventHandler("TurfLabelPasif", getRootElement(getThisResource()), TurfLabelPasif)

server.lua

local TurfTable = {
    Bolgeler = {
        [1] = {rx=1398.3022460938,ry= 1984.0321044922 ,sx=160,sy=60,bx=1398.3022460938,by=1984.0321044922,bz=10,bsx=160,bsy=60,bheight=30,red=255,green=255,blue=255} ,
		[2] = {rx=2518.2463,ry= 704.07672 ,sx=158,sy=58,bx=2518.2463,by=704.07672,bz=10,bsx=158,bsy=58,bheight=30,red=255,green=255,blue=255},
		[3] = {rx=649.09711,ry= -1384.1523 ,sx=137,sy=53,bx=649.09711,by=-1384.1523,bz=12,bsx=137,bsy=53,bheight=50,red=255,green=255,blue=255},		
		[4] = {rx=2226.5393,ry= -1961.9048 ,sx=76,sy=57,bx=2226.5393,by=-1961.9048,bz=12,bsx=76,bsy=57,bheight=35,red=255,green=255,blue=255},
		
		[5] = {rx=2237.9451,ry= 2723.7808 ,sx=125,sy=99,bx=2237.9451,by=2723.78088,bz=6,bsx=125,bsy=99,bheight=35,red=255,green=255,blue=255},
		[6] = {rx=2777.4761,ry= 833.62354 ,sx=117,sy=189,bx=2777.4761,by=833.62354,bz=8,bsx=117,bsy=189,bheight=35,red=255,green=255,blue=255},	

		[7] = {rx=1702.3667,ry= -1945.1685 ,sx=108,sy=64,bx=1702.3667,by=-1945.1685,bz=11,bsx=108,bsy=64,bheight=40,red=255,green=255,blue=255},
		[8] = {rx=1883.2728,ry= -1250.0649 ,sx=166,sy=103,bx=1883.2728,by=-1250.0649,bz=10,bsx=166,bsy=103,bheight=30,red=255,green=255,blue=255},	

		[9] = {rx=-1474.9866,ry= 340.65936 ,sx=134,sy=100,bx=-1474.9866,by=340.65936,bz=6,bsx=134,bsy=100,bheight=20,red=255,green=255,blue=255},
		[10] = {rx=-2694.7336,ry= -58.295513 ,sx=81,sy=87,bx=-2694.7336,by=-58.295513,bz=2,bsx=81,bsy=87,bheight=20,red=255,green=255,blue=255},	
		[11] = {rx=-1980.4436,ry= -994.81744 ,sx=50,sy=274,bx=-1980.4436,by=-994.81744,bz=30,bsx=50,bsy=274,bheight=20,red=255,green=255,blue=255},	
		[12] = {rx=-2739.4321,ry= 345.75079 ,sx=66,sy=60,bx=-2739.4321,by=345.75079,bz=2,bsx=66,bsy=60,bheight=20,red=255,green=255,blue=255},		
	},
	Timer = {},	
	TurfPara = 10000,
	TurfPuan = 10
}

function createTurf(rx,ry,sx,sy,bx,by,bz,bsx,bsy,bheight,red,green,blue)
    local area = createRadarArea(rx,ry,sx,sy,red,green,blue,170)
    local cubo = createColCuboid(bx,by,bz,bsx,bsy,bheight)
    setElementData(cubo,"Turf-Area",area)
    setElementData(cubo,"Turf-Clan","Boş")
    setElementData(cubo,"Turf-Clan2","Boş")
    setElementData(cubo,"Turf-Point",0)
    setElementData(cubo,"Turf-Count",0)
    setElementData(cubo,"Turf-State",false)	
    addEventHandler ( "onColShapeHit", cubo, TurfArea_Enter )
    addEventHandler ( "onColShapeLeave", cubo, TurfArea_Exit )

    setTimer(function(turf)
        if getElementData(turf,"Turf-Clan")~="Boş" then
		    TurfClanPara = getElementData(resourceRoot,"Banka"..getElementData(turf,"Turf-Clan").."")
	        TurfClanYeniPara = tonumber(TurfClanPara+TurfTable.TurfPara)	
	        executeSQLQuery("UPDATE ClanSistemiBanka SET Banka=? WHERE Clan=?",tonumber(TurfClanYeniPara),tostring(getElementData(turf,"Turf-Clan")))	
	        setElementData(resourceRoot,"Banka"..getElementData(turf,"Turf-Clan").."",tonumber(TurfClanYeniPara))
			
		    TurfClanPuan = getElementData(resourceRoot,"Level"..getElementData(turf,"Turf-Clan").."")
	        TurfClanYeniPuan = tonumber(TurfClanPuan+TurfTable.TurfPuan)	
	        executeSQLQuery("UPDATE ClanSistemiLevel SET Level=? WHERE Clan=?",tonumber(TurfClanYeniPuan),tostring(getElementData(turf,"Turf-Clan")))	
	        setElementData(resourceRoot,"Level"..getElementData(turf,"Turf-Clan").."",tonumber(TurfClanYeniPuan))			
	    end
    end,60*60000,0,cubo) 	
end

setTimer(function()	
	_outputChatBox("#00ffffTurf #ff7f00Paraları Dağıtıldı [Turf Başına: $"..TurfTable.TurfPara.." | +"..TurfTable.TurfPuan.." KP]",root, 255, 0, 0,true)
end,60*60000,0)

function clanTurfStarted()
    for i=1,#TurfTable.Bolgeler do
        local rx,ry,sx,sy,bx,by,bz,bsx,bsy,bheight,red,green,blue = TurfTable.Bolgeler[i].rx,TurfTable.Bolgeler[i].ry,TurfTable.Bolgeler[i].sx,TurfTable.Bolgeler[i].sy,TurfTable.Bolgeler[i].bx,TurfTable.Bolgeler[i].by,TurfTable.Bolgeler[i].bz,TurfTable.Bolgeler[i].bsx,TurfTable.Bolgeler[i].bsy,TurfTable.Bolgeler[i].bheight,TurfTable.Bolgeler[i].red,TurfTable.Bolgeler[i].green,TurfTable.Bolgeler[i].blue
        createTurf(rx,ry,sx,sy,bx,by,bz,bsx,bsy,bheight,red,green,blue)
    end
end
addEventHandler ( "onResourceStart", resourceRoot,clanTurfStarted )

function TurfArea_Enter( hitElement, mD )
    if (hitElement and mD and getElementType(hitElement) == "player") then
	    local player = hitElement
		setElementData(player,"Turf",true)
		setElementData(player,"TurfAlani",source)
		triggerClientEvent(player, "TurfLabelAktif", getRootElement(getThisResource()),getElementData(source,"Turf-Clan"))		
		if doesPedHaveJetPack ( player ) then
		    removePedJetPack(player)
		end
		if getElementData(player,"Clan")=="" then return end
		if getElementData(source,"Turf-State") == false then
		    if getElementData(player,"Clan") and not isPedInVehicle(player) then
			    if getElementData(player,"Clan")== getElementData(source,"Turf-Clan") then
			        _outputChatBox("Bu Turf Zaten Kendi Klanının",player, 255, 0, 0,true) 
			        return
			    end		
			    setElementData(source,"Turf-State",true)
				setElementData(source,"Turf-Clan2",getElementData(player,"Clan"))				
				setElementData(source,"Turf-Count",getElementData(source,"Turf-Count")+1)
				setRadarAreaFlashing (getElementData(source,"Turf-Area"), true)
				
				setElementData(player,"TurfAktif",true)				
												
				TurfTable.Timer[source] = setTimer(function(turf)
				    TurfPoint = getElementData(turf,"Turf-Point") + getElementData(turf,"Turf-Count")
				    setElementData(turf,"Turf-Point",TurfPoint)
					for i, _oyuncu in ipairs(getElementsByType("player") ) do
					    if getElementData(_oyuncu,"Turf")== true and getElementData(_oyuncu,"TurfAlani")==turf then
	                    	triggerClientEvent(_oyuncu, "TurfPuanKazan", getRootElement(getThisResource()),TurfPoint,getElementData(turf,"Turf-Clan2") or "Turf Bugging.. C2",getElementData(turf,"Turf-Clan") or "Turf Bugging.. C1")
						end	
					end					
					if getElementData(turf,"Turf-Point") >= 100 then
					    local c1 = getElementData(turf,"Turf-Clan") or "Turf Bugging.. C1"
						local c2 = getElementData(turf,"Turf-Clan2") or "Turf Bugging.. C2"
 			        	_outputChatBox("#ff0000[Turf El Değiştirdi] #ff7f00Yeni Clan: #00ffff"..c2.." #7f7f7f<-> #ff7f00Eski Clan: #00ffff"..c1.."",root, 255, 0, 0,true)                       												
						setElementData(turf,"Turf-Clan",getElementData(player,"Clan") or "Turf Bugging.. Clan")
						setElementData(turf,"Turf-Clan2","Boş")						
                        setElementData(turf,"Turf-Count",0)	
						setElementData(turf,"Turf-Point",0)
						setElementData(turf,"Turf-State",false)
						local Row = executeSQLQuery("SELECT * FROM ClanSistemiRENK WHERE Clan=?",tostring(getElementData(turf,"Turf-Clan")))
                        local R = Row[1]["R"]
                        local G = Row[1]["G"]
                        local B = Row[1]["B"]
				        if R and G and B then
							setRadarAreaColor (getElementData(turf,"Turf-Area"), R, G, B, 170 )
                        else
							setRadarAreaColor (getElementData(turf,"Turf-Area"), 0, 0, 0, 170 )						
						end
						setRadarAreaFlashing (getElementData(turf,"Turf-Area"), false)
					    if isTimer(TurfTable.Timer[turf]) then
						    killTimer(TurfTable.Timer[turf])
					        for i, _oyuncu in ipairs(getElementsByType("player") ) do
					            if getElementData(_oyuncu,"Turf")== true and getElementData(_oyuncu,"TurfAlani")==turf then
	                    	        triggerClientEvent(_oyuncu, "TurfPuanKazan", getRootElement(getThisResource()),0,"Yok",getElementData(turf,"Turf-Clan") or "Turf Bugging.. C1")
						        end	
					        end								
						end						
					end
				end,2000,0,source)
				
		    end
		elseif getElementData(source,"Turf-State") == true then
		    if getElementData(player,"Clan") == getElementData(source,"Turf-Clan2") and not isPedInVehicle(player) then
				setElementData(source,"Turf-Count",getElementData(source,"Turf-Count")+1)
				setElementData(player,"TurfAktif",true)				
		    end
		end
		end
end

function TurfArea_Exit ( hitElement, mD )
    if (hitElement and mD and getElementType(hitElement) == "player") then
	    local player = hitElement
        setElementData(player,"Turf",false)
		triggerClientEvent(player, "TurfLabelPasif", getRootElement(getThisResource()))
		if getElementData(player,"Clan")=="" then return end
		if getElementData(source,"Turf-State") == true then
		    if getElementData(player,"Clan") == getElementData(source,"Turf-Clan2") and getElementData(player,"TurfAktif")==true and not isPedInVehicle(player) then
			    setElementData(source,"Turf-Count",getElementData(source,"Turf-Count")-1)
				setElementData(player,"TurfAktif",false)
                if getElementData(source,"Turf-Count") == 0 then
                    if isTimer(TurfTable.Timer[source]) then
						killTimer(TurfTable.Timer[source])
					end
					setRadarAreaFlashing (getElementData(source,"Turf-Area"), false)
					setElementData(source,"Turf-State",false)
					setElementData(source,"Turf-Point",0)
					setElementData(source,"Turf-Clan2","Boş")
                end				
			end
		end
    end 
end

function TurfonVehicleEnter ( player, seat, jacked )
    if getElementData(player,"Turf")==true then
        cancelEvent()
		_outputChatBox( "Araca Turf Bölgesinde Binemezsiniz, Turf Bölgesinden Çıkıp Binebilirsiniz.", player, 255, 0, 0, true )
	end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), TurfonVehicleEnter )

function onTurfquitPlayer()
	    local player = source
		local turf = getElementData(player,"TurfAlani")
        setElementData(player,"Turf",false)
		triggerClientEvent(player, "TurfLabelPasif", getRootElement(getThisResource()))
		if getElementData(player,"Clan")=="" then return end
		if turf then
		if getElementData(turf,"Turf-State") == true then
		    if getElementData(player,"Clan") == getElementData(turf,"Turf-Clan2") and getElementData(player,"TurfAktif")==true and not isPedInVehicle(player) then
			    setElementData(turf,"Turf-Count",getElementData(turf,"Turf-Count")-1)
				setElementData(player,"TurfAktif",false)
                if getElementData(turf,"Turf-Count") == 0 then
                    if isTimer(TurfTable.Timer[turf]) then
						killTimer(TurfTable.Timer[turf])
					end
					setRadarAreaFlashing (getElementData(turf,"Turf-Area"), false)
					setElementData(turf,"Turf-State",false)
					setElementData(turf,"Turf-Point",0)
					setElementData(turf,"Turf-Clan2","Boş")
                end				
			end
		end
		end			
end
addEventHandler ( "onPlayerQuit", getRootElement(), onTurfquitPlayer )

 

Clan System;

client.lua

local SpamOnClick = false
bindKey("y", "down", "chatbox", "Clan")
--------------------------
-- Function Center Window
--------------------------
function centerWindow(center_window)
screenW,screenH=guiGetScreenSize()
windowW,windowH=guiGetSize(center_window,false)
x,y = (screenW-windowW)/2,(screenH-windowH)/2
guiSetPosition(center_window,x,y,false)
end
----------------
-- Window Main
----------------
Window = guiCreateWindow(308, 142, 376, 464, "Clan Panel | F7", false)
guiSetProperty(Window, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(Window, false)
guiWindowSetMovable(Window,false)
guiSetVisible(Window,false)
guiSetAlpha(Window, 1.00)
centerWindow(Window)
CreateGroup = guiCreateButton(252, 23, 114, 34, "Clanı Oluştur", false, Window)
EditCreateGroup = guiCreateEdit(59, 23, 178, 34, "", false, Window)
guiSetFont(EditCreateGroup, "default-bold-small")
guiEditSetMaxLength(EditCreateGroup,10)
LabelClan = guiCreateLabel(10, 67, 305, 16, "Clan Adı :", false, Window)
ButtonViewAllGroups = guiCreateButton(10, 133, 160, 34, "Bilgilendirme", false, Window)
LabelNameCreatedGroups = guiCreateLabel(10, 92, 305, 16, "Clan Kurucu:", false, Window)
ButtonViewMyGroupMembers = guiCreateButton(10, 183, 160, 34, "Clan Üyeleri", false, Window)
ButtonViewAdminPanel = guiCreateButton(10, 376, 160, 34, "Yönetici Paneli", false, Window)
ButtonViewMyInviteGroups = guiCreateButton(10, 328, 160, 34, "Gelen Davetler", false, Window)
ButtonViewEditMyGroupRulesInfo = guiCreateButton(10, 231, 160, 34, "Clan Kuralları", false, Window)
ButtonInvitePlayerToGroup = guiCreateButton(10, 279, 160, 34, "Clana Davet Et", false, Window)
ButtonLeaveOfGroup = guiCreateButton(200, 424, 160, 30, "Clandan Ayrıl", false, Window)
ClanSiralamasi = guiCreateButton(10, 424, 160, 30, "Clan Sıralaması", false, Window)
ButtonAddEditNewEventGroup = guiCreateButton(202, 133, 159, 34, "  Duyuru Ekle", false, Window)
MemoEvents = guiCreateMemo(202, 188, 159, 227, "", false, Window)
guiSetFont(MemoEvents, "default-bold-small")
Label3 = guiCreateLabel(260, 169, 98, 16, "Duyurular", false, Window)
guiMemoSetReadOnly(MemoEvents, true)
Label1 = guiCreateLabel(0, 108, 370, 15, "_____________________________________________________", false, Window)
Label2 = guiCreateLabel(10, 405, 370, 15, "_____________________________________________________", false, Window)
--------------------------
-- Window View All Groups
--------------------------
WindowViewAllGroups = guiCreateWindow(309, 171, 530, 430, "Clan Listesi", false)
guiSetProperty(WindowViewAllGroups, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowViewAllGroups, false)
guiWindowSetMovable(WindowViewAllGroups,false)
guiSetVisible(WindowViewAllGroups, false)
guiSetAlpha(WindowViewAllGroups, 1)
centerWindow(WindowViewAllGroups)
ListGroups = guiCreateGridList(19, 21, 270, 357, false, WindowViewAllGroups)
guiGridListAddColumn(ListGroups,"Clan Adı:",0.40)
guiGridListAddColumn(ListGroups,"Clan Sahibi:",0.40)
guiGridListSetSortingEnabled(ListGroups, false)
guiGridListSetSelectionMode(ListGroups,1)
ListViewMembersGroup = guiCreateGridList(300, 21, 220, 357, false, WindowViewAllGroups)
guiGridListAddColumn(ListViewMembersGroup,"Clan Üyeleri:",0.50)
guiGridListSetSortingEnabled(ListViewMembersGroup, false)
guiGridListSetSelectionMode(ListViewMembersGroup,1)
CloseGroupsList = guiCreateButton(420, 385, 100, 32, "Kapat", false, WindowViewAllGroups)
ViewMembersSelectGroup = guiCreateButton(310, 385, 100, 32, "Üyeleri Göster", false, WindowViewAllGroups)
CountGroupsLabel = guiCreateLabel(15, 390, 156, 20, "", false, WindowViewAllGroups)
CountMembersLabel = guiCreateLabel(160, 390, 156, 20, "", false, WindowViewAllGroups)

--------------------------
-- Bilgilendirme
--------------------------
ClanBilgilendirmeWindow = guiCreateWindow(245, 115, 450, 500, "Bilgilendirme", false)
guiSetProperty(ClanBilgilendirmeWindow, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(ClanBilgilendirmeWindow, false)
guiWindowSetMovable(ClanBilgilendirmeWindow,false)
guiSetVisible(ClanBilgilendirmeWindow, false)
guiSetAlpha(ClanBilgilendirmeWindow, 1)
centerWindow(ClanBilgilendirmeWindow)
MeomBilgilendirmeClan = guiCreateMemo(15, 50, 425, 400, "Klan Puanı Nasıl Yükselir?\n----------------------------------\n-Klanında olan oyuncular görev yaptıkça klan puanı artar ve bir miktar klan bankasına para yatar.\n\nClana 1 Puan ve $1.000 veren görevler;\nUyuşturucu Teslimat [Kolay], Silah Teslimat [Kolay], Petrol Teslimat [Kolay], Araba Teslimat [Kolay].\n\nClana 2 Puan ve $2.000 veren görevler;\nUyuşturucu Teslimat [Zor], Silah Teslimat [Zor], Petrol Teslimat [Zor], Araba Teslimat [Zor].\n\nClana 3 Puan ve $3.000 veren görevler; \nLiman [Kolay],Taksi [Kolay], Uçak [Kolay].\n\nClana 4 Puan ve $4.000 veren görevler; \nTaksi [Zor], Uçak [Zor].\n\n-Klanında olan oyuncular etkinlik kazandıkça klan puanı 1 artar ve $1.000 klan bankasına para yatar.\n\n--------------------------\nTurf Nedir?\n--------------------------\n-Belirli bölgeler içerisini belirli bir zamanda ele geçirip o bölge sayesinde klan bankanıza belirli miktarda para yatar. Kısacası klanlar arası savaş alanı diyebiliriz.\n-Turf alanlarını radar veya [F11] tuşuna basarak renkli alanları(doğma bölgeleri hariç) bulabilirsiniz.\n-Eğer turf sizinse, her saat başı klana turf başına $10.000 klan bankasına yatar ve +10 klan puanı eklenir.\n\n\n---------------------------\nKlan Rütbe Yetkileri\n---------------------------\n[Kurucu]\n- Tüm Yetkilere Sahiptir.\n \n[Yönetici]\n-Klana oyuncu davet etme.\n-Kuralları düzenleyebilme.\n-Duyuruları düzenleyebilme.\n-Klan bankasına para yatırıp, çekebilme.\n \n[Yardımcı]\n-Klana oyuncu davet etme.\n-Kuralları düzenleyebilme.\n-Duyuruları düzenleyebilme.\n-Klan bankasına para yatırma.\n \n[Editör]\n-Klana oyuncu davet etme.\n-Klan bankasına para yatırma.\n \n[Üye]\n-Klan bankasına para yatırma.\n\nKlana Alınabilcek Maksimum Oyuncu Sayısı\n----------------------------------------\n-[1000] Puan altı klanlar '20' kişi alabilir.\n-[1000-5000] Puan arası klanlar '30' kişi alabilir.\n-[5000] Puan üzeri klanlar '40' kişi alabilir.", false, ClanBilgilendirmeWindow)
guiMemoSetReadOnly(MeomBilgilendirmeClan, true)
guiSetFont(MeomBilgilendirmeClan, "default-bold-small")
KapatButonBilgilendirmeClan = guiCreateButton(150, 466, 133, 24, "Kapat", false, ClanBilgilendirmeWindow)
---------------------
-- Window New Event
---------------------
WindowEvent = guiCreateWindow(266, 189, 350, 200, "Duyuru Ekle", false)
guiSetProperty(WindowEvent, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowEvent, false)
guiWindowSetMovable(WindowEvent,false)
guiSetVisible(WindowEvent,false)
guiSetAlpha(WindowEvent, 1.00)
centerWindow(WindowEvent)
MeomEventNew = guiCreateMemo(16, 23, 318, 137, "", false, WindowEvent)
guiSetFont(MeomEventNew, "default-bold-small")
SaveEvent = guiCreateButton(34, 166, 127, 24, "Kaydet", false, WindowEvent)
KapatButonDuyuru = guiCreateButton(184, 166, 127, 24, "Kapat", false, WindowEvent)
---------------------
-- Window Ruels/Info
---------------------
WindowRules = guiCreateWindow(245, 115, 450, 500, "Clan Kuralları", false)
guiSetProperty(WindowRules, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowRules, false)
guiWindowSetMovable(WindowRules,false)
guiSetVisible(WindowRules, false)
guiSetAlpha(WindowRules, 1)
centerWindow(WindowRules)
MeomRulesInfo1 = guiCreateMemo(15, 58, 425, 247, "", false, WindowRules)
guiMemoSetReadOnly(MeomRulesInfo1, true)
guiSetFont(MeomRulesInfo1, "default-bold-small")
LabeR404 = guiCreateLabel(15, 31, 352, 22, "Clan Kuralları:", false, WindowRules)
guiSetFont(LabeR404, "default-bold-small")
guiLabelSetColor(LabeR404, 28, 130, 226)
LabelR405 = guiCreateLabel(15, 322, 425, 18, "Clan Kuralarını Değiştir:", false, WindowRules)
guiSetFont(LabelR405, "default-bold-small")
guiLabelSetColor(LabelR405, 28, 130, 226)
MeomRulesInfo = guiCreateMemo(17, 350, 413, 106, "", false, WindowRules)
guiSetFont(MeomRulesInfo, "default-bold-small")
SaveRules = guiCreateButton(66, 466, 133, 24, "Kaydet", false, WindowRules)
KapatButonKurallar = guiCreateButton(241, 466, 133, 24, "Kapat", false, WindowRules)
---------------------
-- CLAN SIRALAMASI
---------------------
WindowSiralama = guiCreateWindow(245, 115, 450, 500, "Clan Sıralaması", false)
guiSetProperty(WindowSiralama, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowSiralama, false)
guiWindowSetMovable(WindowSiralama,false)
guiSetVisible(WindowSiralama, false)
guiSetAlpha(WindowSiralama, 1)
centerWindow(WindowSiralama)
KapatButonSiralama = guiCreateButton(160, 466, 133, 24, "Kapat", false, WindowSiralama)

WindowSiralamaList = guiCreateGridList(5, 20, 440, 440, false, WindowSiralama)
local column = guiGridListAddColumn(WindowSiralamaList, "Sıra", 0.20 ) 
local column1 = guiGridListAddColumn(WindowSiralamaList, "Clan Adı", 0.40 ) 
local column2 = guiGridListAddColumn(WindowSiralamaList, "Clan Puanı", 0.30 )
guiGridListSetSortingEnabled(WindowSiralamaList, false)
for i = 1,200 do
local row = guiGridListAddRow ( WindowSiralamaList )
guiGridListSetItemText ( WindowSiralamaList, row, column, "" .. i .. "-", false, false )
guiGridListSetItemText ( WindowSiralamaList, row, column1, "-", false, false )
guiGridListSetItemText ( WindowSiralamaList, row, column2, "-", false, false )
guiGridListSetItemColor(WindowSiralamaList, row, column1, 255, 255, 0)
guiGridListSetItemColor(WindowSiralamaList, row, column2, 0, 180, 255)
guiGridListSetItemColor(WindowSiralamaList, row, column, 255, 0, 0)
end

function updateTopList(name, top, i)
local row = guiGridListAddRow ( WindowSiralamaList )
guiGridListSetItemText ( WindowSiralamaList, row, column, "" .. i .. "-", false, false )
guiGridListSetItemText (WindowSiralamaList, row, column1, tostring(name), false, false )
guiGridListSetItemText ( WindowSiralamaList, row, column2, top, false, false )
guiGridListSetItemColor(WindowSiralamaList, row, column1, 255, 255, 0)
guiGridListSetItemColor(WindowSiralamaList, row, column2, 0, 180, 255)
guiGridListSetItemColor(WindowSiralamaList, row, column, 255, 0, 0)
end
addEvent("updateTop", true)
addEventHandler("updateTop", root, updateTopList)

function update()
guiGridListClear(WindowSiralamaList)
end
addEvent("deltTop", true)
addEventHandler("deltTop", root, update)
--------------------------
-- Window View All Members
--------------------------
WindowMembers = guiCreateWindow(124, 174, 679, 370, "Clan Üyeleri", false)
guiSetProperty(WindowMembers, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowMembers, false)
guiWindowSetMovable(WindowMembers,false)
guiSetVisible(WindowMembers, false)
guiSetAlpha(WindowMembers, 1)
centerWindow(WindowMembers)
ListMembers = guiCreateGridList(14, 30, 655, 299, false, WindowMembers)
guiGridListAddColumn(ListMembers,"Üye Adı:",0.30)
guiGridListAddColumn(ListMembers,"Üye Rütbesi:",0.13)
guiGridListAddColumn(ListMembers,"Üye Durumu:",0.13)
guiGridListAddColumn(ListMembers,"Üye Hesap Adı:",0.22)
guiGridListAddColumn(ListMembers,"Üye Son Giriş Tarihi:",0.24)
guiGridListSetSortingEnabled(ListMembers, false)
guiGridListSetSelectionMode(ListMembers,1)
KapatButonUyeleri = guiCreateButton(285, 334, 99, 26, "Kapat", false, WindowMembers)
----------------------
-- Window Admin Panel
----------------------
WindowAdmin = guiCreateWindow(190, 150, 667, 400, "Yönetici Paneli", false)
guiSetProperty(WindowAdmin, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowAdmin, false)
guiWindowSetMovable(WindowAdmin,false)
guiSetVisible(WindowAdmin, false)
guiSetAlpha(WindowAdmin, 1)
centerWindow(WindowAdmin)
ListAdmin = guiCreateGridList(10, 25, 516, 355, false, WindowAdmin)
guiGridListAddColumn(ListAdmin,"Üye Adı:",0.25)
guiGridListAddColumn(ListAdmin,"Üye Rütbesi:",0.13)
guiGridListAddColumn(ListAdmin,"Üye Durumu:",0.13)
guiGridListAddColumn(ListAdmin,"Üye Hesap Adı:",0.22)
guiGridListAddColumn(ListAdmin,"Üye Son Giriş Tarihi:",0.24)
guiGridListSetSortingEnabled(ListAdmin, false)
guiGridListSetSelectionMode(ListAdmin,1)
CloseAdmin = guiCreateButton(534, 359, 157, 24, "Kapat", false, WindowAdmin)
GiveOwner = guiCreateButton(534, 25, 123, 24, "Kuruculuk Ver", false, WindowAdmin)
GiveAdmin = guiCreateButton(534, 59, 123, 24, "Yöneticilik Ver", false, WindowAdmin)
GiveSuperModerator = guiCreateButton(534, 93, 123, 24, "Yardımcılık Ver", false, WindowAdmin)
GiveModerator = guiCreateButton(534, 127, 123, 24, "Editörlük Ver", false, WindowAdmin)
GiveMember = guiCreateButton(534, 161, 123, 24, "Üyelik Ver", false, WindowAdmin)
GiveKick = guiCreateButton(534, 195, 123, 24, "Clandan At", false, WindowAdmin)
ChangeOwner = guiCreateButton(534, 229, 123, 24, "Kurucu Değiştir", false, WindowAdmin)
MoneySystem = guiCreateButton(534, 263, 123, 24, "Clan Bankası", false, WindowAdmin)
ClanPuanInGroup = guiCreateLabel(534, 289, 123, 24, "Puan: ", false, WindowAdmin)
LabelOnlineInGroup = guiCreateLabel(534, 313, 123, 24, "Açık: [ - ]", false, WindowAdmin)
guiLabelSetColor(LabelOnlineInGroup,0,255,0)
LabelOfflineInGroup = guiCreateLabel(534, 337, 123, 24, "Kapalı: [ - ]", false, WindowAdmin)
guiLabelSetColor(LabelOfflineInGroup,255,0,0)

addEvent("LevelYenile",true)
addEventHandler("LevelYenile",root,function(Level)
if Level==nil then return end
guiSetText(ClanPuanInGroup,"Puan: "..Level.."")
end)
----------------------------------
-- Window Invite Player To Group
----------------------------------
WindowPlayers = guiCreateWindow(274, 128, 272, 468, "Davet Et", false)
guiSetProperty(WindowPlayers, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowPlayers, false)
guiWindowSetMovable(WindowPlayers,false)
guiSetVisible(WindowPlayers, false)
guiSetAlpha(WindowPlayers, 1)
centerWindow(WindowPlayers)
ListPlayers = guiCreateGridList(11, 27, 251, 347, false, WindowPlayers)
guiGridListAddColumn(ListPlayers,"Oyuncu Adı:",0.60)
guiGridListAddColumn(ListPlayers,"Hesap Adı:",0.30)
guiGridListSetSortingEnabled(ListPlayers, false)
ButtonInvite = guiCreateButton(69, 384, 136, 33, "Davet Et", false, WindowPlayers)
CloseInvite = guiCreateButton(69, 427, 136, 33, "Kapat", false, WindowPlayers)
----------------------------------
-- Window Invite Groups ,
----------------------------------
WindowInvite = guiCreateWindow(274, 128, 272, 500, "Clan Davetleri", false)
guiSetProperty(WindowInvite, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowInvite, false)
guiWindowSetMovable(WindowInvite,false)
guiSetVisible(WindowInvite, false)
guiSetAlpha(WindowInvite, 1)
centerWindow(WindowInvite)
ListInvite = guiCreateGridList(11, 27, 251, 347, false, WindowInvite)
guiGridListAddColumn(ListInvite,"Clan Adı:",0.50)
guiGridListAddColumn(ListInvite,"Daveti Gönderen:",0.50)
guiGridListAddColumn(ListInvite,"Hesap Adı:",0.50)
guiGridListSetSortingEnabled(ListInvite, false)
ButtonAgre = guiCreateButton(69, 384, 136, 33, "Kabul Et", false, WindowInvite)
DeletedInvite = guiCreateButton(69, 420, 136, 33, "Reddet", false, WindowInvite)
CloseWInvite = guiCreateButton(69, 457, 136, 33, "Kapat", false, WindowInvite)
-----------------------------
-- Money System For Group,

ClanBankWindow = guiCreateWindow(602, 353, 336, 157, "Clan Banka", false)
guiSetProperty(ClanBankWindow, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(ClanBankWindow, false)
guiWindowSetMovable(ClanBankWindow,false)
guiSetVisible(ClanBankWindow, false)
guiSetAlpha(ClanBankWindow, 1)
centerWindow(ClanBankWindow)

ClanBankLabel1 = guiCreateLabel(5, 22, 325, 26, "Clan Bankasındaki Toplam Para:", false, ClanBankWindow)
guiSetFont(ClanBankLabel1, "default-bold-small")
guiLabelSetHorizontalAlign(ClanBankLabel1, "center", false)
guiLabelSetVerticalAlign(ClanBankLabel1, "center")
ClanBankEdit1 = guiCreateEdit(9, 47, 317, 29, "0", false, ClanBankWindow)
guiEditSetReadOnly(ClanBankEdit1, true)
guiSetFont(ClanBankEdit1, "default-bold-small")
ClanBankEdit2 = guiCreateEdit(9, 79, 128, 29, "", false, ClanBankWindow)
guiSetFont(ClanBankEdit2, "default-bold-small")
ClanBankButon1 = guiCreateButton(142, 80, 89, 28, "Para Çek", false, ClanBankWindow)
guiSetFont(ClanBankButon1, "default-bold-small")
ClanBankButon2 = guiCreateButton(237, 80, 89, 28, "Para Yatır", false, ClanBankWindow)
guiSetFont(ClanBankButon2, "default-bold-small")
ClanBankButon3 = guiCreateButton(9, 115, 317, 28, "Kapat", false, ClanBankWindow)
guiSetFont(ClanBankButon3, "default-bold-small")

addEvent("BankaYenile",true)
addEventHandler("BankaYenile",root,function(Para)
if Para==nil then return end
guiSetText(ClanBankEdit1,""..Para.."")
end)

-----------------------------
WindowMoney = guiCreateWindow(330, 143, 373, 438, "Money System For My Group", false)
guiSetProperty(WindowMoney, "CaptionColour", "FF1C90E1")
guiWindowSetSizable(WindowMoney, false)
guiWindowSetMovable(WindowMoney,false)
guiSetVisible(WindowMoney, false)
guiSetAlpha(WindowMoney, 1)
centerWindow(WindowMoney)
ButtonAddMoney = guiCreateButton(169, 67, 127, 29, "Add Money", false, WindowMoney)
EditAddMoney = guiCreateEdit(70, 71, 89, 25, "", false, WindowMoney)
L_5 = guiCreateLabel(15, 78, 51, 18, "Amount : :", false, WindowMoney)
L_3 = guiCreateLabel(19, 34, 237, 17, "* For Add Money Need To Be 1000 or up .", false, WindowMoney)
L_7 = guiCreateLabel(106, 311, 171, 18, "For Use Any amount Select it .", false, WindowMoney)
GivwMySelf = guiCreateButton(130, 339, 136, 26, "Give My Self", false, WindowMoney)
GiveAllOnline = guiCreateButton(130, 370, 136, 26, "Give All Online In Group", false, WindowMoney)
CloseWindowMoneySystem = guiCreateButton(150, 405, 50, 20, "Close", false, WindowMoney)
ListMoney = guiCreateGridList(19, 118, 345, 178, false, WindowMoney)
guiGridListAddColumn(ListMoney, "#Name:", 0.7)
guiGridListAddColumn(ListMoney, "#Amount:", 0.2)
guiGridListAddColumn(ListMoney, "#Account: ", 0.2)
guiGridListAddColumn(ListMoney, "#Rank:", 0.2)
guiGridListAddColumn(ListMoney, "#Tick:", 0.2)
guiMemoSetReadOnly(MeomRulesInfo1, true)
for _,v in ipairs (getElementsByType("gui-label",resourceRoot)) do
guiSetFont(v,"default-bold-small")
end
for _,v in ipairs (getElementsByType("gui-button",resourceRoot)) do
guiSetFont(v,"default-bold-small")
end
----------------------
-- Functions - Events
----------------------
addEventHandler("onClientGUIClick",guiRoot,function()
	if ( SpamOnClick == false ) then
		if ( source == CreateGroup ) then
			local GGTCC = guiGetText(EditCreateGroup)
			if ( GGTCC == "" or GGTCC == " " or GGTCC == "  " or GGTCC == "   " or GGTCC == nil ) then
				_outputChatBox("Lütfen Clan Adını Girin",255,0,0,true)
			else
				if ( string.len(GGTCC) >= 3 ) then
					if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
						if ( getElementData(getLocalPlayer(),"Clan") == "" ) then
							triggerServerEvent("CreateGroup",getLocalPlayer(),GGTCC)
						else
							_outputChatBox("Zaten Clanın Var",255,0,0,true)
						end
					else
						_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
					end
				else
					_outputChatBox("Clan Adı En Az 3 Karakterden Oluşmalıdır",255,0,0,true)
				end
			end
		elseif ( source == ButtonViewAllGroups ) then
			falseAllWindow()
			guiSetVisible(ClanBilgilendirmeWindow,true)
			showCursor(true)
			guiSetInputEnabled(true)
		elseif ( source == ClanSiralamasi ) then
			falseAllWindow()
			guiSetVisible(WindowSiralama,true)
			showCursor(true)
			guiSetInputEnabled(true)
            triggerServerEvent("getTop", localPlayer)		
		elseif ( source == KapatButonBilgilendirmeClan ) then 
			falseAllWindow()
		elseif ( source == KapatButonKurallar ) then
			falseAllWindow()
		elseif ( source == KapatButonSiralama ) then
			falseAllWindow()			
		elseif ( source == KapatButonUyeleri ) then
			falseAllWindow()
		elseif ( source == KapatButonDuyuru ) then
			falseAllWindow()
		elseif ( source == ButtonAddEditNewEventGroup ) then
			local rank = getElementData(getLocalPlayer(),"RankPlayer")
			if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
				if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
					if ( rank == "Kurucu" or rank == "Yönetici" or rank == "Yardımcı" ) then
						falseAllWindow()
						guiSetVisible(WindowEvent,true)
						showCursor(true)
						guiSetInputEnabled(true)
					else
						_outputChatBox("Sadece Kurucu & Yönetici & Yardımcı Bu Bölümü Kullanabilir",255,0,0,true)
					end
				else
					_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
				end
			else
				_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
			end
		elseif ( source == SaveEvent ) then
			triggerServerEvent("UpEvent",getLocalPlayer(),guiGetText(MeomEventNew))
			falseAllWindow()
		elseif ( source == ButtonViewEditMyGroupRulesInfo ) then
			local rank = getElementData(getLocalPlayer(),"RankPlayer")
			if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
				if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
					falseAllWindow()
					guiSetVisible(WindowRules,true)
					showCursor(true)
					guiSetInputEnabled(true)
				else
					_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
				end
			else
				_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
			end
		elseif ( source == SaveRules ) then
			local rank = getElementData(getLocalPlayer(),"RankPlayer")
			if ( rank == "Kurucu" or rank == "Yönetici" or rank == "Yardımcı" ) then
				triggerServerEvent("UpRuel",getLocalPlayer(),guiGetText(MeomRulesInfo))
			else
				_outputChatBox("Sadece Kurucu & Yönetici & Yardımcı Bu Bölümü Kullanabilir",255,0,0,true)
			end
		elseif ( source == ButtonViewMyGroupMembers ) then
			if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
				if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
					triggerServerEvent("UpMembers",getLocalPlayer())
					falseAllWindow()
					guiSetVisible(WindowMembers,true)
					showCursor(true)
					guiSetInputEnabled(true)
				else
					_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
				end
			else
				_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
			end
		elseif ( source == CloseMembers ) then
			falseAllWindow()
		elseif ( source == ButtonViewAdminPanel ) then
			local rank = getElementData(getLocalPlayer(),"RankPlayer")
			if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
				if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
					if ( rank ~= "" ) then
						falseAllWindow()
						guiSetVisible(WindowAdmin,true)
						showCursor(true)
						guiSetInputEnabled(true)
						triggerServerEvent("UpMembers",getLocalPlayer())
					else
						_outputChatBox("Yetkiye Sahip Değilsin",255,0,0,true)
					end
				else
					_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
				end
			else
				_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
			end
		elseif ( source == CloseAdmin ) then
			falseAllWindow()
		elseif ( source == GiveOwner ) then
			local sel = guiGridListGetSelectedItem(ListAdmin)
			local getSel = guiGridListGetItemText(ListAdmin,sel,4)
			if ( getSel ) then
				triggerServerEvent("GiveRank",getLocalPlayer(),tostring(getSel),"Kurucu")
			else
				_outputChatBox("Lütfen Oyuncu Seçiniz",255,0,0,true)
			end
		elseif ( source == GiveAdmin ) then
			local sel = guiGridListGetSelectedItem(ListAdmin)
			local getSel = guiGridListGetItemText(ListAdmin,sel,4)
			if ( getSel ) then
				triggerServerEvent("GiveRank",getLocalPlayer(),tostring(getSel),"Yönetici")
			else
				_outputChatBox("Lütfen Oyuncu Seçiniz",255,0,0,true)
			end
		elseif ( source == GiveSuperModerator ) then
			local sel = guiGridListGetSelectedItem(ListAdmin)
			local getSel = guiGridListGetItemText(ListAdmin,sel,4)
			if ( getSel ) then
				triggerServerEvent("GiveRank",getLocalPlayer(),tostring(getSel),"Yardımcı")
			else
				_outputChatBox("Lütfen Oyuncu Seçiniz",255,0,0,true)
			end
		elseif ( source == GiveModerator ) then
			local rank = getElementData(getLocalPlayer(),"RankPlayer")
			local sel = guiGridListGetSelectedItem(ListAdmin)
			local getSel = guiGridListGetItemText(ListAdmin,sel,4)
			if ( getSel ) then
				triggerServerEvent("GiveRank",getLocalPlayer(),tostring(getSel),"Editör")
			else
				_outputChatBox("Lütfen Oyuncu Seçiniz",255,0,0,true)
			end
		elseif ( source == GiveMember ) then
			local sel = guiGridListGetSelectedItem(ListAdmin)
			local getSel = guiGridListGetItemText(ListAdmin,sel,4)
			if ( getSel ) then
				triggerServerEvent("GiveRank",getLocalPlayer(),tostring(getSel),"Üye")
			else
				_outputChatBox("Lütfen Oyuncu Seçiniz",255,0,0,true)
			end
		elseif ( source == GiveKick ) then
			local sel = guiGridListGetSelectedItem(ListAdmin)
			local getSel = guiGridListGetItemText(ListAdmin,sel,4)
			if ( getSel ) then
				triggerServerEvent("GetKick",getLocalPlayer(),tostring(getSel))
			else
				_outputChatBox("Lütfen Oyuncu Seçiniz",255,0,0,true)
			end
		elseif ( source == ChangeOwner ) then
		local rank = getElementData(getLocalPlayer(),"RankPlayer")
		if ( rank == "Kurucu" ) then				
            local sel = guiGridListGetSelectedItem(ListAdmin)
			local getSel = guiGridListGetItemText(ListAdmin,sel,1)
			if ( getSel ) then
				triggerServerEvent("GetKurucuChange",getLocalPlayer(),tostring(getSel))
			else
				_outputChatBox("Lütfen Oyuncu Seçiniz",255,0,0,true)
			end   
		end
		elseif ( source == ClanBankButon1 ) then
		local rank = getElementData(getLocalPlayer(),"RankPlayer")
		if ( rank == "Kurucu" ) or ( rank == "Yönetici" ) then				
            Miktar = guiGetText(ClanBankEdit2)
			if ( Miktar ) and not ( Miktar=="" ) and not ( Miktar==nil ) then
				triggerServerEvent("ClanBankaCek",getLocalPlayer(),Miktar)
			else
				_outputChatBox("Hata",255,0,0,true)
			end   
		end
		elseif ( source == ClanBankButon2 ) then
		local rank = getElementData(getLocalPlayer(),"RankPlayer")			
            Miktar = guiGetText(ClanBankEdit2)
			if ( Miktar ) and not ( Miktar=="" ) and not ( Miktar==nil ) then
				triggerServerEvent("ClanBankaYatir",getLocalPlayer(),Miktar)
			else
				_outputChatBox("Hata",255,0,0,true)
			end   		
		elseif ( source == MoneySystem ) then
			if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
				local MyGroupName = getElementData(getLocalPlayer(),"Clan")
				if ( MyGroupName ~= "" ) then
					falseAllWindow()
					guiSetVisible(ClanBankWindow,true)
					showCursor(true)
					guiSetInputEnabled(true)
				else
					_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
				end
			else
				_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
			end
		elseif ( source == ViewMembersSelectGroup ) then
			local selectedItem = guiGridListGetSelectedItem(ListGroups)
			local ClanSelected = guiGridListGetItemText(ListGroups,selectedItem,1)
			if ( ClanSelected ) then
				triggerServerEvent("ViewMembersSelectGroup",getLocalPlayer(),ClanSelected)
			else
				_outputChatBox("Listeden Clan Seçmelisin",255,0,0,true)
			end
		elseif ( source == DeletedInvite ) then
			local selectedItemMyInvite = guiGridListGetSelectedItem(ListInvite)
			local ClanSelectedMyIvite = guiGridListGetItemText(ListInvite,selectedItemMyInvite,1)
			local NameI = guiGridListGetItemText(ListInvite,selectedItemMyInvite,2)
			local AccI = guiGridListGetItemText(ListInvite,selectedItemMyInvite,3)
			if ( ClanSelectedMyIvite and NameI and AccI) then
				triggerServerEvent("DeletedMyInvite",getLocalPlayer(),tostring(ClanSelectedMyIvite),tostring(AccI),tostring(NameI))
			else
				_outputChatBox("Listeden Davet Seçmelisin",255,0,0,true)
			end
		elseif ( source == ButtonLeaveOfGroup ) then
			if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
				if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
					triggerServerEvent("LeaveGroup",getLocalPlayer())
				else
					_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
				end
			else
				_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
			end
		elseif ( source == ButtonInvitePlayerToGroup ) then
			local rank = getElementData(getLocalPlayer(),"RankPlayer")
			if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
				if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
					if ( rank == "Kurucu" or rank == "Yönetici" or rank=="Yardımcı" or rank=="Editör" ) then
						falseAllWindow()
						guiSetVisible(WindowPlayers,true)
						showCursor(true)
						guiSetInputEnabled(true)
						guiGridListClear(ListPlayers)
						for _,plrs in ipairs (getElementsByType("player")) do
							if ( getElementData(plrs,"AccountName") ~= tostring("") ) then
							player1 = getLocalPlayer()
							 if plrs ~= player1 then 
								local row = guiGridListAddRow(ListPlayers)
								guiGridListSetItemText(ListPlayers,row,1,tostring(string.gsub(getPlayerName(plrs),'#%x%x%x%x%x%x','')), false, false)
								guiGridListSetItemText(ListPlayers,row,2,tostring(getElementData(plrs,"AccountName")), false, false)
								guiGridListSetItemColor(ListPlayers,row,1,0,255,255)
								guiGridListSetItemColor(ListPlayers,row,2,255,0,0)
							 end
							end
						end
					else
						_outputChatBox("Sadece Kurucu & Yönetici & Yardımcı & Editör Bu Bölümü Kullanabilir",255,0,0,true)
					end
				else
					_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
				end
			else
				_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
			end
		elseif ( source == ButtonAgre ) then
			local sel = guiGridListGetSelectedItem(ListInvite)
			local getSel = guiGridListGetItemText(ListInvite,sel,1)
			local NameI = guiGridListGetItemText(ListInvite,sel,2)
			local AccI = guiGridListGetItemText(ListInvite,sel,3)
			if ( getSel and NameI and AccI) then
				if ( getElementData(getLocalPlayer(),"Clan") == "" ) then
					if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
						triggerServerEvent("InviteAgre",getLocalPlayer(),tostring(getSel),tostring(AccI),tostring(NameI))
					else
						_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
					end
				else
					_outputChatBox("Başka Clana Gitmek İçin Clanından Çıkmalısın",255,0,0,true)
				end
			else
				_outputChatBox("Oyuncu Seçmelisin",255,0,0,true)
			end
		elseif ( source == ButtonInvite ) then
			local sel = guiGridListGetSelectedItem(ListPlayers)
			local getSel = guiGridListGetItemText(ListPlayers,sel,2)
			local getSel1 = guiGridListGetItemText(ListPlayers,sel,1)
			if ( getSel ) then
				local rank = getElementData(getLocalPlayer(),"RankPlayer")
				if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
					if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
						if ( rank == "Kurucu" or rank == "Yönetici" or rank=="Yardımcı" or rank=="Editör" ) then
							triggerServerEvent("InvitePlayer",getLocalPlayer(),tostring(getSel),tostring(getSel1))
						else
							_outputChatBox("Sadece Kurucu & Yönetici & Yardımcı & Editör  Bu Bölümü Kullanabilir",255,0,0,true)
						end
					else
						_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
					end
				else
					_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
				end
			else
				_outputChatBox("Oyuncu Seçmelisin",255,0,0,true)
			end
		elseif ( source == CloseInvite ) then
			falseAllWindow()
		elseif ( source == CloseWInvite ) then
			falseAllWindow()
		elseif ( source == ButtonAddMoney ) then
			local amount = guiGetText(EditAddMoney)
			if ( tonumber(amount) and tonumber(amount) ~= nil and string.len(amount) >= 4 ) then
				if ( tonumber(amount) >= 1000 ) then
					if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
						if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
							triggerServerEvent("AddMoney",getLocalPlayer(),tonumber(amount))
						else
							_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
						end
					else
						_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
					end
				else
					_outputChatBox("$1000'dan Yüksek Para Yatırmalısın",255,0,0,true)
				end
			else
				_outputChatBox("En Az 4 Sayıdan Oluşmalıdır",255,0,0,true)
			end
		elseif ( source == GivwMySelf ) then
			local selectTake = guiGridListGetSelectedItem(ListMoney)
			local nameTake = guiGridListGetItemText(ListMoney,selectTake,1)
			local AmountTake = guiGridListGetItemText(ListMoney,selectTake,2)
			local AccountTake = guiGridListGetItemText(ListMoney,selectTake,3)
			local TickTake = guiGridListGetItemText(ListMoney,selectTake,5)
			if ( tostring(nameTake) and tonumber(AmountTake) and  tostring(AccountTake) and tonumber(TickTake) ) then
				local rank = getElementData(getLocalPlayer(),"RankPlayer")
				if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
					if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
						if ( rank ~= "Üye" and rank ~= "" ) then
							triggerServerEvent("GiveMoneyMySelf",getLocalPlayer(),tostring(nameTake),tonumber(AmountTake),tostring(AccountTake),tonumber(TickTake))
						else
							_outputChatBox("Yetkiye Sahip Değilsin",255,0,0,true)
						end
					else
						_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
					end
				else
					_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
				end
			else
				_outputChatBox("Listeden Para Seçiniz",255,0,0,true)
			end
		elseif ( source == GiveAllOnline ) then
			local selectTake = guiGridListGetSelectedItem(ListMoney)
			local nameTake = guiGridListGetItemText(ListMoney,selectTake,1)
			local AmountTake = guiGridListGetItemText(ListMoney,selectTake,2)
			local AccountTake = guiGridListGetItemText(ListMoney,selectTake,3)
			local TickTake = guiGridListGetItemText(ListMoney,selectTake,5)
			if ( tostring(nameTake) and tonumber(AmountTake) and  tostring(AccountTake) and tonumber(TickTake) ) then
				local rank = getElementData(getLocalPlayer(),"RankPlayer")
				if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
					if ( getElementData(getLocalPlayer(),"Clan") ~= "" ) then
						if ( rank ~= "Üye" and rank ~= "" ) then
							triggerServerEvent("GiveMoneyAllOnline",getLocalPlayer(),tostring(nameTake),tonumber(AmountTake),tostring(AccountTake),tonumber(TickTake))
						else
							_outputChatBox("Yetkiye Sahip Değilsin",255,0,0,true)
						end
					else
						_outputChatBox("Clana Sahip Değilsin",255,0,0,true)
					end
				else
					_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
				end
			else
				_outputChatBox("Listeden Para Seçiniz",255,0,0,true)
			end
		elseif ( source == ClanBankButon3 ) then
			falseAllWindow()
		elseif ( source == ButtonViewMyInviteGroups ) then
			if ( getElementData(getLocalPlayer(),"AccountName") ~= "" ) then
				falseAllWindow()
				guiSetVisible(WindowInvite,true)
				showCursor(true)
				guiSetInputEnabled(true)
				triggerServerEvent("ViewMyInvite",getLocalPlayer())
			else
				_outputChatBox("Hesabına Giriş Yapmalısın",255,0,0,true)
			end
		end
		SpamOnClick = true
		setTimer(function() SpamOnClick = false end,60,1)
	else
		
	end
end)

addEventHandler("onClientRender",root,function()
	local Clan = getElementData(getLocalPlayer(),"Clan")
if Clan then
	local getOwnerLabel = getElementData(resourceRoot,"Kurucu"..Clan.."")
	local CountPlayersOnlineInMyGroup = getElementData(getLocalPlayer(),"OnlineInMyGroup")
	local PlayersOfflineInMyGroup = getElementData(getLocalPlayer(),"OfflineInMyGroup")
	if ( Clan and Clan ~= "" ) then
		local event = getElementData(resourceRoot,"Event"..Clan.."")
		local rule = getElementData(resourceRoot,"Ruel"..Clan.."")
		local owner = getElementData(resourceRoot,"Kurucu"..Clan.."")
		if ( event ) then
			guiSetText(MemoEvents,event)
		end
		if ( rule ) then
			guiSetText(MeomRulesInfo1,rule)
		end
		if ( owner ) then
			guiSetText(LabelNameCreatedGroups,"Clan Kurucusu : "..owner)
		end
		if ( CountPlayersOnlineInMyGroup ) then
			guiSetText(LabelOnlineInGroup,"Açık:  "..CountPlayersOnlineInMyGroup.." ")
		end
		if ( PlayersOfflineInMyGroup ) then
			guiSetText(LabelOfflineInGroup,"Kapalı:  "..PlayersOfflineInMyGroup.." ")
		else
			guiSetText(LabelOfflineInGroup,"Kapalı:  - ")
		end
	end
	if not( getOwnerLabel ) then
		guiSetText(LabelNameCreatedGroups,"Clan Kurucusu : ")
	end
	guiSetText(LabelClan,"Clan Adı : "..Clan)
end
	local CountGroups = getElementData(resourceRoot,"CountGroups")
	if ( CountGroups ) then
	
		guiSetText(CountGroupsLabel,"  Clan Sayısı :  "..CountGroups.." ")
	else
		guiSetText(CountGroupsLabel,"  Clan Sayısı :  - ")
	end
	local CountMembers = getElementData(resourceRoot,"CountMembers")	
	if ( CountMembers ) then
		guiSetText(CountMembersLabel,"  Üye Sayısı :  "..CountMembers.." ")
	else
		guiSetText(CountMembersLabel,"  Üye Sayısı :  - ")
	end
end)

addEvent("DestroyGui",true)
addEventHandler("DestroyGui",root,function()
	falseAllWindow()
	guiGridListClear(ListInvite)
	for _,v in ipairs (getElementsByType("gui-edit",resourceRoot)) do
		guiSetText(v,"")
	end
	for _,v in ipairs (getElementsByType("gui-memo",resourceRoot)) do
		guiSetText(v,"")
	end
end)

addEvent("upGroupsToList",true)
addEventHandler("upGroupsToList",root,function(GroupsTableOfSql)
	guiGridListClear(ListGroups)
	for _,v in ipairs (GroupsTableOfSql) do
		local row = guiGridListAddRow(ListGroups)
		guiGridListSetItemText(ListGroups,row,1,tostring(v.groupName),false,false)
		guiGridListSetItemText(ListGroups,row,2,tostring(v.ownerName),false,false)
		guiGridListSetItemColor(ListGroups,row,1,0,255,255)
		guiGridListSetItemColor(ListGroups,row,2,255,255,0)
	end
end)

addEvent("upMyInviteToList",true)
addEventHandler("upMyInviteToList",root,function(InviteTableOfSql)
	guiGridListClear(ListInvite)
	for _,v in ipairs (InviteTableOfSql) do
		local row = guiGridListAddRow(ListInvite)
		guiGridListSetItemText(ListInvite,row,1,tostring(v.GroupNamePlrSendInvite),false,false)
		guiGridListSetItemText(ListInvite,row,2,tostring(v.NamePlrSendInvite),false,false)
		guiGridListSetItemText(ListInvite,row,3,tostring(v.AccountPlrSendInvite),false,false)
		guiGridListSetItemColor(ListInvite,row,1,0,255,255)
		guiGridListSetItemColor(ListInvite,row,2,255,255,0)
		guiGridListSetItemColor(ListInvite,row,3,0,0,255)
	end
end)

addEvent("upMembersToList",true)
addEventHandler("upMembersToList",root,function(MembersTableOfSql)
	if ( guiGetVisible(WindowMembers) == true ) then
		ListElement = ListMembers
	else
		ListElement = ListAdmin
	end
	guiGridListClear(ListElement)
	for _,v in ipairs (MembersTableOfSql) do
		local row = guiGridListAddRow(ListElement)
		guiGridListSetItemText(ListElement,row,1,tostring(v.NameMember),false,false)
		guiGridListSetItemText(ListElement,row,2,tostring(v.RankMember),false,false)
		guiGridListSetItemText(ListElement,row,3,tostring(v.StateMember),false,false)
		guiGridListSetItemText(ListElement,row,4,tostring(v.AccountMember),false,false)		
		guiGridListSetItemText(ListElement,row,5,tostring(v.LastLoginMember),false,false)
		guiGridListSetItemColor(ListElement,row,1,0,255,255)
		guiGridListSetItemColor(ListElement,row,2,255,255,0)
		guiGridListSetItemColor(ListElement,row,3,0,0,255)
		guiGridListSetItemColor(ListElement,row,4,0,255,0)
	end
end)

addEvent("upMyGroupMoneyToList",true)
addEventHandler("upMyGroupMoneyToList",root,function(MoneyTableOfSql)
	guiGridListClear(ListMoney)
	for _,v in ipairs(MoneyTableOfSql) do
		local row = guiGridListAddRow(ListMoney)
		guiGridListSetItemText(ListMoney,row,1,tostring(v.NamePlayer),false,false)
		guiGridListSetItemText(ListMoney,row,2,tostring(v.AmountPlayer),false,false)
		guiGridListSetItemText(ListMoney,row,3,tostring(v.AccountPlayer),false,false)
		guiGridListSetItemText(ListMoney,row,4,tostring(v.Rank),false,false)
		guiGridListSetItemText(ListMoney,row,5,tostring(v.Tick),false,false)
		guiGridListSetItemColor(ListMoney,row,1,0,255,255)
		guiGridListSetItemColor(ListMoney,row,2,255,255,0)
		guiGridListSetItemColor(ListMoney,row,3,0,0,255)
		guiGridListSetItemColor(ListMoney,row,4,0,255,0)
		guiGridListSetItemColor(ListMoney,row,5,0,255,255)
	end
end)

addEvent("upMembersSelectToList",true)
addEventHandler("upMembersSelectToList",root,function(members)
	guiGridListClear(ListViewMembersGroup)
	for _,v in ipairs (members) do
		local row = guiGridListAddRow(ListViewMembersGroup)
		guiGridListSetItemText(ListViewMembersGroup,row,1,tostring(v.NameMembers),false,false)
		guiGridListSetItemColor(ListViewMembersGroup,row,1,0,255,255)
	end
end)

function falseAllWindow()
	for i,v in ipairs (getElementsByType("gui-window",resourceRoot)) do
		guiSetVisible(v,false)
		showCursor(false)
		guiSetInputEnabled(false)
	end
end
-------------
-- Bind Key
-------------
bindKey("F7","Down",function()
if ( guiGetVisible(Window) == false ) and not getElementData(localPlayer,"Turf") then
falseAllWindow()
guiSetVisible(Window,true)
showCursor(true)
guiSetInputEnabled(true)
elseif ( guiGetVisible(Window) == true ) then
falseAllWindow()
end
end)

server.lua

addEvent("onPlayerCreatedGroup",true)
addEvent("onPlayerDeletedGroup",true)

addEventHandler("onResourceStart",resourceRoot,function()
	executeSQLQuery("CREATE TABLE IF NOT EXISTS ClanSistemi (Account,Clan,RankPlayer,Kurucu,Event,Ruel)")
	executeSQLQuery("CREATE TABLE IF NOT EXISTS ClanSistemiUyeler (Account,Clan,RankPlayer,State,Name)")
	executeSQLQuery("CREATE TABLE IF NOT EXISTS ClanSistemiDavet (Account,Name,Clan)")
	executeSQLQuery("CREATE TABLE IF NOT EXISTS ClanSistemiError (Account,Name,RankPlayer,Clan,Amount,Tick)")
	executeSQLQuery("CREATE TABLE IF NOT EXISTS ClanSistemiBanka (Clan,Banka)")
	executeSQLQuery("CREATE TABLE IF NOT EXISTS ClanSistemiLevel (Clan,Level)")	
	executeSQLQuery("CREATE TABLE IF NOT EXISTS ClanSistemiRENK (Clan,R,G,B)")		
	exports.scoreboard:addScoreboardColumn("Clan")
	executeSQLQuery("UPDATE ClanSistemiUyeler SET State=? ",tostring("Kapalı"))			
	for _,plrs in ipairs (getElementsByType("player")) do
		local acc = getPlayerAccount(plrs)
		if ( acc ) then
			if not( isGuestAccount(acc) ) then
				setElementData(plrs,"AccountName",tostring(getAccountName(acc)))
				local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(getAccountName(acc)))
				if ( type(Row) == "table" and #Row == 0 or not Row ) then
					setElementData(plrs,"Clan","")
					setElementData(plrs,"RankPlayer","")
				else
					local Row_ = executeSQLQuery("SELECT * FROM ClanSistemi WHERE Clan=?",tostring(Row[1]["Clan"]))
					local Row_1 = executeSQLQuery("SELECT * FROM ClanSistemiBanka WHERE Clan=?",tostring(Row[1]["Clan"]))
			      	local Row_2 = executeSQLQuery("SELECT * FROM ClanSistemiLevel WHERE Clan=?",tostring(Row[1]["Clan"]))					
					if ( type(Row_) == "table" and #Row_ == 0 or not Row_ ) then
						return false
					else
						setElementData(resourceRoot,"Event"..tostring(Row_[1]["Clan"]).."",tostring(Row_[1]["Event"]))
						setElementData(resourceRoot,"Ruel"..tostring(Row_[1]["Clan"]).."",tostring(Row_[1]["Ruel"]))
						setElementData(resourceRoot,"Kurucu"..tostring(Row_[1]["Clan"]).."",tostring(Row_[1]["Kurucu"]))	
					end
					if ( type(Row_1) == "table" and #Row_1 == 0 or not Row_1 ) then
						return false
					else
						setElementData(resourceRoot,"Banka"..tostring(Row_1[1]["Clan"]).."",tostring(Row_1[1]["Banka"]))
					end
					if ( type(Row_2) == "table" and #Row_2 == 0 or not Row_2 ) then
					    return false
				    else
					    setElementData(resourceRoot,"Level"..tostring(Row_2[1]["Clan"]).."",tostring(Row_2[1]["Level"]))
				    end				
				end
			else
				setElementData(plrs,"AccountName","")
				setElementData(plrs,"Clan","")
				setElementData(plrs,"RankPlayer","")
			end
		else
			setElementData(source,"AccountName","")
			setElementData(plrs,"Clan","")
			setElementData(plrs,"RankPlayer","")
		end
	end		
end)

addEventHandler("onPlayerLogin",root,function(_,account)
	setElementData(source,"AccountName",tostring(getAccountName(account)))
	local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(getAccountName(account)))
	if ( type(Row) == "table" and #Row == 0 or not Row ) then
		setElementData(source,"Clan","")
		setElementData(source,"RankPlayer","")
	else
		setElementData(source,"Clan",tostring(Row[1]["Clan"]))
		setElementData(source,"RankPlayer",tostring(Row[1]["RankPlayer"]))
		executeSQLQuery("UPDATE ClanSistemiUyeler SET State=? WHERE Account=?",tostring("Açık"),tostring(getAccountName(account)))
		executeSQLQuery("UPDATE ClanSistemiUyeler SET Name=? WHERE Account=?",tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")),tostring(getAccountName(account)))		
	end
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			setElementData(source,"Clan","")
			setElementData(source,"RankPlayer","")
		else
			local Row_ = executeSQLQuery("SELECT * FROM ClanSistemi WHERE Clan=?",tostring(Row[1]["Clan"]))
			local Row_1 = executeSQLQuery("SELECT * FROM ClanSistemiBanka WHERE Clan=?",tostring(Row[1]["Clan"]))
			local Row_2 = executeSQLQuery("SELECT * FROM ClanSistemiLevel WHERE Clan=?",tostring(Row[1]["Clan"]))			
			if ( type(Row_) == "table" and #Row_ == 0 or not Row_ ) then
				return false
			else
				setElementData(resourceRoot,"Event"..tostring(Row_[1]["Clan"]).."",tostring(Row_[1]["Event"]))
				setElementData(resourceRoot,"Ruel"..tostring(Row_[1]["Clan"]).."",tostring(Row_[1]["Ruel"]))
				setElementData(resourceRoot,"Kurucu"..tostring(Row_[1]["Clan"]).."",tostring(Row_[1]["Kurucu"]))	
			end
				if ( type(Row_1) == "table" and #Row_1 == 0 or not Row_1 ) then
					return false
				else
					setElementData(resourceRoot,"Banka"..tostring(Row_1[1]["Clan"]).."",tostring(Row_1[1]["Banka"]))
				end
				if ( type(Row_2) == "table" and #Row_2 == 0 or not Row_2 ) then
					return false
				else
					setElementData(resourceRoot,"Level"..tostring(Row_2[1]["Clan"]).."",tostring(Row_2[1]["Level"]))
				end				
		end	
end)

addEventHandler("onPlayerLogout",root,function()
	local accountName = getElementData(source,"AccountName")
	local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(accountName))
	if ( type(Row) == "table" and #Row == 0 or not Row ) then
		return false
	else
		executeSQLQuery("UPDATE ClanSistemiUyeler SET State=? WHERE Account=?",tostring("Kapalı"),tostring(accountName))
	end
	setElementData(source,"AccountName","")
	setElementData(source,"Clan","")
	setElementData(source,"RankPlayer","")
	triggerClientEvent(source,"DestroyGui",source)
end)

addEventHandler("onPlayerQuit",root,function()
	local accountName = getElementData(source,"AccountName")
	if ( accountName ~= "" ) then
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(accountName))
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			return false
		else
			executeSQLQuery("UPDATE ClanSistemiUyeler SET State=? WHERE Account=?",tostring("Kapalı"),tostring(accountName))
		end
	end
end)

addCommandHandler("kurucubug1",function(player)
local accountName = getElementData(player,"AccountName")
executeSQLQuery("UPDATE ClanSistemiUyeler SET RankPlayer=? WHERE Account=?",tostring("Kurucu"),tostring(accountName))
setElementData(player,"RankPlayer",tostring("Kurucu"))
end)

addEvent("CreateGroup",true)
addEventHandler("CreateGroup",root,function(Clan)
	local accountName = getElementData(source,"AccountName")
	local CheckClan = executeSQLQuery("SELECT * FROM ClanSistemi WHERE Clan=?",tostring(Clan))
	if ( type(CheckClan) == "table" and #CheckClan == 0 or not CheckClan ) then
	  if getPlayerMoney(source) >= 500000 then 
		executeSQLQuery("INSERT INTO ClanSistemi (Account,Clan,RankPlayer,Kurucu,Event,Ruel) VALUES (?,?,?,?,?,?)",tostring(accountName),tostring(Clan),tostring("Kurucu"),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")),tostring("Yok"),tostring("Yok"))
		executeSQLQuery("INSERT INTO ClanSistemiUyeler (Account,Clan,RankPlayer,State,Name) VALUES (?,?,?,?,?)",tostring(accountName),tostring(Clan),tostring("Kurucu"),tostring("Açık"),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")))
        executeSQLQuery("INSERT INTO ClanSistemiBanka (Clan,Banka) VALUES (?,?)",tostring(Clan),tostring("10000"))
        executeSQLQuery("INSERT INTO ClanSistemiLevel (Clan,Level) VALUES (?,?)",tostring(Clan),tostring("1"))	
        executeSQLQuery("INSERT INTO ClanSistemiRENK (Clan,R,G,B) VALUES (?,?,?,?)",tostring(Clan),math.random(1,255),math.random(1,255),math.random(1,255))		
		_outputChatBox("Clanı Başarıyla Oluşturdun | "..tostring(Clan).."",source,0,255,255,true)
		triggerEvent("onPlayerCreatedGroup",source,source,Clan)
		setElementData(resourceRoot,"Event"..Clan.."","Yok")
		setElementData(resourceRoot,"Ruel"..Clan.."","Yok")
		setElementData(resourceRoot,"Kurucu"..Clan.."",tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")))
		setElementData(resourceRoot,"Banka"..Clan.."","10000")
		setElementData(resourceRoot,"Level"..Clan.."","1")		
		setElementData(source,"Clan",tostring(Clan))
		setElementData(source,"RankPlayer",tostring("Kurucu"))
		takePlayerMoney(source,500000)
		--[[for _,plrs in ipairs (getElementsByType("player")) do
			getAllGroups(plrs)
		end--]]
	  else
	    _outputChatBox("Clan Kurabilmen İçin $500.000 İhtiyacın Var",source,255,0,0,true)
	  end
	else
		_outputChatBox("Bu Clan Adı Kullanılamaz",source,255,0,0,true)
	end
end)

function TopClans()
	local TopClan = {}
	local TopClan2 = {}
	local CreatTop = executeSQLQuery( "SELECT * FROM ClanSistemiLevel" )
	local CreatTop2 = executeSQLQuery( "SELECT * FROM ClanSistemiBanka" )
	for _, v in ipairs(CreatTop) do
		table.insert(TopClan,{name = v.Clan,score = v.Level})		
	end
	for _, v in ipairs(CreatTop2) do
		table.insert(TopClan2,{cname = v.Clan,banka = v.Banka})		
	end		
    local max_val, key = -math.huge
    for k, v in pairs(TopClan) do
        if tonumber(v.score) > max_val then
		    for x, y in pairs(TopClan2) do
			banka,cname = y.banka,y.cname
            max_val, name = tonumber(v.score), v.name
			if tostring(y.cname)==tostring(v.name) then
			Para = getElementData(resourceRoot,"Banka"..name.."")
			YeniPara = tonumber(banka+25000)
			executeSQLQuery("UPDATE ClanSistemiBanka SET Banka=? WHERE Clan=?",tonumber(YeniPara),tostring(name))
			setElementData(resourceRoot,"Banka"..name.."",tonumber(YeniPara))
            end
			end
        end
    end
	for _,plrs in ipairs (getElementsByType("player")) do
	    _outputChatBox("#ff7f00"..name.." #00ffffClanı "..max_val.." Puanla Birinci Oldu #ff0000| #00ff00Ödül: $25000",plrs,0,255,0,true)	 
	end		
end
setTimer(TopClans,3600000,0)

function LevelYenile()
	for _,plrs in ipairs (getElementsByType("player")) do
        local sourceAccount = getPlayerAccount ( plrs )
		if not isGuestAccount ( sourceAccount ) then
	        local Clan = getElementData(plrs,"Clan")
			if Clan then
			    local Puan = getElementData(resourceRoot,"Level"..Clan.."")
				if Puan then
				    triggerClientEvent(plrs,"LevelYenile",root,tonumber(Puan))
				end
			end
		end
	end
end	
setTimer(LevelYenile,60000,0)

function ClanPuanDuzelt()
	for _,v in ipairs (takeGroupsName()) do
	    executeSQLQuery("INSERT INTO ClanSistemiRENK (Clan,R,G,B) VALUES (?,?,?,?)",tostring(v.Clan),math.random(1,255),math.random(1,255),math.random(1,255))
	end
end
addCommandHandler("shlevelyap",ClanPuanDuzelt)

function ClanPuanDuzelt11(thePlayer,cmd,R,G,B)
    local R,G,B = tonumber(R),tonumber(G),tonumber(B)
	if R and G and B then
	    if R <= 255 and R >= 0 and G <= 255 and G >= 0 and B <= 255 and B >= 0 then	
        local Clan = getElementData(thePlayer,"Clan")
	    local rank = getElementData(thePlayer,"RankPlayer")
	        if rank=="Kurucu" then
		        executeSQLQuery("UPDATE ClanSistemiRENK  SET R=? WHERE Clan=?",tonumber(R),tostring(Clan))
		        executeSQLQuery("UPDATE ClanSistemiRENK  SET G=? WHERE Clan=?",tonumber(G),tostring(Clan))
		        executeSQLQuery("UPDATE ClanSistemiRENK  SET B=? WHERE Clan=?",tonumber(B),tostring(Clan))
				outputChatBox("Clan Rengi Değiştirildi",thePlayer,R,G,B,true)
	        end
		end
	end
end
addCommandHandler("clanrenk",ClanPuanDuzelt11)

function ClanPuanDuzelt1()
    local Clan = "[YsC]"
	    executeSQLQuery("UPDATE ClanSistemiLevel  SET Level=? WHERE Clan=?",tostring("100"),tostring(Clan))
        setElementData(resourceRoot,"Level"..Clan.."","100")
end
addCommandHandler("shlevelysc",ClanPuanDuzelt1)


addCommandHandler("banka",function(player)
Clan = getElementData(player,"Clan")
if Clan then
Para = getElementData(resourceRoot,"Banka"..Clan.."")
_outputChatBox(""..tonumber(Para).."",player,255,0,0,true)
end
end)

function BankaYenile()
if not getRandomPlayer() then return end
p = getRandomPlayer()
sourceAccount = getPlayerAccount ( p )
if not isGuestAccount ( sourceAccount ) then
Clan = getElementData(p,"Clan")
if Clan then
Para = getElementData(resourceRoot,"Banka"..Clan.."")
triggerClientEvent(p,"BankaYenile",root,tonumber(Para))
end
end
end
setTimer(BankaYenile,5000,0)

addEvent("ClanBankaYatir",true)
addEventHandler("ClanBankaYatir",root,function(Miktar)
money = getPlayerMoney(source)
    if tonumber(Miktar) <= tonumber(money) and tonumber(money) > 0 and tonumber(Miktar) > 0 then
	local Clan = getElementData(source,"Clan")
	Para = getElementData(resourceRoot,"Banka"..Clan.."")
	YeniPara = tonumber(Para+math.ceil(Miktar))
	executeSQLQuery("UPDATE ClanSistemiBanka SET Banka=? WHERE Clan=?",tonumber(YeniPara),tostring(Clan))
	setElementData(resourceRoot,"Banka"..Clan.."",tonumber(YeniPara))
	takePlayerMoney(source,tonumber(Miktar))
	end
end)

addEvent("ClanBankaCek",true)
addEventHandler("ClanBankaCek",root,function(Miktar)
	local Clan = getElementData(source,"Clan")
	Para = getElementData(resourceRoot,"Banka"..Clan.."")
	if tonumber(Para) >= tonumber(Miktar) and tonumber(Miktar) > 0 then
	YeniPara = tonumber(Para-math.ceil(Miktar))
	executeSQLQuery("UPDATE ClanSistemiBanka SET Banka=? WHERE Clan=?",tonumber(YeniPara),tostring(Clan))
	setElementData(resourceRoot,"Banka"..Clan.."",tonumber(YeniPara))
	givePlayerMoney(source,tonumber(Miktar))
	else
    outputChatBox("Clanın Yeterli Parası Yok",source,255,0,0,true)	
	end
end)

addEvent("UpGroups",true)
addEventHandler("UpGroups",root,function()
	for _,plrs in ipairs (getElementsByType("player")) do
		getAllGroups(plrs)
	end
	setElementData(resourceRoot,"CountGroups",getCountGroups())
	setElementData(resourceRoot,"CountMembers",getCountMembers())
end)

addEvent("UpMembers",true)
addEventHandler("UpMembers",root,function()
		getAllMembers(source,getElementData(source,"Clan"))
	setElementData(source,"OnlineInMyGroup",""..#getPlayersCountOnlineInMyGroup(source,getElementData(source,"Clan")).."")
	setElementData(source,"OfflineInMyGroup",""..#getPlayersCountOfflineInMyGroup(source,getElementData(source,"Clan")).."")
end)

addEvent("UpEvent",true)
addEventHandler("UpEvent",root,function(eventText)
	local Clan = getElementData(source,"Clan")
	executeSQLQuery("UPDATE ClanSistemi SET Event=? WHERE Clan=?",tostring(eventText),tostring(Clan))
	setElementData(resourceRoot,"Event"..Clan.."",tostring(eventText))
end)

addEvent("GetKurucuChange",true)
addEventHandler("GetKurucuChange",root,function(acc)
if ( acc and acc ~= false and acc ~= nil and type(acc) == "string" and string.len(acc) >= 1) then
	local Clan = getElementData(source,"Clan")
	executeSQLQuery("UPDATE ClanSistemi SET Kurucu=? WHERE Clan=?",tostring(acc),tostring(Clan))
	setElementData(resourceRoot,"Kurucu"..Clan.."",tostring(acc))
	outputChatBox("Kurucuyu Değiştirdin | "..tostring(acc).."",source,0,255,255,true)
else
	outputChatBox("Listeden Oyuncu Seçiniz",source,255,0,0,true)
end
end)

addEvent("UpRuel",true)
addEventHandler("UpRuel",root,function(ruelText)
	local Clan = getElementData(source,"Clan")
	executeSQLQuery("UPDATE ClanSistemi SET Ruel=? WHERE Clan=?",tostring(ruelText),tostring(Clan))
	setElementData(resourceRoot,"Ruel"..Clan.."",tostring(ruelText))
end)

addEvent("InvitePlayer",true)
addEventHandler("InvitePlayer",root,function(Account,NameDavetli)
if ( Account and Account ~= false and Account ~= nil and string.len(Account) >= 1 ) then
	local MyAcc = getElementData(source,"AccountName")
	if ( Account == MyAcc ) then
		outputChatBox("Kendine Davet Atamazsın",source,255,0,0,true)
		return
	end
	
	local Clan = getElementData(source,"Clan")
	local Puan = getElementData(resourceRoot,"Level"..Clan.."")
	
	if tonumber(Puan) < 1000 then
	    if #getPlayersCountInMyGroup(source,Clan) < 20 then
		    local Davetli_Oyuncu = getPlayerFromAccount(Account)
		    local Clan_ = getElementData(source,"Clan")
		    local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(Account))
		    local Row_ = executeSQLQuery("SELECT * FROM ClanSistemiDavet WHERE Account=?",tostring(Account))
		    for i,v in ipairs (Row_) do
			    if ( v.Clan == Clan_ ) then
				    outputChatBox("Daha Önceden Davet Gönderilmiş",source,255,0,0,true)
				    return
			    end
		    end
		    executeSQLQuery("INSERT INTO ClanSistemiDavet (Account,Name,Clan) VALUES (?,?,?)",tostring(Account),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")),tostring(Clan_))
		    outputChatBox("Davet Gönderildi",source,0,255,255,true)
		    outputChatBox(""..Clan_.." | Clanından Davet Geldi",Davetli_Oyuncu,0,255,255,true)				
		else
		    outputChatBox("Clanda En Fazla 25 Kişi Olabilir",source,255,0,0,true)
	    end
	elseif tonumber(Puan) >= 1000 and tonumber(Puan) < 5000 then
	    if #getPlayersCountInMyGroup(source,Clan) < 30 then
		    local Davetli_Oyuncu = getPlayerFromAccount(Account)
		    local Clan_ = getElementData(source,"Clan")
		    local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(Account))
		    local Row_ = executeSQLQuery("SELECT * FROM ClanSistemiDavet WHERE Account=?",tostring(Account))
		    for i,v in ipairs (Row_) do
			    if ( v.Clan == Clan_ ) then
				    outputChatBox("Daha Önceden Davet Gönderilmiş",source,255,0,0,true)
				    return
			    end
		    end
		    executeSQLQuery("INSERT INTO ClanSistemiDavet (Account,Name,Clan) VALUES (?,?,?)",tostring(Account),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")),tostring(Clan_))
		    outputChatBox("Davet Gönderildi",source,0,255,255,true)
		    outputChatBox(""..Clan_.." | Clanından Davet Geldi",Davetli_Oyuncu,0,255,255,true)				
	    else
		    outputChatBox("Clanda En Fazla 25 Kişi Olabilir",source,255,0,0,true)
		end
	elseif tonumber(Puan) >= 5000 then
	    if #getPlayersCountInMyGroup(source,Clan) < 40 then
		    local Davetli_Oyuncu = getPlayerFromAccount(Account)
		    local Clan_ = getElementData(source,"Clan")
		    local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(Account))
		    local Row_ = executeSQLQuery("SELECT * FROM ClanSistemiDavet WHERE Account=?",tostring(Account))
		    for i,v in ipairs (Row_) do
			    if ( v.Clan == Clan_ ) then
				    outputChatBox("Daha Önceden Davet Gönderilmiş",source,255,0,0,true)
				    return
			    end
		    end
		    executeSQLQuery("INSERT INTO ClanSistemiDavet (Account,Name,Clan) VALUES (?,?,?)",tostring(Account),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")),tostring(Clan_))
		    outputChatBox("Davet Gönderildi",source,0,255,255,true)
		    outputChatBox(""..Clan_.." | Clanından Davet Geldi",Davetli_Oyuncu,0,255,255,true)	 	 
	    else
		    outputChatBox("Clanda En Fazla 30 Kişi Olabilir",source,255,0,0,true)
		end
	end	
	else
        outputChatBox("Listeden Oyuncu Seçiniz",source,255,0,0,true)	
end
end)

addEvent("ViewMyInvite",true)
addEventHandler("ViewMyInvite",root,function()
	getAllInvites(source,getElementData(source,"AccountName"))
end)

addEvent("InviteAgre",true)
addEventHandler("InviteAgre",root,function(Clan,acc,name)
	if ( Clan and Clan ~= false and Clan ~= nil and string.len(Clan) >= 3 ) then
		local Row = executeSQLQuery("SELECT * FROM ClanSistemi WHERE Clan=?",tostring(Clan))
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			outputChatBox("Böyle Bir Clan Bulunamadı",source,255,0,0,true)
			return
		end
		if ( Row[1]["Clan"] == getElementData(source,"Clan") ) then
			outputChatBox("Zaten Bu Clandasın",source,255,0,0,true)
			return
		end
		
	    local Puan = getElementData(resourceRoot,"Level"..Clan.."")
	
	    if tonumber(Puan) < 1000 then
	        if #getPlayersCountInMyGroup(source,Clan) < 20 then			
		        local accountName = getElementData(source,"AccountName")
		        executeSQLQuery("INSERT INTO ClanSistemiUyeler (Account,Clan,RankPlayer,State,Name) VALUES (?,?,?,?,?)",tostring(accountName),tostring(Clan),tostring("Üye"),tostring("Açık"),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")))
		        executeSQLQuery("DELETE FROM ClanSistemiDavet WHERE Clan =? AND Account=? AND Name=?",tostring(Clan),tostring(acc),tostring(name))
		        setElementData(source,"Clan",tostring(Clan))
		        setElementData(source,"RankPlayer",tostring("Üye"))
		        getAllInvites(source,accountName)	
			else
		        outputChatBox("Bu Clan Dolu",source,255,0,0,true)				
			end
		elseif tonumber(Puan) >= 1000 and tonumber(Puan) < 5000 then
	        if #getPlayersCountInMyGroup(source,Clan) < 30 then
		        local accountName = getElementData(source,"AccountName")
		        executeSQLQuery("INSERT INTO ClanSistemiUyeler (Account,Clan,RankPlayer,State,Name) VALUES (?,?,?,?,?)",tostring(accountName),tostring(Clan),tostring("Üye"),tostring("Açık"),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")))
		        executeSQLQuery("DELETE FROM ClanSistemiDavet WHERE Clan =? AND Account=? AND Name=?",tostring(Clan),tostring(acc),tostring(name))
		        setElementData(source,"Clan",tostring(Clan))
		        setElementData(source,"RankPlayer",tostring("Üye"))
		        getAllInvites(source,accountName)
			else
		        outputChatBox("Bu Clan Dolu",source,255,0,0,true)				
			end
	    elseif tonumber(Puan) >= 5000 then
	        if #getPlayersCountInMyGroup(source,Clan) < 40 then
		        local accountName = getElementData(source,"AccountName")
		        executeSQLQuery("INSERT INTO ClanSistemiUyeler (Account,Clan,RankPlayer,State,Name) VALUES (?,?,?,?,?)",tostring(accountName),tostring(Clan),tostring("Üye"),tostring("Açık"),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")))
		        executeSQLQuery("DELETE FROM ClanSistemiDavet WHERE Clan =? AND Account=? AND Name=?",tostring(Clan),tostring(acc),tostring(name))
		        setElementData(source,"Clan",tostring(Clan))
		        setElementData(source,"RankPlayer",tostring("Üye"))
		        getAllInvites(source,accountName)
			else
		        outputChatBox("Bu Clan Dolu",source,255,0,0,true)	
			end
		end
	end
end)

addEvent("DeletedMyInvite",true)
addEventHandler("DeletedMyInvite",root,function(Clan,acc,name)
	if ( Clan and Clan ~= false and Clan ~= nil and string.len(Clan) >= 3 ) then
		executeSQLQuery("DELETE FROM ClanSistemiDavet WHERE Clan =? AND Account=? AND Name=?",tostring(Clan),tostring(acc),tostring(name))
		getAllInvites(source,getElementData(source,"AccountName"))
	end
end)

addEvent("GiveRank",true)
addEventHandler("GiveRank",root,function(acc,GiveRank)
	if ( acc and acc ~= false and acc ~= nil and type(acc) == "string" and string.len(acc) >= 1 and GiveRank ) then
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(acc))
		local MyRank = getElementData(source,"RankPlayer")
		local MyAcc = getElementData(source,"AccountName")
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			outputChatBox("Oyuncu Bulunamadı",source,255,0,0,true)
		else
			local PlayerToGiveRank = Row[1]["RankPlayer"]
			if ( acc == MyAcc ) then 
				outputChatBox("Kendi Yetkini Değiştiremezsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Editör" or MyRank == "Üye" ) then 
			   outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yardımcı" and PlayerToGiveRank == "Kurucu" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yardımcı" and PlayerToGiveRank == "Yönetici" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yardımcı" and PlayerToGiveRank == "Yardımcı" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end	
			if ( MyRank == "Yardımcı" and GiveRank == "Kurucu" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yardımcı" and GiveRank == "Yönetici" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yardımcı" and GiveRank == "Yardımcı" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end			
			if ( MyRank == "Yönetici" and GiveRank == "Kurucu" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yönetici" and PlayerToGiveRank == "Kurucu" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yönetici" and GiveRank == "Yönetici" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yönetici" and PlayerToGiveRank == "Yönetici" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end			
			executeSQLQuery("UPDATE ClanSistemiUyeler SET RankPlayer=? WHERE Account=?",tostring(GiveRank),tostring(acc))
			outputChatBox("Yetki Verildi",source,0,255,255,true)
			getAllMembers(source,getElementData(source,"Clan"))
			local plr = getPlayerFromAccount(acc)
			if not( plr ) then
				return
			end
			setElementData(plr,"RankPlayer",tostring(GiveRank))
		end
	else
		outputChatBox("Listeden Oyuncu Seçiniz",source,255,0,0,true)
	end
end)

addEvent("GetKick",true)
addEventHandler("GetKick",root,function(acc)
	if ( acc and acc ~= false and acc ~= nil and type(acc) == "string" and string.len(acc) >= 1 ) then
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(acc))
		local MyRank = getElementData(source,"RankPlayer")
		local MyAcc = getElementData(source,"AccountName")
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			outputChatBox("Oyuncu Bulunamadı",source,255,0,0,true)
		else
			local PlayerRankToGiveKick = Row[1]["RankPlayer"]
			if ( acc == MyAcc ) then 
				outputChatBox("Kendini Clandan Atamazsın",source,255,0,0,true)
				return
			end
			if ( MyRank == "Üye" ) then
			    outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Editör" ) then
			    outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yardımcı" ) then
			    outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end
			if ( MyRank == "Yönetici" ) then
			    outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end	
			if ( MyRank == "Kurucu" and PlayerRankToGiveKick == "Kurucu" ) then 
				outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
				return
			end			
			executeSQLQuery("DELETE FROM ClanSistemiUyeler WHERE Account = '"..tostring(acc).."'")
			if ( getElementData(source,"Clan") ~= "" ) then
				getAllMembers(source,getElementData(source,"Clan"))
			end			
			setElementData(getPlayerFromAccount(acc),"RankPlayer",tostring(""))
			setElementData(getPlayerFromAccount(acc),"Clan",tostring(""))
		end
	end
end)

addEvent("LeaveGroup",true)
addEventHandler("LeaveGroup",root,function()
	local acc = getPlayerAccount(source)
	if ( acc ) then
		if not ( isGuestAccount(acc) ) then
			local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Account=?",tostring(getAccountName(acc)))
			if ( type(Row) == "table" and #Row == 0 or not Row ) then
				outputChatBox("Başka Clana Gitmek İçin Clanından Çıkmalısın",source,255,0,0,true)
			else
				local RowCheckDeleted = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Clan=?",tostring(Row[1]["Clan"]))
				if ( type(RowCheckDeleted) == "table" and #RowCheckDeleted == 1 ) then
					triggerEvent("onPlayerDeletedGroup",source,source,Row[1]["Clan"])
					executeSQLQuery("DELETE FROM ClanSistemiError WHERE Clan = '"..tostring(Row[1]["Clan"]).."'")
					executeSQLQuery("DELETE FROM ClanSistemiDavet WHERE Clan = '"..tostring(Row[1]["Clan"]).."'")
					executeSQLQuery("DELETE FROM ClanSistemi WHERE Clan = '"..Row[1]["Clan"].."'")
					executeSQLQuery("DELETE FROM ClanSistemiUyeler WHERE Account = '"..tostring(Row[1]["Account"]).."'")
					executeSQLQuery("DELETE FROM ClanSistemiBanka WHERE Clan = '"..tostring(Row[1]["Clan"]).."'")	
					executeSQLQuery("DELETE FROM ClanSistemiLevel WHERE Clan = '"..tostring(Row[1]["Clan"]).."'")	
					executeSQLQuery("DELETE FROM ClanSistemiRENK WHERE Clan = '"..tostring(Row[1]["Clan"]).."'")					
					outputChatBox("Clanını Sildin",source,0,255,255,true)
					setElementData(source,"RankPlayer","")
					setElementData(source,"Clan","")
					--[[for _,plrs in ipairs (getElementsByType("player")) do
			        getAllGroups(plrs)
	              	end--]]
				else
					executeSQLQuery("DELETE FROM ClanSistemiUyeler WHERE Account = '"..tostring(Row[1]["Account"]).."'")
				    outputChatBox("Clandan Ayrıldın",source,0,255,255,true)
					setElementData(source,"RankPlayer","")
					setElementData(source,"Clan","")
					--[[for _,plrs in ipairs (getElementsByType("player")) do
			        getAllGroups(plrs)
	             	end--]]
				end
			end
		else
			outputChatBox("Bu Yetkiye Sahip Değilsin",source,255,0,0,true)
		end
	end
end)

addEvent("ViewMembersSelectGroup",true)
addEventHandler("ViewMembersSelectGroup",root,function(Clan_Select)
	getAllMembersSelect(source,Clan_Select)
end)

addEvent("ViewListMoneyMyGroup",true)
addEventHandler("ViewListMoneyMyGroup",root,function(MyGroupName)
	getAllMoneyGroup(source,MyGroupName)
end)

addEvent("AddMoney",true)
addEventHandler("AddMoney",root,function(amount)
	local MyMoney = getPlayerMoney(source)
	if ( MyMoney >= tonumber(amount) ) then
		takePlayerMoney(source,tonumber(amount))
		local Tick = math.random(100,170) * math.random(170,190) / math.random(2,8)
		local accountName = getElementData(source,"AccountName")
		local MyRank = getElementData(source,"RankPlayer")
		local MyGroup = getElementData(source,"Clan")
		insertMoneyToSql = executeSQLQuery("INSERT INTO ClanSistemiError (Account,Name,RankPlayer,Clan,Amount,Tick) VALUES (?,?,?,?,?,?)",tostring(accountName),tostring(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")),tostring(MyRank),tostring(MyGroup),tonumber(amount),tonumber(math.floor(Tick)))
		outputChatBox("Başarıyla Parayı Yatırdın",source,0,255,255,true)
		if ( insertMoneyToSql ~= false ) then
			getAllMoneyGroup(source,MyGroup)
		end
	else
		outputChatBox("Yeterli Paraya Sahip Değilsin",source,255,0,0,true)
	end
end)

addEvent("GiveMoneyMySelf",true)
addEventHandler("GiveMoneyMySelf",root,function(name,amount,account,tick)
	if ( tostring(name) and name ~= nil and name ~= false and tonumber(amount) and amount ~= nil and amount ~= false and tostring(account) and account ~= nil and account ~= false and tonumber(tick) and tick ~= nil and tick ~= false ) then
		givePlayerMoney(source,tonumber(amount))
		outputChatBox("Parayı Başarıyla Çektin | [ "..amount.." ]",source,0,255,255,true)
		deletedAmountOfSql = executeSQLQuery("DELETE FROM ClanSistemiError WHERE Tick=? AND Account=? AND Amount=? AND Clan=? AND Name=?",tonumber(tick),tostring(account),tonumber(amount),tostring(getElementData(source,"Clan")),tostring(name))
		if ( deletedAmountOfSql ~= false ) then
			getAllMoneyGroup(source,getElementData(source,"Clan"))
		else
			outputChatBox("Böyle Bir Para Bulunamadı",source,255,0,0,true)
		end
	else
		outputChatBox("Listeden Para Seçiniz",source,255,0,0,true)
	end
end)

addEvent("GiveMoneyAllOnline",true)
addEventHandler("GiveMoneyAllOnline",root,function(name,amount,account,tick)
	if ( tostring(name) and name ~= nil and name ~= false and tonumber(amount) and amount ~= nil and amount ~= false and tostring(account) and account ~= nil and account ~= false and tonumber(tick) and tick ~= nil and tick ~= false ) then
		local plrsOnline = getPlayersOnlineInMyGroup(source,getElementData(source,"Clan"))
		local countPlrsOnline = getPlayersCountOnlineInMyGroup(source,getElementData(source,"Clan"))
		local amount_ = math.floor(tonumber(amount)/tonumber(#countPlrsOnline))
		givePlayerMoney(plrsOnline,tonumber(amount_))
		outputChatBox("Clanında Para Dağıtıldı | [ "..amount_.." ]",plrsOnline,0,255,255,true)
		deletedAmountOfSql = executeSQLQuery("DELETE FROM ClanSistemiError WHERE Tick=? AND Account=? AND Amount=? AND Clan=? AND Name=?",tonumber(tick),tostring(account),tonumber(amount),tostring(getElementData(source,"Clan")),tostring(name))
		if ( deletedAmountOfSql ~= false ) then
			getAllMoneyGroup(plrsOnline,getElementData(source,"Clan"))
		else
			outputChatBox("Böyle Bir Para Bulunamadı",source,255,0,0,true)
		end
	else
		outputChatBox("Listeden Para Seçiniz",source,255,0,0,true)
	end
end)

addCommandHandler("Clan", function(thePlayer, cmd, ...)
	local message = table.concat ( { ... }, " " )
	local ClanAdi = getElementData(thePlayer,"Clan")
	ClanSohbetTable = {}
	r, g, b = getPlayerNametagColor(thePlayer)
	outputServerLog("CLAN CHAT: " .. getPlayerName (thePlayer) .. ": " .. message .. " | ("..ClanAdi..")")	
	for _,v in ipairs (takeMembers(ClanAdi)) do
		table.insert(ClanSohbetTable,{NameMember = v.Account,})
		
		if v.Account then
			local account = getAccount(v.Account)
			if account and getAccountPlayer(account) then
				local player = getAccountPlayer(account)
				outputChatBox ("#00bfff("..ClanAdi..") " .. getPlayerName (thePlayer) .. ":#ffFFff " .. message, player, r, g, b, true)
			end
		end
	end
end)

function takeGroupsName()
	local Row = executeSQLQuery("SELECT * FROM ClanSistemi")
	if ( type(Row) == "table" and #Row == 0 or not Row ) then
		return {}
	else
		return Row
	end
end

function getAllGroups(plr)
	if ( plr ) then
		local TableGroups = {}
		for _,v in ipairs (takeGroupsName()) do
			table.insert(TableGroups,{groupName = v.Clan,ownerName = v.Kurucu ,})
		end
		triggerClientEvent(plr,"upGroupsToList",plr,TableGroups)
	end
end

function takeMembers(groupName_)
	if ( groupName_ and type(groupName_) == "string" ) then
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Clan=?",tostring(groupName_))
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			return {}
		else
			return Row
		end
	end
end

function getAllMembers(plr,groupName_)
	if ( plr and groupName_ and type(groupName_) == "string" ) then
		local TableMembers = {}
		for _,v in ipairs (takeMembers(groupName_)) do
			table.insert(TableMembers,{NameMember = v.Name,AccountMember = v.Account ,RankMember = v.RankPlayer ,StateMember = v.State,LastLoginMember = getAccountData(getAccount(v.Account),"lastlogin") or "Bilinmiyor",})
		end
		table.sort(TableMembers, function(a,b)
		    return 
			    (a.RankMember) < (b.RankMember)						
		end)
		triggerClientEvent(plr,"upMembersToList",plr,TableMembers)
	end
end

function takeMembersSelect(groupName_Select)
	if ( groupName_Select and type(groupName_Select) == "string" ) then
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Clan=?",tostring(groupName_Select))
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			return {}
		else
			return Row
		end
	end
end

function getAllMembersSelect(plr,groupName_Select)
	if ( plr and groupName_Select and type(groupName_Select) == "string" ) then
		local TableMembersSelect = {}
		for _,v in ipairs (takeMembers(groupName_Select)) do
			table.insert(TableMembersSelect,{NameMembers = v.Name,})
		end
		triggerClientEvent(plr,"upMembersSelectToList",plr,TableMembersSelect)
	end
end

function takeInvites(account)
	if ( account and type(account) == "string" ) then
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiDavet WHERE Account=?",tostring(account))
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			return {}
		else
			return Row
		end
	end
end

function getAllInvites(plr,account)
	if ( plr and account and type(account) == "string" ) then
		local TableInvites = {}
		for _,v in ipairs (takeInvites(account)) do
			table.insert(TableInvites,{GroupNamePlrSendInvite = v.Clan,NamePlrSendInvite = v.Name ,AccountPlrSendInvite = v.Account,})
		end
		triggerClientEvent(plr,"upMyInviteToList",plr,TableInvites)
	end
end

function takeMoneyGroup(Clan_)
	if ( Clan_ and type(Clan_) == "string" ) then
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiError WHERE Clan=?",tostring(Clan_))
		if ( type(Row) == "table" and #Row == 0 or not Row ) then
			return {}
		else
			return Row
		end
	end
end

function getAllMoneyGroup(plr,Clan_)
	if ( plr and Clan_ and type(Clan_) == "string" ) then
		local TableMoney = {}
		for _,v in ipairs (takeMoneyGroup(Clan_)) do
			table.insert(TableMoney,{AmountPlayer = v.Amount,NamePlayer = v.Name ,AccountPlayer = v.Account,Rank = v.RankPlayer,Tick = v.Tick,})
		end
		triggerClientEvent(plr,"upMyGroupMoneyToList",plr,TableMoney)
	end
end

function getPlayerFromAccount(account)
	if ( account and type(account) == "string" ) then
		for _,plr in ipairs (getElementsByType("player")) do
			local acc = getPlayerAccount(plr)
			if ( acc ) then
				if ( getAccountName(acc) == tostring(account) ) then
					return plr
				end
			end
		end
	end
	return false
end

function getCountGroups()
	local Count = {}
	local Row = executeSQLQuery("SELECT * FROM ClanSistemi")
	for _,check in ipairs(Row) do
		if ( #check.Clan == 0 ) then
			return
		end
	end
	for _,groupsName in ipairs (Row) do
		Count[#Count + 1] = groupsName.Clan
	end
	return ""..#Count..""
end

function getCountMembers()
	local Count = {}
	local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler")
	for _,check in ipairs(Row) do
		if ( #check.Account == 0 ) then
			return
		end
	end
	for _,members in ipairs (Row) do
		Count[#Count + 1] = members.Account
	end
	return ""..#Count..""
end

function getPlayersOnlineInMyGroup(plr,groupName_)
	if ( plr and groupName_ and type(groupName_) == "string" ) then
		for _,plrs in ipairs(getElementsByType("player")) do
			if ( getElementData(plrs,groupName_) == getElementData(plr,groupName_) ) then
				return plrs
			end
		end
	end
	return false
end

function getPlayersCountOnlineInMyGroup(plr,groupName_)
	if ( plr and groupName_ and type(groupName_) == "string" ) then
		local PlayersOnline = {}
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Clan=?",tostring(groupName_))
		for _,v in ipairs(Row) do
			if ( v.State == tostring("Açık") ) then
				PlayersOnline[#PlayersOnline + 1] = v.State
			end
		end
		return PlayersOnline
	end
	return false
end

function getPlayersCountOfflineInMyGroup(plr,groupName_)
	if ( plr and groupName_ and type(groupName_) == "string" ) then
		local PlayersOffline = {}
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Clan=?",tostring(groupName_))
		for _,v in ipairs(Row) do
			if ( v.State == tostring("Kapalı") ) then
				PlayersOffline[#PlayersOffline + 1] = v.State
			end
		end
		return PlayersOffline
	end
	return false
end

function getPlayersCountInMyGroup(plr,groupName_)
	if ( plr and groupName_ and type(groupName_) == "string" ) then
		local PlayersCountSH = {}
		local Row = executeSQLQuery("SELECT * FROM ClanSistemiUyeler WHERE Clan=?",tostring(groupName_))
		for _,v in ipairs(Row) do
			if ( v.State == tostring("Kapalı") ) then
				PlayersCountSH[#PlayersCountSH + 1] = v.State
			end
			if ( v.State == tostring("Açık") ) then
				PlayersCountSH[#PlayersCountSH + 1] = v.State
			end
		end
		return PlayersCountSH
	end
	return false
end

function createTopSystem( player )
	if not isElement( player ) then
		return
	end
	local Top = {}
	local CreatTop = executeSQLQuery( "SELECT * FROM ClanSistemiLevel" )
	for i = 1, #CreatTop do
		table.insert(Top,{name = CreatTop[i].Clan,score = CreatTop[i].Level})
	end
	if #CreatTop >0 then
		table.sort(Top, function(a,b) return (tonumber(a.score)or 0) > (tonumber(b.score)or 0) end)
	setTimer(
	function()
		for k, data in ipairs(Top) do
			if k == 1 then
				triggerClientEvent (player,"deltTop",player)
			end	
			triggerClientEvent (player,"updateTop",player,tostring(data.name),tostring(data.score),tonumber(k))
			if k == 200 then
					table.remove(Top)
				break
			end
		end
	end,
		1500,
	1
	)
	end
end

addEvent("getTop", true)
addEventHandler("getTop", root, 
	function()
		createTopSystem( source )
	end
)

 

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