Jump to content

مشكلة


ryan112

Recommended Posts

 سلام عليكم شباب عملت لوحة  مود كلان بس حاطو في اف1 بس ماعم شتغل مود  شوفولي وين مشكلة

--Clan menu
Clan = {
    Button = {},
    Window = {},
	Gridlist = {},
	Edit = {},
	Memo = {}
}
Clan.Window[1] = guiCreateWindow(0, 232, 302, 421, "Clan panel", false)
guiWindowSetSizable(Clan.Window[1], false)
Clan.Window[2] = guiCreateWindow(361, 232, 250, 451, "Set player Rank", false)
guiWindowSetSizable(Clan.Window[2], false)
Clan.Window[3] = guiCreateWindow(361, 232, 250, 451, "Set player Rank", false)
guiWindowSetSizable(Clan.Window[3], false)

Clan.Gridlist[1] = guiCreateGridList(9, 19, 291, 352, false, Clan.Window[1])
local column = guiGridListAddColumn(Clan.Gridlist[1], "Players", 0.9)
if ( column ) then --If the column has been created, fill it with players
    for _,v in ipairs(getElementsByType("player"))do
        local row = guiGridListAddRow(Clan.Gridlist[1])
        local players = getPlayerName(v)
        guiGridListSetItemText(Clan.Gridlist[1],row,column,players,false,false)
    end
end
Clan.Button[1] = guiCreateButton(9, 377, 59, 36, "Add", false, Clan.Window[1])
Clan.Button[2] = guiCreateButton(126, 377, 51, 36, "Kick", false, Clan.Window[1])
Clan.Button[3] = guiCreateButton(68, 377, 58, 36, "Promote", false, Clan.Window[1])
Clan.Button[4] = guiCreateButton(177, 377, 54, 36, "Demote", false, Clan.Window[1])
Clan.Button[5] = guiCreateButton(231, 377, 54, 36, "Close", false, Clan.Window[1])
Clan.Button[6] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[2])
Clan.Button[7] = guiCreateButton(143, 62, 87, 23, "Promote", false, Clan.Window[2])
Clan.Button[8] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[3])
Clan.Button[9] = guiCreateButton(143, 62, 87, 23, "Demote", false, Clan.Window[3])
Clan.Edit[1] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[2])
Clan.Edit[2] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[3])

Clan.Memo[1] = guiCreateMemo(13, 97, 227, 344, "Avaible Ranks\n\nLeader\n\nCo Leader\n\nGuest", false, Clan.Window[2])
guiMemoSetReadOnly(Clan.Memo[1], true)

guiSetVisible(Clan.Window[1], false)
guiSetVisible(Clan.Window[2], false)
guiSetVisible(Clan.Window[3], false)
showCursor(false)
if getElementData(localPlayer, "clan.rank") == "leader" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Mohamed" then
guiSetEnabled(Clan.Button[3], true)
guiSetEnabled(Clan.Button[4], true)
else
guiSetEnabled(Clan.Button[3], false)
guiSetEnabled(Clan.Button[4], false)
end

function toggleClanControl( source )
if getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "[ET]Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" then
    if not guiGetVisible( Clan.Window[1] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[1], true )
        guiGridListClear ( Clan.Gridlist[1] )
        if ( column ) then
            guiGridListClear ( Clan.Gridlist[1] )
            for _,v in ipairs(getElementsByType("player"))do
                local row = guiGridListAddRow(Clan.Gridlist[1])
                local playerName = getPlayerName(v)
                guiGridListSetItemText(Clan.Gridlist[1],row,column,playerName,false,false)
            end
		end
		if getElementData(localPlayer, "clan.rank") == "leader" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "[ET]Danksta" then
			guiSetEnabled(Clan.Button[3], true)
			guiSetEnabled(Clan.Button[4], true)
		else
			guiSetEnabled(Clan.Button[3], false)
			guiSetEnabled(Clan.Button[4], false)
		end
    else
        showCursor ( false )
        guiSetVisible( Clan.Window[1], false )
    end
end
end
bindKey( "H", "down", toggleClanControl )
addCommandHandler("clan", toggleClanControl)

addEventHandler("onClientGUIClick", guiRoot,
function()
	if source == Clan.Button[1] then
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
		local team = getPlayerTeam(localPlayer)
		local teamName = getTeamName(team)
        if not playerName then
            guiGridListRemoveRow(row)
            return
        end
            triggerServerEvent("addToTeam", localPlayer,playerName,teamName)
		end
end)

addEventHandler("onClientGUIClick", guiRoot,
function()
	if source == Clan.Button[2] then
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
		local team = getPlayerTeam(localPlayer)
		local teamName = getTeamName(team)
        if not playerName then
            guiGridListRemoveRow(row)
            return
        end
            triggerServerEvent("kickFromTeam", localPlayer,playerName,teamName)
		end
end)

function closeClan()
	if guiGetVisible(Clan.Window[1]) then 
		guiSetVisible(Clan.Window[1],false)
		showCursor(false)
	end
end
addEventHandler ("onClientGUIClick", Clan.Button[5], closeClan, false)

function togglePromote( source )
-- Show the panel
    if not guiGetVisible( Clan.Window[2] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[2], true )
		guiMoveToBack( Clan.Window[1] )
    else
        showCursor ( true )
        guiSetVisible( Clan.Window[2], false )
    end
end
addEventHandler ( "onClientGUIClick", Clan.Button[3], togglePromote, false )

addEventHandler("onClientGUIClick",Clan.Button[7],
function()
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
        if not playerName then
        guiGridListRemoveRow(row)
        return
		end
    triggerServerEvent("promotePlayer",localPlayer,playerName,tostring(guiGetText(Clan.Edit[1])) or "Member")
	guiSetVisible( Clan.Window[2], false )
	showCursor ( true )
end,false)

function closeClan()
	if guiGetVisible(Clan.Window[2]) then 
		guiSetVisible(Clan.Window[2],false)
		showCursor(true)
	end
end
addEventHandler ("onClientGUIClick", Clan.Button[6], closeClan, false)

function toggleDemote( source )
-- Show the panel
    if not guiGetVisible( Clan.Window[2] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[2], true )
		guiMoveToBack( Clan.Window[1] )
    else
        showCursor ( true )
        guiSetVisible( Clan.Window[2], false )
    end
end
addEventHandler ( "onClientGUIClick", Clan.Button[4], toggleDemote, false )

addEventHandler("onClientGUIClick",Clan.Button[9],
function()
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
        if not playerName then
        guiGridListRemoveRow(row)
        return
		end
    triggerServerEvent("DemotePlayer",localPlayer,playerName,tostring(guiGetText(Clan.Edit[2])) or "Member")
	guiSetVisible( Clan.Window[3], false )
	showCursor ( true )
end,false)


addEventHandler ("onClientGUIClick", Clan.Button[8], closeClan, false)

 

Link to comment
1 hour ago, #Himoo said:

اكتب في اف 8
 


debugscript 3

وقولنا ايش يجيك بالظبط

warning freeroam/DizzyRoom_Client.lua"1707.Bad argument @ 'getPlayerFroNmay[Expected string at argument 1, got player] [DUPX5

هي ملف لينت تبع اف 1 موجود بقلبو ملف اكواد لكلان

CONTROL_MARGIN_RIGHT = 5
LINE_MARGIN = 5
LINE_HEIGHT = 16

g_Root = getRootElement()
g_ResRoot = getResourceRootElement(getThisResource())
g_Me = getLocalPlayer()
server = createServerCallInterface()
guiSetInputMode("no_binds_when_editing")

---------------------------
-- Set skin window
---------------------------
function skinInit()
	setControlNumber(wndSkin, 'skinid', getElementModel(g_Me))
end

function showSkinID(leaf)
	if leaf.id then
		setControlNumber(wndSkin, 'skinid', leaf.id)
	end
end

function applySkin()
	local skinID = getControlNumber(wndSkin, 'skinid')
	if skinID then
		server.setMySkin(skinID)
	end
end

wndSkin = {
	'wnd',
	text = 'Character',
	width = 250,
	x = -20,
	y = 0.3,
	controls = {
		{
			'lst',
			id='skinlist',
			width=230,
			height=290,
			columns={
				{text='Skin', attr='name'}
			},
			rows={xml='lists/DizzyRoam_Skins.xml', attrs={'id', 'name'}},
			onitemclick=showSkinID,
			onitemdoubleclick=applySkin
		},
		{'txt', id='skinid', text='', width=50},
		{'btn', id='set', onclick=applySkin},
		{'btn', id='close', closeswindow=true}
	},
	oncreate = skinInit
}



function setSkinCommand(cmd, skin)
    skin = skin and tonumber(skin)
    if skin then
        server.setMySkin(skin)
        fadeCamera(true)
        closeWindow(wndSpawnMap)
        closeWindow(wndSetPos)
    end
end
addCommandHandler('setskin', setSkinCommand)
addCommandHandler('ss', setSkinCommand)


---------------------------
-- Walking Style Window
---------------------------
 
