Storm-Hanma Posted February 1, 2018 Share Posted February 1, 2018 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) 1 Link to comment
itHyperoX Posted February 1, 2018 Share Posted February 1, 2018 (edited) 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 February 1, 2018 by TheMOG Link to comment
Storm-Hanma Posted February 1, 2018 Author Share Posted February 1, 2018 Actually there is no team leader function when player create team for example amazing casino now only this guy can access to kick or add to team hope you got it , That's why I use get elementdata Link to comment
pa3ck Posted February 1, 2018 Share Posted February 1, 2018 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
Storm-Hanma Posted February 1, 2018 Author Share Posted February 1, 2018 This function not working bro if getElementData(localPlayer, "player.key") == "amazingcasino" then Now amazing casino must add players to team or kick from team but it not happening there is no errors too In debug script Link to comment
pa3ck Posted February 1, 2018 Share Posted February 1, 2018 Where do you set that setElementData? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now