Jump to content

[Help]teampanel


Storm-Hanma

Recommended Posts

hello all i created a teampanel all works fine but problem is in adding players to team which only leader must do!

for exmaple i created team and if i need to add players to team i tried with 

if getElementData(localPlayer, "player.key") == "amazingcasino" then
  
 

but it doesn't work below is  full code

addEventHandler("onClientGUIClick", guiRoot,
function()
 if getElementData(localPlayer, "player.key") == "amazingcasino" then
			if source == GUIEditor.button[3] then
        local row, column = guiGridListGetSelectedItem( GUIEditor.gridlist[1])
        if row == -1 then return end
        local playerName = guiGridListGetItemText( GUIEditor.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("Add to team", localPlayer,playerName,teamName)
		end
		end
			
			
		
end)

 

  • Like 1
Link to comment

try this:

-- command for set you as leader
addCommandHandler("leader", function()
    setElementData(localPlayer, "team:leader", true)
end)



addEventHandler("onClientGUIClick", guiRoot, function()
    if (getElementData(localPlayer, "team:leader") == true) then
	    iprint("I'm a leader!")
		
		
		if source == GUIEditor.button[3] then
	        local row, column = guiGridListGetSelectedItem( GUIEditor.gridlist[1])
			
			
	        if (row ~= - 1) then
			
	            local playerName = guiGridListGetItemText( GUIEditor.gridlist[1],row,column)
	            local player = getPlayerFromName(playerName)
	            local team = getPlayerTeam(localPlayer)
	            local teamName = getTeamName(team)
	
	            if not playerName then
	                return guiGridListRemoveRow(row)
	            end

				triggerServerEvent("Add to team", localPlayer, playerName, teamName)
		
	        end	
			
	    end
			
	end
	
end)

 

Edited by TheMOG
Link to comment

It's not clear what you're trying to do and what your problem is. So you want the leader to be able to add / kick players, but you don't know who the leader is? What is wrong with your code? Any errors? Which "if" statement does the execution fail at? 

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