function applyWalkStyle( leaf )
    if type( leaf ) ~= 'table' then
        leaf = getSelectedGridListLeaf( wndWalking, 'walkStyle' )
        if not leaf then
            return
        end
    end
    server.setPedWalkingStyle( g_Me, leaf.id )
end
 
function stopWalkStyle()
    server.setPedWalkingStyle( g_Me, 0 )
end
 
wndWalking = {
    'wnd',
    text = 'Walking style',
    width = 250,
    controls = {
        {
            'lst',
            id = 'walkStyle',
            width = 230,
            height = 290,
            columns = {
                { text = 'Walking', attr = 'name' }
            },
            rows = { xml = 'lists/DizzyRoam_Walking.xml', attrs = { 'id', 'name' } },
            onitemdoubleclick = applyWalkStyle
        },
        { 'btn', id = 'set', onclick = applyWalkStyle },
        { 'btn', id = 'stop', onclick = stopWalkStyle },
        { 'btn', id = 'close', closeswindow = true }
    }
}
 
function setWalkStyleCommand( cmd, id )
    id = id and tonumber( id )
    if id then
        server.setPedWalkingStyle( id )
    end
end
addCommandHandler( 'setwalkstyle', setWalkStyleCommand )
addCommandHandler( 'walkstyle', setWalkStyleCommand )

---------------------------
-- Fighting style window
---------------------------
wndFighting = {
	'wnd',
	text = 'Fighting style',
	width = 250,
	x = -20,
	y = 0.3,
	controls = {
		{
			'lst',
			id='fighting',
			width=230,
			height=290,
			columns={
				{text='style', attr='name'}
			},
			rows={xml='lists/DizzyRoam_Fighting.xml', attrs={'name'}},
			expandlastlevel=false,
			onitemdoubleclick=applyFightingStyle
		},
		{'btn', id='Set', onclick=applyFightingStyle},
		{'btn', id='Close', closeswindow=true}
	}
}


addCommandHandler('setstyle',
	function(cmd, style)
		style = style and tonumber(style)
		if style then
			server.setPedFightingStyle(g_Me, style)
		end
	end
)
---------------------------
--- Set animation window
---------------------------

function applyAnimation(leaf)
	if type(leaf) ~= 'table' then
		leaf = getSelectedGridListLeaf(wndAnim, 'animlist')
		if not leaf then
			return
		end
	end
	server.setPedAnimation(g_Me, leaf.parent.name, leaf.name, true, true)
end

function stopAnimation()
	server.setPedAnimation(g_Me, false)
end

wndAnim = {
	'wnd',
	text = 'Set animation',
	width = 250,
	x = -20,
	y = 0.3,
	controls = {
		{
			'lst',
			id='animlist',
			width=230,
			height=290,
			columns={
				{text='Animation', attr='name'}
			},
			rows={xml='lists/DizzyRoam_Animations.xml', attrs={'name'}},
			expandlastlevel=false,
			onitemdoubleclick=applyAnimation
		},
		{'btn', id='set', onclick=applyAnimation},
		{'btn', id='stop', onclick=stopAnimation},
		{'btn', id='close', closeswindow=true}
	}
}

addCommandHandler('anim',
	function(command, lib, name)
		server.setPedAnimation(g_Me, lib, name, true, true)
	end
)

---------------------------
-- Weapon window
---------------------------

function addWeapon(leaf, amount)
	if type(leaf) ~= 'table' then
		leaf = getSelectedGridListLeaf(wndWeapon, 'weaplist')
		amount = getControlNumber(wndWeapon, 'amount')
		if not amount or not leaf then
			return
		end
	end
	server.giveMeWeapon(leaf.id, amount)
end

wndWeapon = {
	'wnd',
	text = 'Weapons',
	width = 250,
	controls = {
		{
			'lst',
			id='weaplist',
			width=230,
			height=280,
			columns={
				{text='Weapon', attr='name'}
			},
			rows={xml='lists/DizzyRoam_Weapons.xml', attrs={'id', 'name'}},
			onitemdoubleclick=function(leaf) addWeapon(leaf, 500) end
		},
		{'br'},
		{'txt', id='amount', text='500', width=60},
		{'btn', id='add', onclick=addWeapon},
		{'btn', id='close', closeswindow=true}
	}
}

function giveWeaponCommand(cmd, weapon, amount)
	weapon = tonumber(weapon) or getWeaponIDFromName(weapon)
	if not weapon then
		return
	end
	amount = amount and tonumber(amount) or 500
	server.giveMeWeapon(math.floor(weapon), amount)
end
addCommandHandler('give', giveWeaponCommand)
addCommandHandler('wp', giveWeaponCommand)

---------------------------
-- Fighting style
---------------------------

addCommandHandler('setstyle',
	function(cmd, style)
		style = style and tonumber(style)
		if style then
			server.setPedFightingStyle(g_Me, style)
		end
	end
)

---------------------------
-- Clothes window
---------------------------
function clothesInit()
	if getElementModel(g_Me) ~= 0 then
		errMsg('You must have the CJ skin in order to change clothes.')
		closeWindow(wndClothes)
		return
	end
	if not g_Clothes then
		triggerServerEvent('onClothesInit', g_Me)
	end
end

addEvent('onClientClothesInit', true)
addEventHandler('onClientClothesInit', g_Root,
	function(clothes)
		g_Clothes = clothes.allClothes
		for i,typeGroup in ipairs(g_Clothes) do
			for j,cloth in ipairs(typeGroup.children) do
				if not cloth.name then
					cloth.name = cloth.model .. ' - ' .. cloth.texture
				end
				cloth.wearing =
					clothes.playerClothes[typeGroup.type] and
					clothes.playerClothes[typeGroup.type].texture == cloth.texture and
					clothes.playerClothes[typeGroup.type].model == cloth.model
					or false
			end
			table.sort(typeGroup.children, function(a, b) return a.name < b.name end)
		end
		bindGridListToTable(wndClothes, 'clothes', g_Clothes, false)
	end
)

function clothListClick(cloth)
	setControlText(wndClothes, 'addremove', cloth.wearing and 'remove' or 'add')
end

function applyClothes(cloth)
	if not cloth then
		cloth = getSelectedGridListLeaf(wndClothes, 'clothes')
		if not cloth then
			return
		end
	end
	if cloth.wearing then
		cloth.wearing = false
		setControlText(wndClothes, 'addremove', 'add')
		server.removePedClothes(g_Me, cloth.parent.type)
	else
		local prevClothIndex = table.find(cloth.siblings, 'wearing', true)
		if prevClothIndex then
			cloth.siblings[prevClothIndex].wearing = false
		end
		cloth.wearing = true
		setControlText(wndClothes, 'addremove', 'remove')
		server.addPedClothes(g_Me, cloth.texture, cloth.model, cloth.parent.type)
	end
end

wndClothes = {
	'wnd',
	text = 'Clothes',
	x = -20,
	y = 0.3,
	width = 350,
	controls = {
		{
			'lst',
			id='clothes',
			width=330,
			height=390,
			columns={
				{text='Clothes', attr='name', width=0.6},
				{text='Wearing', attr='wearing', enablemodify=true, width=0.3}
			},
			rows={
				{name='Retrieving clothes list...'}
			},
			onitemclick=clothListClick,
			onitemdoubleclick=applyClothes
		},
		{'br'},
		{'btn', text='add', id='addremove', width=60, onclick=applyClothes},
		{'btn', id='close', closeswindow=true}
	},
	oncreate = clothesInit
}

function addClothesCommand(cmd, type, model, texture)
	type = type and tonumber(type)
	if type and model and texture then
		server.addPedClothes(g_Me, texture, model, type)
	end
end
addCommandHandler('addclothes', addClothesCommand)
addCommandHandler('ac', addClothesCommand)

function removeClothesCommand(cmd, type)
	type = type and tonumber(type)
	if type then
		server.removePlayerClothes(g_Me, type)
	end
end
addCommandHandler('removeclothes', removeClothesCommand)
addCommandHandler('rc', removeClothesCommand)

---------------------------
-- Stats window
---------------------------

function initStats()
	applyToLeaves(getGridListCache(wndStats, 'statslist'), function(leaf) leaf.value = getPedStat(g_Me, leaf.id) end)
end

function applyStat()
	local leaf = getSelectedGridListLeaf(wndStats, 'statslist')
	if not leaf then
		return
	end
	local value = getControlNumber(wndStats, 'statval')
	if not value then
		return
	end
	leaf.value = value
end

wndStats = {
	'wnd',
	text = 'Stats',
	width = 300,
	x = -20,
	y = 0.3,
	controls = {
		{
			'lst',
			id='statslist',
			width=280,
			columns={
				{text='Stat', attr='name', width=0.6},
				{text='Value', attr='value', width=0.3, enablemodify=true}
			},
			rows={xml='lists/DizzyRoam_Stats.xml', attrs={'name', 'id'}},
			onitemclick=selectStat,
			onitemdoubleclick=maxStat
		},
		{'btn', id='close', closeswindow=true}
	},
	oncreate = initStats
}

---------------------------
-- Set position window
---------------------------
do
	local screenWidth, screenHeight = guiGetScreenSize()
	if screenHeight < 700 then
		g_MapSide = 450
	else
		g_MapSide = 700
	end
end

function setPosInit()
	local x, y, z = getElementPosition(g_Me)
	setControlNumbers(wndSetPos, { x = x, y = y, z = z })	
	addEventHandler('onClientRender', g_Root, updatePlayerBlips)
end

function fillInPosition(relX, relY, btn)
	if (btn == 'right') then
		closeWindow (wndSetPos)
		return
	end

	local x = relX*6000 - 3000
	local y = 3000 - relY*6000
	local hit, hitX, hitY, hitZ
	hit, hitX, hitY, hitZ = processLineOfSight(x, y, 3000, x, y, -3000)
	setControlNumbers(wndSetPos, { x = x, y = y, z = hitZ or 0 })
end

function setPosClick()
	setPlayerPosition(getControlNumbers(wndSetPos, {'x', 'y', 'z'}))
	closeWindow(wndSetPos)
end

function setPlayerPosition(x, y, z)
    if getElementData ( localPlayer, "attached" ) then return end
	if getElementData(g_Me, "timer.setpos") == "cooldown" then
	errMsg('Please wait 10 seconds before seting your position again.')
	return
	else
		if not isPedInVehicle(g_Me) then
		setElementData(g_Me, "timer.setpos", "cooldown")
		setTimer(setElementData, 10000, 1, g_Me, "timer.setpos", "normal")
		end
	local elem = getPedOccupiedVehicle(g_Me)
	local distanceToGround
	local isVehicle
		if elem then
		errMsg('Please leave the vehicle to change your position.')
		return
		else
		elem = g_Me
		distanceToGround = 0.4
		isVehicle = false
		end
	local hit, hitX, hitY, hitZ = processLineOfSight(x, y, 3000, x, y, -3000)
	if not hit then
		if isVehicle then
		server.fadeVehiclePassengersCamera(false)
		else
		fadeCamera(false)
		end
	setTimer(setCameraMatrix, 1000, 1, x, y, z)
	local grav = getGravity()
	setGravity(0.001)
	g_TeleportTimer = setTimer(
		function()
		local hit, groundX, groundY, groundZ = processLineOfSight(x, y, 3000, x, y, -3000)
			if hit then
			local waterZ = getWaterLevel(x, y, 100)
			z = (waterZ and math.max(groundZ, waterZ) or groundZ) + distanceToGround
				if isPlayerDead(g_Me) then
				server.spawnMe(x, y, z)
				else
				setElementPosition(elem, x, y, z + 2000)
				end
			setCameraPlayerMode()
			setGravity(grav)
				if isVehicle then
				server.fadeVehiclePassengersCamera(true)
				else
				fadeCamera(true)
				end
			killTimer(g_TeleportTimer)
			g_TeleportTimer = nil
			end
		end,
	500,
	0
	)
	else
		if isPlayerDead(g_Me) then
		server.spawnMe(x, y, z + distanceToGround)
		else
		setElementPosition(elem, x, y, z + distanceToGround + 2000)
			if isVehicle then
			setTimer(setElementVelocity, 100, 1, elem, 0, 0, 0)
			setTimer(setVehicleTurnVelocity, 100, 1, elem, 0, 0, 0)
			end
		end
	end
end
end

function updatePlayerBlips()
	if not g_PlayerData then
		return
	end
	local wnd = isWindowOpen(wndSpawnMap) and wndSpawnMap or wndSetPos
	local mapControl = getControl(wnd, 'map')
	for elem,player in pairs(g_PlayerData) do
		if not player.gui.mapBlip then
			player.gui.mapBlip = guiCreateStaticImage(0, 0, 9, 9, elem == g_Me and 'images/DizzyRoam_Local_Blip.png' or 'images/DizzyRoam_Blip.png', false, mapControl)
			player.gui.mapLabelShadow = guiCreateLabel(0, 0, 100, 14, player.name, false, mapControl)
			local labelWidth = guiLabelGetTextExtent(player.gui.mapLabelShadow)
			guiSetSize(player.gui.mapLabelShadow, labelWidth, 14, false)
			guiSetFont(player.gui.mapLabelShadow, 'default-bold-small')
			guiLabelSetColor(player.gui.mapLabelShadow, 255, 255, 255)
			player.gui.mapLabel = guiCreateLabel(0, 0, labelWidth, 14, player.name, false, mapControl)
			guiSetFont(player.gui.mapLabel, 'default-bold-small')
			guiLabelSetColor(player.gui.mapLabel, 0, 0, 0)
			for i,name in ipairs({'mapBlip', 'mapLabelShadow'}) do
				addEventHandler('onClientGUIDoubleClick', player.gui[name],
					function()
						server.warpMe(elem)
						closeWindow(wnd)
					end,
					false
				)
			end
		end
		local x, y = getElementPosition(elem)
		x = math.floor((x + 3000) * g_MapSide / 6000) - 4
		y = math.floor((3000 - y) * g_MapSide / 6000) - 4
		guiSetPosition(player.gui.mapBlip, x, y, false)
		guiSetPosition(player.gui.mapLabelShadow, x + 14, y - 4, false)
		guiSetPosition(player.gui.mapLabel, x + 13, y - 5, false)
	end
end

addEventHandler('onClientPlayerChangeNick', g_Root,
	function(oldNick, newNick)
		if (not g_PlayerData) then return end
		local player = g_PlayerData[source]
		player.name = newNick
		if player.gui.mapLabel then
			guiSetText(player.gui.mapLabelShadow, newNick)
			guiSetText(player.gui.mapLabel, newNick)
			local labelWidth = guiLabelGetTextExtent(player.gui.mapLabelShadow)
			guiSetSize(player.gui.mapLabelShadow, labelWidth, 14, false)
			guiSetSize(player.gui.mapLabel, labelWidth, 14, false)
		end
	end
)

function closePositionWindow()
	removeEventHandler('onClientRender', g_Root, updatePlayerBlips)
end

wndSetPos = {
	'wnd',
	text = 'Set position',
	width = g_MapSide + 20,
	controls = {
		{'img', id='map', src='images/DizzyRoam_Map.png', width=g_MapSide, height=g_MapSide, onclick=fillInPosition, ondoubleclick=setPosClick},
		{'txt', id='x', text='', width=0},
		{'txt', id='y', text='', width=0},
		{'txt', id='z', text='', width=0},
		{'btn', id='close', closeswindow=true},
	},
	oncreate = setPosInit,
	onclose = closePositionWindow
}


---------------------------
-- Spawn map window
---------------------------
function warpMapInit()
	addEventHandler('onClientRender', g_Root, updatePlayerBlips)
end

function spawnMapDoubleClick(relX, relY)
	setPlayerPosition(relX*6000 - 3000, 3000 - relY*6000, 0)
	closeWindow(wndSpawnMap)
end

function closeSpawnMap()
	showCursor(false)
	removeEventHandler('onClientRender', g_Root, updatePlayerBlips)
	for elem,data in pairs(g_PlayerData) do
		for i,name in ipairs({'mapBlip', 'mapLabelShadow', 'mapLabel'}) do
			if data.gui[name] then
				destroyElement(data.gui[name])
				data.gui[name] = nil
			end
		end
	end
end

wndSpawnMap = {
	'wnd',
	text = 'Set Position',
	width = g_MapSide + 20,
	controls = {
		{'img', id='map', src='images/DizzyRoam_Map.png', width=g_MapSide, height=g_MapSide, ondoubleclick=spawnMapDoubleClick},
		{'lbl', text='Welcome to freeroam. Double click a location on the map to spawn.', width=g_MapSide-60, align='center'},
		{'btn', id='close', closeswindow=true}
	},
	oncreate = warpMapInit,
	onclose = closeSpawnMap
}

---------------------------
-- Interior window
---------------------------

function setInterior(leaf)
	if getPedOccupiedVehicle(g_Me) then
	errMsg("Please leave the vehicle to change an interior")
	return
	end
setElementInterior(g_Me, leaf.world)
setCameraInterior(leaf.world)
setElementPosition(g_Me, leaf.posX, leaf.posY, leaf.posZ + 1)
closeWindow(wndSetInterior)
end

wndSetInterior = {
	'wnd',
	text = 'Set interior',
	width = 250,
	controls = {
		{
			'lst',
			id='interiors',
			width=230,
			height=300,
			columns={
				{text='Interior', attr='name'}
			},
			rows={xml='lists/DizzyRoam_Interiors.xml', attrs={'name', 'posX', 'posY', 'posZ', 'world'}},
			onitemdoubleclick=setInterior
		},
		{'btn', id='close', closeswindow=true}
	}
}

---------------------------
-- Create vehicle window
---------------------------
function createSelectedVehicle(leaf)
	if not leaf then
		leaf = getSelectedGridListLeaf(wndCreateVehicle, 'vehicles')
		if not leaf then
			return
		end
	end
	server.giveMeVehicles(leaf.id)
end

wndCreateVehicle = {
	'wnd',
	text = 'Vehicles',
	width = 300,
	controls = {
		{
			'lst',
			id='vehicles',
			width=280,
			height=340,
			columns={
				{text='Vehicle', attr='name'}
			},
			rows={xml='lists/DizzyRoam_Vehicles.xml', attrs={'id', 'name'}},
			onitemdoubleclick=createSelectedVehicle
		},
		{'btn', id='create', onclick=createSelectedVehicle},
		{'btn', id='close', closeswindow=true}
	}
}

function createVehicleCommand(cmd, id)
vehID = tonumber(id) or getVehicleModelFromName(id)
	if not vehID then
		return
	end
server.giveMeVehicles(math.floor(vehID))
end
addCommandHandler('createvehicle', createVehicleCommand)
addCommandHandler('cv', createVehicleCommand)

---------------------------
-- Repair vehicle
---------------------------
function repairVehicle()
local vehicle = getPedOccupiedVehicle(g_Me)
	if vehicle then
		if not repairTimer then
   		repairTimer = true
   		setTimer(function () repairTimer = false end, 30000, 1)
		server.fixVehicle(vehicle)
		outputChatBox("• Vehicle successfully repaired", 0, 100, 0)
		else
		errMsg("• Please wait 30 seconds before repairing again")
		end
	end
end
addCommandHandler('repair', repairVehicle)
addCommandHandler('rp', repairVehicle)
addCommandHandler('r', repairVehicle)

---------------------------
-- Flip vehicle
---------------------------
function flipVehicle()
local vehicle = getPedOccupiedVehicle(g_Me)
	if vehicle then
		if not flipTimer then
		flipTimer = true
   		setTimer(function () flipTimer = false end, 30000, 1)
		local rX, rY, rZ = getElementRotation(vehicle)
		server['set' .. 'VehicleRotation'](vehicle, 0, 0, (rX > 90 and rX < 270) and (rZ + 180) or rZ)
		outputChatBox("• Vehicle successfully flipped", 0, 100, 0)
		else
		errMsg("• Please wait 30 seconds before flipping again")
		end
	end
end
addCommandHandler('flip', flipVehicle)
addCommandHandler('f', flipVehicle)
addCommandHandler('fp', flipVehicle)

---------------------------
-- Vehicle upgrades
---------------------------
function upgradesInit()
	local vehicle = getPedOccupiedVehicle(g_Me)
	if not vehicle then
		errMsg('Please enter a vehicle to change the upgrades of.')
		closeWindow(wndUpgrades)
		return
	end
	local installedUpgrades = getVehicleUpgrades(vehicle)
	local compatibleUpgrades = {}
	local slotName, group
	for i,upgrade in ipairs(getVehicleCompatibleUpgrades(vehicle)) do
		slotName = getVehicleUpgradeSlotName(upgrade)
		group = table.find(compatibleUpgrades, 'name', slotName)
		if not group then
			group = { 'group', name = slotName, children = {} }
			table.insert(compatibleUpgrades, group)
		else
			group = compatibleUpgrades[group]
		end
		table.insert(group.children, { id = upgrade, installed = table.find(installedUpgrades, upgrade) ~= false })
	end
	table.sort(compatibleUpgrades, function(a, b) return a.name < b.name end)
	bindGridListToTable(wndUpgrades, 'upgradelist', compatibleUpgrades, true)
end

function selectUpgrade(leaf)
	setControlText(wndUpgrades, 'addremove', leaf.installed and 'remove' or 'add')
end

function addRemoveUpgrade(selUpgrade)
	-- Add or remove selected upgrade
	local vehicle = getPedOccupiedVehicle(g_Me)
	if not vehicle then
		return
	end
	
	if not selUpgrade then
		selUpgrade = getSelectedGridListLeaf(wndUpgrades, 'upgradelist')
		if not selUpgrade then
			return
		end
	end
	
	if selUpgrade.installed then
		-- remove upgrade
		selUpgrade.installed = false
		setControlText(wndUpgrades, 'addremove', 'add')
		server.removeVehicleUpgrade(vehicle, selUpgrade.id)
	else
		-- add upgrade
		local prevUpgradeIndex = table.find(selUpgrade.siblings, 'installed', true)
		if prevUpgradeIndex then
			selUpgrade.siblings[prevUpgradeIndex].installed = false
		end
		selUpgrade.installed = true
		setControlText(wndUpgrades, 'addremove', 'remove')
		server.addVehicleUpgrade(vehicle, selUpgrade.id)
	end
end

wndUpgrades = {
	'wnd',
	text = 'Vehicle upgrades',
	width = 300,
	x = -20,
	y = 0.3,
	controls = {
		{
			'lst',
			id='upgradelist',
			width=280,
			height=340,
			columns={
				{text='Upgrade', attr='id', width=0.6},
				{text='Installed', attr='installed', width=0.3, enablemodify=true}
			},
			onitemclick=selectUpgrade,
			onitemdoubleclick=addRemoveUpgrade
		},
		{'btn', id='addremove', text='add', width=60, onclick=addRemoveUpgrade},
		{'btn', id='ok', closeswindow=true}
	},
	oncreate = upgradesInit
}

function addUpgradeCommand(cmd, upgrade)
	local vehicle = getPedOccupiedVehicle(g_Me)
	if vehicle and upgrade then
		server.addVehicleUpgrade(vehicle, tonumber(upgrade) or 0)
	end
end
addCommandHandler('addupgrade', addUpgradeCommand)
addCommandHandler('au', addUpgradeCommand)

function removeUpgradeCommand(cmd, upgrade)
	local vehicle = getPedOccupiedVehicle(g_Me)
	if vehicle and upgrade then
		server.removeVehicleUpgrade(vehicle, tonumber(upgrade) or 0)
	end
end
addCommandHandler('removeupgrade', removeUpgradeCommand)
addCommandHandler('ru', removeUpgradeCommand)

---------------------------
-- Color
---------------------------

function setColorCommand(cmd, ...)
	local vehicle = getPedOccupiedVehicle(g_Me)
	if not vehicle then
		return
	end
	local colors = { getVehicleColor(vehicle) }
	local args = { ... }
	for i=1,6 do
		colors[i] = args[i] and tonumber(args[i]) or colors[i]
	end
	server.setVehicleColor(vehicle, unpack(colors))
end
addCommandHandler('color', setColorCommand)
addCommandHandler('cl', setColorCommand)

function openColorPicker()
	editingVehicle = getPedOccupiedVehicle(localPlayer)
	if (editingVehicle) then
		colorPicker.openSelect(colors)
	end
end

function closedColorPicker()
	local r1, g1, b1, r2, g2, b2 = getVehicleColor(editingVehicle, true)
	server.setVehicleColor(editingVehicle, r1, g1, b1, r2, g2, b2)
	local r, g, b = getVehicleHeadLightColor(editingVehicle)
	server.setVehicleHeadLightColor(editingVehicle, r, g, b)
	editingVehicle = nil
end

function updateColor()
	if (not colorPicker.isSelectOpen) then return end
	local r, g, b = colorPicker.updateTempColors()
	if (editingVehicle and isElement(editingVehicle)) then
		local r1, g1, b1, r2, g2, b2 = getVehicleColor(editingVehicle, true)
		if (guiCheckBoxGetSelected(checkColor1)) then
			r1, g1, b1 = r, g, b
		end
		if (guiCheckBoxGetSelected(checkColor2)) then
			r2, g2, b2 = r, g, b
		end
		if (guiCheckBoxGetSelected(checkColor3)) then
			setVehicleHeadLightColor(editingVehicle, r, g, b)
		end
		setVehicleColor(editingVehicle, r1, g1, b1, r2, g2, b2)
	end
end
addEventHandler("onClientRender", root, updateColor)

function errMsg(msg)
	outputChatBox(msg, 255, 0, 0)
end

---------------------------
-- Paintjob
---------------------------

function paintjobInit()
	local vehicle = getPedOccupiedVehicle(g_Me)
	if not vehicle then
		errMsg('You need to be in a car to change its paintjob.')
		closeWindow(wndPaintjob)
		return
	end
	local paint = getVehiclePaintjob(vehicle)
	if paint then
		guiGridListSetSelectedItem(getControl(wndPaintjob, 'paintjoblist'), paint+1)
	end
end

function applyPaintjob(paint)
	server.setVehiclePaintjob(getPedOccupiedVehicle(g_Me), paint.id)
end

wndPaintjob = {
	'wnd',
	text = 'Car paintjob',
	width = 220,
	x = -20,
	y = 0.3,
	controls = {
		{
			'lst',
			id='paintjoblist',
			width=200,
			height=130,
			columns={
				{text='Paintjob ID', attr='id'}
			},
			rows={
				{id=0},
				{id=1},
				{id=2},
				{id=3}
			},
			onitemclick=applyPaintjob,
			ondoubleclick=function() closeWindow(wndPaintjob) end
		},
		{'btn', id='close', closeswindow=true},
	},
	oncreate = paintjobInit
}

function setPaintjobCommand(cmd, paint)
	local vehicle = getPedOccupiedVehicle(g_Me)
	paint = paint and tonumber(paint)
	if not paint or not vehicle then
		return
	end
	server.setVehiclePaintjob(vehicle, paint)
end
addCommandHandler('paintjob', setPaintjobCommand)
addCommandHandler('pj', setPaintjobCommand)

---------------------------
-- Main window
---------------------------

function mainWndShow()
	if not getPedOccupiedVehicle(g_Me) then
		hideControls(wndMain, 'Repair', 'Flip', 'Upgrades', 'Color', 'Paintjob')
	end
end

function mainWndClose()
	killTimer(updateTimer)
	updateTimer = nil
	colorPicker.closeSelect()
end

function onEnterVehicle(vehicle)
	showControls(wndMain, 'Repair', 'Flip', 'Upgrades', 'Color', 'Paintjob')
end

function onExitVehicle(vehicle)
	hideControls(wndMain, 'Repair', 'Flip', 'Upgrades', 'Color', 'Paintjob')
	closeWindow(wndUpgrades)
	closeWindow(wndColor)
end

function killLocalPlayer()
	server.killPed(g_Me)
end
addCommandHandler('kill', killLocalPlayer)

wndMain = {
	'wnd',
	text = 'Freeroam',
	x = 10,
	y = 150,
	width = 280,
	controls = {
		{'lbl', text='Player'},
		{'br'},
		{'btn', id='Kill', onclick=killLocalPlayer},
		{'btn', id='Character', window=wndSkin},
		{'btn', id='Animations', window=wndAnim},
		{'btn', id='Clothes', window=wndClothes},
		{'btn', id='Stats', window=wndStats},
		{'btn', id='Walking', window=wndWalking},
        {'btn', id='Fighting', window=wndFighting},
		{'btn', id='Weapons', window=wndWeapon},
		{'br'},
		{'lbl', text='Position'},
		{'br'},
		{'btn', id='setpos', text='Set position', window=wndSetPos},
		{'br'},
		{'lbl', text='Vehicle'},
		{'br'},
		{'btn', id='createvehicle', window=wndCreateVehicle, text='Create vehicle'},
		{'btn', id='Repair', onclick=repairVehicle},
		{'btn', id='Flip', onclick=flipVehicle},
		{'btn', id='Upgrades', window=wndUpgrades},
		{'btn', id='Color', onclick=openColorPicker},
		{'btn', id='Paintjob', window=wndPaintjob},
		{'br'},
	},
	oncreate = mainWndShow,
	onclose = mainWndClose
}


addEventHandler('onClientResourceStart', g_ResRoot,
	function()
		fadeCamera(true)
		setTimer(getPlayers, 1000, 1)		
		bindKey('f1', 'down', toggleFRWindow)
		addCommandHandler("freeroam", toggleFRWindow)
		createWindow(wndMain)
		hideAllWindows()	
		triggerServerEvent('onLoadedAtClient', g_ResRoot, g_Me)
	end
)

function showWelcomeMap()
	createWindow(wndSpawnMap)
	showCursor(true)
end

function showMap()
	createWindow(wndSetPos)
	showCursor(true)
end

function toggleFRWindow()
	if isWindowOpen(wndMain) then
		showCursor(false)
		hideAllWindows()
		colorPicker.closeSelect()
	else
		showCursor(true)
		showAllWindows()
	end
end

addCommandHandler('fr', toggleFRWindow)

function getPlayers()
	g_PlayerData = {}
	table.each(getElementsByType('player'), joinHandler)
end

function joinHandler(player)
	if (not g_PlayerData) then return end
	g_PlayerData[player or source] = { name = getPlayerName(player or source), gui = {} }
end
addEventHandler('onClientPlayerJoin', g_Root, joinHandler)

addEventHandler('onClientPlayerQuit', g_Root,
	function()
		if (not g_PlayerData) then return end
		table.each(g_PlayerData[source].gui, destroyElement)
		g_PlayerData[source] = nil
	end
)

addEventHandler('onClientPlayerWasted', g_Me,
	function()
		onExitVehicle(g_Me)
	end
)

addEventHandler('onClientPlayerVehicleEnter', g_Me, onEnterVehicle)
addEventHandler('onClientPlayerVehicleExit', g_Me, onExitVehicle)

addEventHandler('onClientResourceStop', g_ResRoot,
	function()
		showCursor(false)
		setPedAnimation(g_Me, false)
	end
)

local vehicleWidth = { 
[400] = 3.03, [401] = 3.30, [402] = 2.90, [403] = 5.30, [404] = 3.21, [405] = 3.37, [406] = 6.60, [407] = 4.89, [408] = 5.90, [409] = 4.36,
[410] = 2.89, [411] = 2.69, [412] = 3.97, [413] = 3.34, [414] = 3.99, [415] = 3.04, [416] = 4.42, [417] = 16.01, [418] = 3.32, [419] = 3.45,
[420] = 3.30, [421] = 3.53, [422] = 3.11, [423] = 3.60, [424] = 2.44, [425] = 9.84, [426] = 3.29, [427] = 4.48, [428] = 3.73, [429] = 2.91,
[430] = 6.59, [431] = 6.66, [432] = 7.17, [433] = 5.51, [434] = 2.69, [435] = 7.33, [436] = 3.11, [437] = 6.40, [438] = 3.37, [439] = 3.04,
[440] = 3.29, [441] = 2.00, [442] = 3.71, [443] = 10.38, [444] = 3.85, [445] = 3.30, [446] = 6.73, [447] = 7.58, [448] = 1.33, [449] = 5.29,
[450] = 7.17, [451] = 3.06, [452] = 5.92, [453] = 6.02, [454] = 9.70, [455] = 5.35, [456] = 5.18, [457] = 2.10, [458] = 3.44, [459] = 3.27,
[460] = 8.94, [461] = 1.44, [462] = 1.33, [463] = 1.40, [464] = 1.25, [465] = 0.94, [466] = 3.45, [467] = 3.53, [468] = 1.39, [469] = 7.58,
[470] = 3.24, [471] = 1.49, [472] = 4.58, [473] = 2.61, [474] = 3.37, [475] = 3.26, [476] = 8.19, [477] = 3.36, [478] = 3.23, [479] = 3.39,
[480] = 2.83, [481] = 1.17, [482] = 3.33, [483] = 3.44, [484] = 9.92, [485] = 2.37, [486] = 4.67, [487] = 7.71, [488] = 6.53, [489] = 3.38,
[490] = 3.93, [491] = 3.00, [492] = 2.84, [493] = 6.79, [494] = 3.57, [495] = 3.22, [496] = 2.65, [497] = 7.71, [498] = 4.19, [499] = 3.99,
[500] = 2.90, [501] = 0.94, [502] = 3.35, [503] = 3.40, [504] = 3.39, [505] = 3.38, [506] = 2.94, [507] = 3.60, [508] = 4.62, [509] = 1.21,
[510] = 1.13, [511] = 15.03, [512] = 6.58, [513] = 6.51, [514] = 5.55, [515] = 5.68, [516] = 3.49, [517] = 3.51, [518] = 3.33, [519] = 13.87,
[520] = 8.61, [521] = 1.44, [522] = 1.44, [523] = 1.44, [524] = 5.08, [525] = 3.94, [526] = 2.98, [527] = 3.14, [528] = 3.28, [529] = 3.15,
[530] = 2.63, [531] = 2.31, [532] = 7.38, [533] = 2.53, [534] = 3.40, [535] = 3.15, [536] = 3.54, [537] = 11.06, [538] = 8.26, [539] = 2.61,
[540] = 3.44, [541] = 2.79, [542] = 3.53, [543] = 3.24, [544] = 6.73, [545] = 2.80, [546] = 3.30, [547] = 3.28, [548] = 12.72, [549] = 3.14,
[550] = 3.34, [551] = 2.86, [552] = 4.02, [553] = 18.92, [554] = 3.57, [555] = 2.84, [556] = 3.85, [557] = 3.85, [558] = 2.94, [559] = 3.05,
[560] = 3.05, [561] = 3.28, [562] = 2.98, [563] = 9.65, [564] = 0.93, [565] = 2.72, [566] = 3.58, [567] = 3.71, [568] = 2.75, [569] = 9.41,
[570] = 9.41, [571] = 1.61, [572] = 1.75, [573] = 4.15, [574] = 2.43, [575] = 3.26, [576] = 3.48, [577] = 45.08, [578] = 6.35, [579] = 3.31,
[580] = 3.35, [581] = 1.46, [582] = 3.98, [583] = 2.52, [584] = 8.24, [585] = 3.56, [586] = 1.56, [587] = 3.24, [588] = 5.52, [589] = 2.98,
[590] = 9.67, [591] = 7.38, [592] = 36.34, [593] = 9.36, [594] = 0.58, [595] = 6.34, [596] = 3.30, [597] = 3.31, [598] = 3.25, [599] = 3.57,
[600] = 3.35, [601] = 4.56, [602] = 3.14, [603] = 3.38, [604] = 3.45, [605] = 3.24, [606] = 2.46, [607] = 2.43, [608] = 4.01, [609] = 4.17,
[610] = 1.59, [611] = 2.11,
}

function isTheLineClear(vx, vy, vz, vehID, vrot)
local width = vehicleWidth[vehID] or 3
local px,py,pz = getElementPosition(source)
	if isLineOfSightClear(px,py,pz+1,vx+width,vy+width,vz+1) and isLineOfSightClear(px,py,pz+1,vx+width,vy-width,vz+1) and isLineOfSightClear(px,py,pz+1,vx-width,vy-width,vz+1) and isLineOfSightClear(px,py,pz+1,vx-width,vy+width,vz+1) then
	triggerServerEvent("onPlayerVehicleCreate", source, vx, vy, vz, vehID, vrot)
	else
	errMsg('Please find a clear location to spawn the vehicle.')
	end
end
addEvent("onClientLineCheck", true)
addEventHandler("onClientLineCheck", getRootElement(), isTheLineClear)

addEvent("onServerChat", true)

----Clan menu
Clan = {
    Button = {},
    Window = {},
	Gridlist = {},
	Edit = {},
	Memo = {}
}
Clan.Window[1] = guiCreateWindow(0, 232, 302, 421, "Clan panel", false)
guiWindowSetSizable(Clan.Window[1], false)
Clan.Window[2] = guiCreateWindow(361, 232, 250, 451, "Set player Rank", false)
guiWindowSetSizable(Clan.Window[2], false)
Clan.Window[3] = guiCreateWindow(361, 232, 250, 451, "Set player Rank", false)
guiWindowSetSizable(Clan.Window[3], false)

Clan.Gridlist[1] = guiCreateGridList(9, 19, 291, 352, false, Clan.Window[1])
local column = guiGridListAddColumn(Clan.Gridlist[1], "Players", 0.9)
if ( column ) then --If the column has been created, fill it with players
    for _,v in ipairs(getElementsByType("player"))do
        local row = guiGridListAddRow(Clan.Gridlist[1])
        local players = getPlayerName(v)
        guiGridListSetItemText(Clan.Gridlist[1],row,column,players,false,false)
    end
end
Clan.Button[1] = guiCreateButton(9, 377, 59, 36, "Add", false, Clan.Window[1])
Clan.Button[2] = guiCreateButton(126, 377, 51, 36, "Kick", false, Clan.Window[1])
Clan.Button[3] = guiCreateButton(68, 377, 58, 36, "Promote", false, Clan.Window[1])
Clan.Button[4] = guiCreateButton(177, 377, 54, 36, "Demote", false, Clan.Window[1])
Clan.Button[5] = guiCreateButton(231, 377, 54, 36, "Close", false, Clan.Window[1])
Clan.Button[6] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[2])
Clan.Button[7] = guiCreateButton(143, 62, 87, 23, "Promote", false, Clan.Window[2])
Clan.Button[8] = guiCreateButton(13, 62, 87, 23, "Cancel", false, Clan.Window[3])
Clan.Button[9] = guiCreateButton(143, 62, 87, 23, "Demote", false, Clan.Window[3])
Clan.Edit[1] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[2])
Clan.Edit[2] = guiCreateEdit(13, 29, 227, 28, "", false, Clan.Window[3])

Clan.Memo[1] = guiCreateMemo(13, 97, 227, 344, "Avaible Ranks\n\nLeader\n\nCo Leader\n\nGuest", false, Clan.Window[2])
guiMemoSetReadOnly(Clan.Memo[1], true)

guiSetVisible(Clan.Window[1], false)
guiSetVisible(Clan.Window[2], false)
guiSetVisible(Clan.Window[3], false)
showCursor(false)
if getElementData(localPlayer, "clan.rank") == "leader" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Mohamed" then
guiSetEnabled(Clan.Button[3], true)
guiSetEnabled(Clan.Button[4], true)
else
guiSetEnabled(Clan.Button[3], false)
guiSetEnabled(Clan.Button[4], false)
end

function toggleClanControl( source )
if getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "[ET]Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" then
    if not guiGetVisible( Clan.Window[1] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[1], true )
        guiGridListClear ( Clan.Gridlist[1] )
        if ( column ) then
            guiGridListClear ( Clan.Gridlist[1] )
            for _,v in ipairs(getElementsByType("player"))do
                local row = guiGridListAddRow(Clan.Gridlist[1])
                local playerName = getPlayerName(v)
                guiGridListSetItemText(Clan.Gridlist[1],row,column,playerName,false,false)
            end
		end
		if getElementData(localPlayer, "clan.rank") == "leader" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "Soap" or getElementData(localPlayer, "player.key") == "[ET]Danksta" then
			guiSetEnabled(Clan.Button[3], true)
			guiSetEnabled(Clan.Button[4], true)
		else
			guiSetEnabled(Clan.Button[3], false)
			guiSetEnabled(Clan.Button[4], false)
		end
    else
        showCursor ( false )
        guiSetVisible( Clan.Window[1], false )
    end
end
end
bindKey( "H", "down", toggleClanControl )
addCommandHandler("clan", toggleClanControl)

addEventHandler("onClientGUIClick", guiRoot,
function()
	if source == Clan.Button[1] then
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
		local team = getPlayerTeam(localPlayer)
		local teamName = getTeamName(team)
        if not playerName then
            guiGridListRemoveRow(row)
            return
        end
            triggerServerEvent("addToTeam", localPlayer,playerName,teamName)
		end
end)

addEventHandler("onClientGUIClick", guiRoot,
function()
	if source == Clan.Button[2] then
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
		local team = getPlayerTeam(localPlayer)
		local teamName = getTeamName(team)
        if not playerName then
            guiGridListRemoveRow(row)
            return
        end
            triggerServerEvent("kickFromTeam", localPlayer,playerName,teamName)
		end
end)

function closeClan()
	if guiGetVisible(Clan.Window[1]) then 
		guiSetVisible(Clan.Window[1],false)
		showCursor(false)
	end
end
addEventHandler ("onClientGUIClick", Clan.Button[5], closeClan, false)

function togglePromote( source )
-- Show the panel
    if not guiGetVisible( Clan.Window[2] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[2], true )
		guiMoveToBack( Clan.Window[1] )
    else
        showCursor ( true )
        guiSetVisible( Clan.Window[2], false )
    end
end
addEventHandler ( "onClientGUIClick", Clan.Button[3], togglePromote, false )

addEventHandler("onClientGUIClick",Clan.Button[7],
function()
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
        if not playerName then
        guiGridListRemoveRow(row)
        return
		end
    triggerServerEvent("promotePlayer",localPlayer,playerName,tostring(guiGetText(Clan.Edit[1])) or "Member")
	guiSetVisible( Clan.Window[2], false )
	showCursor ( true )
end,false)

function closeClan()
	if guiGetVisible(Clan.Window[2]) then 
		guiSetVisible(Clan.Window[2],false)
		showCursor(true)
	end
end
addEventHandler ("onClientGUIClick", Clan.Button[6], closeClan, false)

function toggleDemote( source )
-- Show the panel
    if not guiGetVisible( Clan.Window[2] ) then
        showCursor ( true )
        guiSetVisible( Clan.Window[2], true )
		guiMoveToBack( Clan.Window[1] )
    else
        showCursor ( true )
        guiSetVisible( Clan.Window[2], false )
    end
end
addEventHandler ( "onClientGUIClick", Clan.Button[4], toggleDemote, false )

addEventHandler("onClientGUIClick",Clan.Button[9],
function()
        local row, column = guiGridListGetSelectedItem(Clan.Gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText(Clan.Gridlist[1],row,column)
        local player = getPlayerFromName(playerName)
        if not playerName then
        guiGridListRemoveRow(row)
        return
		end
    triggerServerEvent("DemotePlayer",localPlayer,playerName,tostring(guiGetText(Clan.Edit[2])) or "Member")
	guiSetVisible( Clan.Window[3], false )
	showCursor ( true )
end,false)


addEventHandler ("onClientGUIClick", Clan.Button[8], closeClan, false)
----Scoreboard Columns
addEventHandler("onClientResourceStart",resourceRoot,
function()
    triggerServerEvent("onDownloadFinish",localPlayer)
end )
----Download Text
addEventHandler("onClientResourceStart",resourceRoot,
    function ()
        triggerServerEvent("removeText",localPlayer)
    end
)
----Glue
function glue()
	local player = getLocalPlayer()
	if not getPedOccupiedVehicle(player) then
		local vehicle = getPedContactElement(player)
		if getElementType(vehicle) == "vehicle" then
			
			local px, py, pz = getElementPosition(player)
			local vx, vy, vz = getElementPosition(vehicle)
			local sx = px - vx
			local sy = py - vy
			local sz = pz - vz
			
			local rotpX = 0
			local rotpY = 0
			local rotpZ = getPedRotation(player)
			
			local rotvX,rotvY,rotvZ = getElementRotation(vehicle)
			
			local t = math.rad(rotvX)
			local p = math.rad(rotvY)
			local f = math.rad(rotvZ)
			
			local ct = math.cos(t)
			local st = math.sin(t)
			local cp = math.cos(p)
			local sp = math.sin(p)
			local cf = math.cos(f)
			local sf = math.sin(f)
			
			local z = ct*cp*sz + (sf*st*cp + cf*sp)*sx + (-cf*st*cp + sf*sp)*sy
			local x = -ct*sp*sz + (-sf*st*sp + cf*cp)*sx + (cf*st*sp + sf*cp)*sy
			local y = st*sz - sf*ct*sx + cf*ct*sy
			
			local rotX = rotpX - rotvX
			local rotY = rotpY - rotvY
			local rotZ = rotpZ - rotvZ
			
			local slot = getPedWeaponSlot(player)
			
			--outputDebugString("gluing ".. getPlayerName(player) .." to " .. getVehicleName(vehicle) .. "(offset: "..tostring(x)..","..tostring(y)..","..tostring(z).."; rotation:"..tostring(rotX)..","..tostring(rotY)..","..tostring(rotZ)..")")
			
			triggerServerEvent("gluePlayer", player, slot, vehicle, x, y, z, rotX, rotY, rotZ)
			
			unbindKey("x","down",glue)
			bindKey("x","down",unglue)
		end
	end
end

addCommandHandler("glue",glue)

function unglue ()
	local player = getLocalPlayer()
	triggerServerEvent("ungluePlayer", player)
	unbindKey("x","down",unglue)
	bindKey("x","down",glue)
end

addCommandHandler("unglue",unglue)

bindKey("x","down",glue)
----Greenzone
addEvent("enableGodMode", true)
addEvent("disableGodMode", true)
addEventHandler ("enableGodMode", getRootElement(), 
function()
  addEventHandler ("onClientPlayerDamage", getRootElement(), cancelEventEvent)
end)

addEventHandler ("disableGodMode", getRootElement(), 
function()
  removeEventHandler ("onClientPlayerDamage", getRootElement(), cancelEventEvent)
end)

function cancelEventEvent () cancelEvent() end 

pirShipMusicCol = createColCuboid (1997.58,1523.16,8,6,17.66,4)
addEventHandler ("onClientColShapeHit", getRootElement(), 
function(hitElement, matchingDimension)
  if (source == pirShipMusicCol) and (hitElement == getLocalPlayer()) then
    setRadioChannel (7)
  end
end)
addEventHandler ("onClientColShapeLeave", getRootElement(), 
function(leaveElement, matchingDimension)
  if (source == pirShipMusicCol) and (leaveElement == getLocalPlayer()) then
    setRadioChannel (0)
  end
end)	
----Sv
glp = getLocalPlayer()
notallowed = {[432] = false, [538] = false, [569] = false, [590] = false, [537] = false, [449] = false}
spaces = {["Police Maverick"] = false, ["Mountain Bike"] = false, ["Pizza Boy"] = false, ["Utility Van"] = false, ["Police Car (Los Santos)"] = false, ["Police Car (San Fierro)"] = false, ["Police Ranger"] = false, ["FBI Rancher"] = false, ["FBI Truck"] = false, ["Fire Truck"] = false, ["Fire Truck (Ladder)"] = false, ["Police Car (Las Venturas)"] = false, ["Black Boxville"] = false, ["Linerunner (From 'Tanker Commando')"] = false, ["Mr. Whoopee"] = false, ["Cement Truck"] = false, ["Combine Harvester"] = false, ["Berkley's RC Van"] = false, ["Damaged Sadler"] = false, ["News Van"] = false, ["RC Bandit"] = false, ["RC Baron"] = false, ["RC Goblin"] = false, ["RC Raider"] = false, ["RC Tiger"] = false, ["BF Injection"] = false, ["Bloodring Banger"] = false, ["Monster 2"] = false, ["Super GT"] = false, ["Hotring Racer"] = false, ["Hotring Racer 2"] = false, ["Hotring Racer 3"] = false, ["Rancher (From 'Lure')"] = false, ["RC Cam (flower pot)"] = false, ["News Chopper"] = false }

function isNumber(n)
	return tonumber(n) ~= nil
end

addCommandHandler("gj",
	function(cmd, carName, ...)
		if (glp and isElement(glp) and getElementType(glp) == "player") then
			if (not isTimer(antiSpam)) then
			if (isPedDead(glp)) then return end
			local px, py, pz = getElementPosition(glp)
				if (carName == nil) then
					msg("•Syntax: /gj (Vehicle name or ID)")
				elseif not isNumber(carName) and (notallowed[getVehicleModelFromName(tostring(carName))]) then
					msg("•Vehicle not allowed")
				elseif isNumber(carName) and ((notallowed[tonumber(carName)]) or (notallowed[tonumber(math.floor(carName))])) then
					msg("•Vehicle not allowed")
				elseif (not getVehicleModelFromName(tostring(carName and ...)) and not isNumber(carName) and spaces[tostring(carName)] == false and not tostring(carName) == "none") then
					msg("•Invalid vehicle name '" .. carName .. "'")
				elseif (getElementInterior(glp) > 0) then
				elseif (not isPedInVehicle(glp)) then
					if (isNumber(carName) and tonumber(carName) < 400 or isNumber(carName) and tonumber(carName) > 610) then
						cancelEvent()
						msg("•Vehicle not found")
					else
						triggerServerEvent("create", glp, glp, px, py, pz, arg2, carName, ...)
					end
				elseif (isPedInVehicle(glp)) then
					if (isNumber(carName) and tonumber(carName) < 400 or isNumber(carName) and tonumber(carName) > 610) then
						cancelEvent()
						msg("•Vehicle not found.")
					else
						triggerServerEvent("change", glp, glp, cmd, arg2, carName, ...)
					end
				end
			antiSpam = setTimer(function() end, 70, 1)
		else
		end
	end
end
)

function msg(err)
	outputChatBox(err,255,0,0)
end
----Random Stuff
addEventHandler("onClientRender", getRootElement(), function()

for k,player in ipairs(getElementsByType("player")) do
if getElementHealth(player) >= 1 then
local width, height = guiGetScreenSize ()
local lx, ly, lz = getWorldFromScreenPosition ( width/2, height/2, 10 )
setPedLookAt(player, lx, ly, lz)
end 
end
   
end)
----Stats GUI And Stats Upgrader
local Progress = {}
local screenWidth, screenHeight = guiGetScreenSize()
local windowWidth, windowHeight = 270, 485
local windowWidth2, windowHeight2 = 146, 15
Progress[1]	= guiCreateProgressBar(189,270,windowWidth2,windowHeight2,false)
Progress[2] = guiCreateProgressBar(189,310,windowWidth2,windowHeight2,false)
Progress[3] = guiCreateProgressBar(189,350,windowWidth2,windowHeight2,false)
Progress[4] = guiCreateProgressBar(189,390,windowWidth2,windowHeight2,false)
Progress[5] = guiCreateProgressBar(189,430,windowWidth2,windowHeight2,false)
Progress[6] = guiCreateProgressBar(189,470,windowWidth2,windowHeight2,false)
Progress[7] = guiCreateProgressBar(189,510,windowWidth2,windowHeight2,false)
Progress[8] = guiCreateProgressBar(189,550,windowWidth2,windowHeight2,false)
Progress[9] = guiCreateProgressBar(189,590,windowWidth2,windowHeight2,false)
Progress[10] = guiCreateProgressBar(189,630,windowWidth2,windowHeight2,false)
Progress[11] = guiCreateProgressBar(189,670,windowWidth2,windowHeight2,false)
for _, prog in pairs ( Progress ) do
	guiSetVisible( prog, false )
end

function Draw()
	dxDrawRectangle(67,220,windowWidth,windowHeight,tocolor(0,0,0,180),false)
    dxDrawText("Usp 45",78,270,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("Usp 45-Silenced",78,310,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("Desert Eagle",78,350,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("SPAS-12",78,390,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("Model-870",78,430,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("Striker",78,470,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("Mp7",78,510,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("Mp5",78,550,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("AK-47",78,590,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("M4A1",78,630,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
	dxDrawText("L118A",78,670,windowWidth,windowHeight,tocolor(255,255,255,255),1.0,"Segoe UI","left","top",false,false,false)
    dxDrawText("Player Stats",70,220,windowWidth,windowHeight,tocolor(255,255,255,255),1.1,"bankgothic","left","top",false,false,false)
end

addEventHandler("onClientRender", root,
	function ( )
		gPS69 = getPedStat(localPlayer, 69 )
		stat69 = (gPS69/10)
		guiProgressBarSetProgress(Progress[1], stat69)
		gPS70 = getPedStat(localPlayer, 70 )
		stat70 = (gPS70/10)
		guiProgressBarSetProgress(Progress[2], stat70)
		gPS71 = getPedStat(localPlayer, 71 )
		stat71 = (gPS71/10)
		guiProgressBarSetProgress(Progress[3], stat71)
		gPS72 = getPedStat(localPlayer, 72 )
		stat72 = (gPS72/10)
		guiProgressBarSetProgress(Progress[4], stat72)
		gPS73 = getPedStat(localPlayer, 73 )
		stat73 = (gPS73/10)
		guiProgressBarSetProgress(Progress[5], stat73)
		gPS74 = getPedStat(localPlayer, 74 )
		stat74 = (gPS74/10)
		guiProgressBarSetProgress(Progress[6], stat74)
		gPS75 = getPedStat(localPlayer, 75 )
		stat75 = (gPS75/10)
		guiProgressBarSetProgress(Progress[7], stat75)
		gPS76 = getPedStat(localPlayer, 76 )
		stat76 = (gPS76/10)
		guiProgressBarSetProgress(Progress[8], stat76)
		gPS77 = getPedStat(localPlayer, 77 )
		stat77 = (gPS77/10)
		guiProgressBarSetProgress(Progress[9], stat77)
		gPS78 = getPedStat(localPlayer, 78 )
		stat78 = (gPS78/10)
		guiProgressBarSetProgress(Progress[10], stat78)
		gPS79 = getPedStat(localPlayer, 79 )
		stat79 = (gPS79/10)
		guiProgressBarSetProgress(Progress[11], stat79)
	end
)

bindKey ( "B", "both",
    function ( key, keyState )
        if ( keyState == "down" ) then
			addEventHandler("onClientRender", getRootElement(), Draw)
			for _, prog in pairs ( Progress ) do
				guiSetVisible( prog, true )
			end
	elseif ( keyState == "up" ) then
			removeEventHandler("onClientRender", getRootElement(), Draw)
			for _, prog in pairs ( Progress ) do
				guiSetVisible( prog, false )
			end
        end
    end
)
----Upgrade Stats
commandName = "defstats"

addCommandHandler (commandName,

 function(sot)
  setPedArmor(sot, 0)
  setElementHealth(sot, 569)
  setPlayerMoney(sot, 0)
  setPedStat (sot, 69, 500)
  setPedStat (sot, 70, 999)
  setPedStat (sot, 71, 999)
  setPedStat (sot, 72, 999)
  setPedStat (sot, 73, 500)
  setPedStat (sot, 74, 999)
  setPedStat (sot, 75, 500)
  setPedStat (sot, 76, 999)
  setPedStat (sot, 77, 999)
  setPedStat (sot, 78, 999)
  setPedStat (sot, 79, 999)
  setPedStat (sot, 229, 0)
  setPedStat (sot, 230, 0)
  setPedStat (sot, 225, 0)
  setPedStat (sot, 22, 0)
  setPedStat (sot, 23, 0)
  setPedStat (sot, 8, 500)
  setPedStat (sot, 9, 500)
  outputChatBox("Stats Changed To Default", sot, 255, 0, 0)
 end
)
----F3 Rules Script
local sWidth, sHeight = guiGetScreenSize()

local strings = {
[1] = " Server rules",
[2] = " Do not annoy staff members",
[3] = " Do not ask for staff",
[4] = " Do not blame anyone with no proof",
[5] = " Do not spam in chat",
[6] = " Do not leech from the server",
[7] = " Do not support server leechers",
[8] = " Do not Spawn kill",
[9] = " Do not hack",
[10] = " Do not insult in chat",
[11] = " Do not abuse",
[12] = " Report the bugs when you find any",
}

function showServerRules()
	if getElementData(localPlayer, "rules.showing") then
	dxDrawText(strings[1], 0.01*sWidth, 0.16*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "bankgothic", "left", "top", false, false, false, true, true)
	dxDrawText(strings[10], 0.01*sWidth, 0.23*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[2], 0.01*sWidth, 0.27*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[3], 0.01*sWidth, 0.31*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[4], 0.01*sWidth, 0.35*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[5], 0.01*sWidth, 0.39*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[6], 0.01*sWidth, 0.43*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[7], 0.01*sWidth, 0.47*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[8], 0.01*sWidth, 0.51*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[9], 0.01*sWidth, 0.55*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[11], 0.01*sWidth, 0.61*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	dxDrawText(strings[12], 0.01*sWidth, 0.64*sHeight, sWidth, sHeight, tocolor(255, 255, 255), 0.001*sWidth, 0.002*sHeight, "DS-Digital Bold", "left", "top", false, false, false, true, true)
	end
end
addEventHandler("onClientRender", root, showServerRules)

function showRules(player, command)
	if getElementData(localPlayer, "rules.showing") then
	setElementData(localPlayer, "rules.showing", false)
	else
	setElementData(localPlayer, "rules.showing", true)
	end
end
addCommandHandler("serverrules", showRules)
bindKey("F3", "down", showRules)
----F5 Staff GUI
local staff = {
        {"[HS]Rock", "Owner"},
		{"[AV]Amrin", "Admin"},
		{"[LB]Silver", "Admin"},
		{"Mohamed", "Admin"},
		{"Soap", "Admin"},
      

       
}       

Staff = {
    gridlist = {},
    window = {},
    button = {}
}

Staff.window[1] = guiCreateWindow(457, 0, 294, 336, "Important People", false)
guiWindowSetSizable(Staff.window[1], false)

Staff.gridlist[1] = guiCreateGridList(9, 30, 277, 294, false, Staff.window[1])
guiGridListAddColumn(Staff.gridlist[1], "Name", 0.5)
guiGridListAddColumn(Staff.gridlist[1], "Rank", 0.4)

	for i,v in ipairs(staff) do	
		local row = guiGridListAddRow(Staff.gridlist[1])
		local name = v[1]
		local rank = v[2]
		for index, k in ipairs(getElementsByType("player")) do
			if isElement(getPlayerFromName(k)) then
				guiGridListSetItemText(Staff.gridlist[1], row, 1, name, false, false)
				guiGridListSetItemText(Staff.gridlist[1], row, 2, rank, false, false)
				guiGridListSetItemColor(Staff.gridlist[1], row, 1, 255,255,255)
				guiGridListSetItemColor(Staff.gridlist[1], row, 2, 255,255,255)
			else
				guiGridListSetItemText(Staff.gridlist[1], row, 1, name, false, false)
				guiGridListSetItemText(Staff.gridlist[1], row, 2, rank, false, false)
				guiGridListSetItemColor(Staff.gridlist[1], row, 1, 55,55,55)
				guiGridListSetItemColor(Staff.gridlist[1], row, 2, 55,55,55)
			end
		end
	end
Staff.button[1] = guiCreateButton(90, 334, 115, 27, "Close", false, Staff.window[1])
guiSetProperty(Staff.button[1], "NormalTextColour", "FFAAAAAA")
guiSetVisible(Staff.window[1], false)
showCursor(false)

function showStaff()
	if guiGetVisible(Staff.window[1]) == false then
		guiSetVisible(Staff.window[1], true)
		showCursor(true)
	else
		guiSetVisible(Staff.window[1], false)
		showCursor(false)
	end
end
bindKey("F5","down", showStaff)
addCommandHandler("staff", showStaff)

function refreshStaffList()
guiGridListClear(Staff.gridlist[1])
	for i,v in ipairs(staff) do	
		local row = guiGridListAddRow(Staff.gridlist[1])
		local name = v[1]
		local rank = v[2]
		for index, k in ipairs(getElementsByType("player")) do
		    if isElement(getPlayerFromName(name)) then
				guiGridListSetItemText(Staff.gridlist[1], row, 1, name, false, false)
				guiGridListSetItemText(Staff.gridlist[1], row, 2, rank, false, false)
				guiGridListSetItemColor(Staff.gridlist[1], row, 1, 255,255,255)
				guiGridListSetItemColor(Staff.gridlist[1], row, 2, 255,255,255)
			else
				guiGridListSetItemText(Staff.gridlist[1], row, 1, name, false, false)
				guiGridListSetItemText(Staff.gridlist[1], row, 2, rank, false, false)
				guiGridListSetItemColor(Staff.gridlist[1], row, 1, 55,55,55)
				guiGridListSetItemColor(Staff.gridlist[1], row, 2, 55,55,55)
			end
		end
	end
end
setTimer(refreshStaffList, 1000,0)

function triggerCloseButton(btn, state)
	if btn == "left" then
		guiSetVisible(Staff.window[1], false)
		showCursor(false)
	end
end
addEventHandler("onClientGUIClick", Staff.button[1], triggerCloseButton, false)

function onPlayerChangeNick(old, new)
local account = getPlayerAccount(source)
	if not isGuestAccount(account) then
	local accountName = getAccountName(account);
		if staff[accountName] then
		staff[accountName][""] = new
		refreshStaff()
		end
	end
end
addEventHandler("onClientPlayerChangeNick", root, onClientPlayerChangeNick)
----Kill Money
----Lost Money
----Reward Money
function rewardOnWasted ( ammo, killer, killerweapon, bodypart )

	if ( killer ) and ( killer ~= source ) then
		givePlayerMoney ( killer, 1000 )
    end
end
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted )
----Dunno :p
function togglePlayerControl(weapon) 
	toggleControl("fire", false) 
	if getKeyState( "mouse1" ) == true and getKeyState( "mouse2" ) == true then
		toggleControl("fire", true) 
	end 
end 
addEventHandler ( "onClientRender", root, togglePlayerControl)

 

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