steadyfi Posted February 27, 2015 Share Posted February 27, 2015 Hello. I have a little problem with my Team System. I want to save all the teams into a XML file so when the resource restarts they will all be loaded back. I know I have to do it with a for loop and some XML functions but I don't really get it in my case. I read the wiki on xmlNodeGetChildren but it doesn't help me too much. The script works like this. There is a root node in the XML called . Then, every team is in a node with the attribute name="Exemple". I want to loop thru all of those and on every loop I want to get the XML attribute and then create a team with that name and do it over and over again. My thoughts on what I understood so far are that the script need to look like this: Server Side Script: --XML Code addEventHandler("onResourceStart", resourceRoot, function() local xmlFile = xmlLoadFile("teams.xml") local xmlNodes = xmlNodeGetChildren(xmlFile) for _,node in ipairs(xmlNodes) do local team = xmlNodeGetAttribute(node) createTeam(team) end end) XML File (teams.xml): <root> <team name="Test"/> <team name="TestTest"/> </root> Thanks. Edit: Sorry for the double-post ! My left click is crazy and annoying. I deleted the duplicate Link to comment
Et-win Posted February 27, 2015 Share Posted February 27, 2015 https://wiki.multitheftauto.com/wiki/Xm ... tAttribute string xmlNodeGetAttribute ( xmlnode node, string name ) Link to comment
steadyfi Posted February 27, 2015 Author Share Posted February 27, 2015 https://wiki.multitheftauto.com/wiki/XmlNodeGetAttributestring xmlNodeGetAttribute ( xmlnode node, string name ) Yeah... I don't really get it. I already used it. Sorry if I'm stupid but it's my first time using XML to store and read things and I already crawled through the entire section on XML Function on the wiki. Could you please show me an example or how I can fix it ? Link to comment
Tekken Posted February 27, 2015 Share Posted February 27, 2015 This is the full code ? Link to comment
steadyfi Posted February 27, 2015 Author Share Posted February 27, 2015 This is the full code ? Nope ! Edit: Load teams from XML problem SOLVED ! Link to comment
KaduRo Posted February 28, 2015 Share Posted February 28, 2015 Would you please show us how it work (no need to use your code) ? Link to comment
steadyfi Posted February 28, 2015 Author Share Posted February 28, 2015 Would you please show us how it work (no need to use your code) ? Edit: Source Code: (Server-Side) function getPlayerFromPartialName(who) --Useful Function | Author: TAPL local who = who and who:gsub("#%x%x%x%x%x%x", ""):lower() or nil if who then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(who, 1, true) then return player end end end end --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x-- function createATeam(source, commandName, teamName) team = getPlayerTeam(source) if team then outputChatBox("You are already in a team", source, 255, 0, 0) return end if teamName then local newTeam = createTeam(teamName) if newTeam then setPlayerTeam(source, newTeam) local playerAccount = getPlayerAccount(source) setAccountData(playerAccount, "isTeamLeader", true) --XML local xmlFile = xmlLoadFile("teams.xml", "root") local team = xmlCreateChild(xmlFile, "team") local success = xmlNodeSetAttribute(team, "name", teamName) if success then xmlSaveFile(xmlFile) elseif not success then outputChatBox("XML FATAL ERROR: Failed to save a team in the XML Team file") destroyElement(team) end --END XML outputChatBox("Successfully created team with name: "..teamName, source, 0, 255, 0) end else outputChatBox("Please enter a team name", thePlayer, 255, 0, 0) end end addCommandHandler("create", createATeam) function inviteToTeam(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true then local target = getPlayerFromPartialName(who) if target then if target ~= thePlayer then if not getElementData(target, "invited_to_team") then local teamName = getTeamName(team) setElementData(target, "invited_to_team", true) setElementData(target, "team_invited_to", teamName) setElementData(target, "inviters_name", thePlayer) outputChatBox("Invited player "..target.." to team !", thePlayer, 0, 255, 0) outputChatBox("You were invited to the team"..teamName.." !", target, 0, 255, 0) outputChatBox("Type '/team accept' or '/team deny'", target, 0, 255, 0) elseif getElementData(target, "invited_to_team") then outputChatBox("The player is already invited to a team", thePlayer, 255, 0, 0) return end else outputChatBox("You cannot invite yourself", thePlayer, 255, 0, 0) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access forbidden", thePlayer, 255, 0, 0) end else outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("invite", inviteToTeam) function inviteHandling(thePlayer, cmd, arg) if arg then if getElementData(thePlayer, "invited_to_team") == true then if arg == "accept" then local team = getPlayerTeam(thePlayer) if getPlayerTeam(thePlayer) == nil then local inviterElement = getElementData(thePlayer, "inviters_name") local theTeam = getElementData(thePlayer, "team_invited_to") local thePlayersName = getPlayerName(thePlayer) local inviter = getPlayerFromName(inviterElement) local teamName = getTeamName(theTeam) setPlayerTeam(thePlayer, theTeam) outputChatBox(thePlayersName.." has joined !", inviter, 0, 255, 0) setElementData(thePlayer, "invited_to_team", false) elseif team then outputChatBox("You are already in a team ! Leave it before joining another.", thePlayer, 255, 0, 0) end elseif arg == "deny" then local inviterElement = getElementData(thePlayer, "inviters_name") local thePlayersName = getPlayerName(thePlayer) local inviter = getPlayerFromName(inviterElement) setElementData(thePlayer, "invited_to_team", false) setElementData(thePlayer, "team_invited_to", false) outputChatBox(thePlayersName.." has declined the invitation !", inviter, 255, 0, 0) outputChatBox("Invitation declined", thePlayer, 0, 255, 0) end else outputChatBox("You are not invited to any team", thePlayer, 255, 0, 0) end else outputChatBox("Argument 2 is missing. arg2 = accept/deny", thePlayer, 255, 0, 0) end end addCommandHandler("team", inviteHandling) function setAnotherPlayerLeader(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true then target = getPlayerFromPartialName(who) if target then if target ~= thePlayer then if getPlayerTeam(target) == team then local targetAccount = getPlayerAccount(target) setAccountData(targetAccount, "isTeamAdmin", true) local targetPlayerName = getPlayerName(target) outputChatBox(targetPlayerName.." added as leader !", thePlayer, 0, 255, 0) local teamName = getTeamName(team) outputChatBox("You were added as a leader in team: "..teamName.." !", target, 0, 255, 0) else outputChatBox("Player not in team", thePlayer, 255, 0, 0) end else outputChatBox("You cannot permit yourself", thePlayer, 255, 0, 0) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access Forbidden", thePlayer, 255, 0, 0) end else outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("permit", setAnotherPlayerLeader) function kickFromTeam(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true or getAccountData(playerAccount, "isTeamAdmin") == true then target = getPlayerFromPartialName(who) if target then if target ~= thePlayer then if getPlayerTeam(target) == team then local targetAccount = getPlayerAccount(target) if not getAccountData(targetAccount, "isTeamLeader") then setPlayerTeam(target, nil) local targetPlayerName = getPlayerName(target) outputChatBox("Kicked "..targetPlayerName.." from team !", thePlayer, 0, 255, 00) outputChatBox("You were kicked from the team ! D:", target, 255, 0, 0) else outputChatBox("You cannot kick the leader !", thePlayer) end else outputChatBox("Player not in team", thePlayer, 255, 0, 0) end else outputChatBox("You cannot kick yourself", thePlayer, 255, 0, 0) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access Forbidden", thePlayer, 255, 0, 0) end else outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("tkick", kickFromTeam) function leaveTeam(thePlayer) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if not getAccountData(playerAccount, "isTeamLeader") then if getAccountData(playerAccount, "isTeamAdmin") then setAccountData(playerAccount, "isTeamAdmin", false) end setPlayerTeam(thePlayer, nil) local teamName = getTeamName(team) outputChatBox("You left the team "..teamName.." !", thePlayer, 0, 255, 0) local teamPlayers = getPlayersInTeam(team) local playerName = getPlayerName(thePlayer) for playerKey, playerValue in ipairs(teamPlayers) do outputChatBox(playerName.." left the team ! D:", playerValue, 255, 0, 0) end else outputChatBox("You can not leave as a leader", thePlayer, 255, 0, 0) end else outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("leave", leaveTeam) function deleteTeam(thePlayer) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") then local teamPlayers = getPlayersInTeam(team) for playerKey, playerValue in ipairs(teamPlayers) do if playerValue ~= thePlayer then accTeamMembers = getPlayerAccount(playerValue) if getAccountData(accTeamMembers, "isTeamAdmin") then setAccountData(accTeamMembers, "isTeamAdmin", false) end setPlayerTeam(playerValue, nil) outputChatBox("Kicked from team because it was deleted \"{SMILIES_PATH}/icon_sad.gif\" alt=\"\" title=\"Sad\" />", playerValue, 255, 0, 0) end end --XML local teamName = getTeamName(team) local xmlFile = xmlLoadFile("teams.xml") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attributes = xmlNodeGetAttributes(node) if attributes == teamName then xmlDestroyNode(node) end end --END XML destroyElement(team) setAccountData(playerAccount, "isTeamLeader", false) setPlayerTeam(thePlayer, nil) outputChatBox("The team has been deleted", thePlayer, 0, 255, 0) else outputChatBox("Access Forbidden", thePlayer, 255, 0, 0) end else outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end Link to comment
Et-win Posted February 28, 2015 Share Posted February 28, 2015 This was the solution: local team = xmlNodeGetAttribute(node) To: local team = xmlNodeGetAttribute(node, "name") Link to comment
steadyfi Posted February 28, 2015 Author Share Posted February 28, 2015 This was the solution: local team = xmlNodeGetAttribute(node) To: local team = xmlNodeGetAttribute(node, "name") Thanks but the XML Loading system works, my problem is the Deleting system. I already did something but it doesn't work. I need to search for the team name through more XML Nodes with the same name and get the attribute that is equal to the team name that is being deleted and delete that node. Ex: XML: <root> <team name="Test"></team> <team name="TestTwo"></team> </root> And let's say I want to delete TestTwo, how do I do to find it ? My current code is this: (Server-Side) (it doesn't work) --XML local teamName = getTeamName(team) local xmlFile = xmlLoadFile("teams.xml") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attributes = xmlNodeGetAttributes(node) if attributes == teamName then xmlDestroyNode(node) end end --END XML Link to comment
WhoAmI Posted February 28, 2015 Share Posted February 28, 2015 local teamName = getTeamName(team) local xmlFile = xmlLoadFile("teams.xml") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attribute = xmlNodeGetAttribute(node, "name") if attribute == teamName then xmlDestroyNode(node) end end Link to comment
steadyfi Posted February 28, 2015 Author Share Posted February 28, 2015 local teamName = getTeamName(team) local xmlFile = xmlLoadFile("teams.xml") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attribute = xmlNodeGetAttribute(node, "name") if attribute == teamName then xmlDestroyNode(node) end end Didn't work.. it still remains in the teams.xml file Edit: Ups... i forgot to add xmlSaveFile(xmlFile) ! Now it works. Thank you Link to comment
WhoAmI Posted February 28, 2015 Share Posted February 28, 2015 Well, put outputChatBox ( attribute ) after attribute variable and check what it outputs. Link to comment
steadyfi Posted February 28, 2015 Author Share Posted February 28, 2015 Well, put outputChatBox ( attribute ) after attribute variable and check what it outputs. It works, i just added xmlSaveFile after xmlDestroyNode and it worked. Thank you. Off-topic: Do you want to come on my server and help me test it ? It need 2 players and I am the only one. Link to comment
WhoAmI Posted February 28, 2015 Share Posted February 28, 2015 Why not, I have some time. Send my IP in priv. And add xmlSaveFile after ending a loop, not inside. Should look like this local teamName = getTeamName(team) local xmlFile = xmlLoadFile("teams.xml") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attribute = xmlNodeGetAttribute(node, "name") if attribute == teamName then xmlDestroyNode(node) end end xmlSaveFile(xmlFile) Link to comment
Moderators IIYAMA Posted March 2, 2015 Moderators Share Posted March 2, 2015 Don't forget to unload it. Link to comment
steadyfi Posted March 2, 2015 Author Share Posted March 2, 2015 Don't forget to unload it. What happens if I don't unload it ? Security (hackers, etc..) ? Resource consumption ? Link to comment
WhoAmI Posted March 2, 2015 Share Posted March 2, 2015 Nah, it's just heavy thing to server. Link to comment
Moderators IIYAMA Posted March 2, 2015 Moderators Share Posted March 2, 2015 Don't forget to unload it. What happens if I don't unload it ? Security (hackers, etc..) ? Resource consumption ? No, it remains in your server ram, which gives you less ram for your other stuff. Not really a big deal for a small xml file, but when it gets larger it might starts to lagg. Even so I recommend you, to make unloading xml files a habit. https://wiki.multitheftauto.com/wiki/XmlUnloadFile Link to comment
steadyfi Posted March 3, 2015 Author Share Posted March 3, 2015 Don't forget to unload it. What happens if I don't unload it ? Security (hackers, etc..) ? Resource consumption ? No, it remains in your server ram, which gives you less ram for your other stuff. Not really a big deal for a small xml file, but when it gets larger it might starts to lagg. Even so I recommend you, to make unloading xml files a habit. https://wiki.multitheftauto.com/wiki/XmlUnloadFile Nah, it's just heavy thing to server. Ok Thanks By the way, how do I set player blips if in team ? I have this script (Client Side) but it only executes when the resource is started. How can I add a triggerClientEvent() in the server script without sending elements as I don't have any ? Or i can just call teh function ? (it is in the same resource) Client-Side Script: function showPlayersFromTeamOnGPS() team = getPlayerTeam(getLocalPlayer()) if team and getTeamName(team) ~= "Player" or getTeamName(team) ~= "Zombie" then teamPlayers = getPlayersInTeam(team) for playerKey,playerValue in ipairs(teamPlayers) do if playerValue ~= getLocalPlayer() then teamBlip = createBlipAttachedTo(playerValue, 0, 2, 0, 255, 255, 255) end end end end addEventHandler("onClientResourceStart", getRootElement(), showPlayersFromTeamOnGPS) Sorry if it doesn't match the title anymore. Link to comment
Tekken Posted March 3, 2015 Share Posted March 3, 2015 addEvent("setBlip", true) addEventHandler("setBlip", getRootElement(), showPlayersFromTeamOnGPS) And use triggerEvent("setBlip", root) Link to comment
steadyfi Posted March 3, 2015 Author Share Posted March 3, 2015 addEvent("setBlip", true) addEventHandler("setBlip", getRootElement(), showPlayersFromTeamOnGPS) And use triggerEvent("setBlip", root) Didn't work. Server-Side: --##DEVELOPMENT CODE for id, playerAbc in ipairs(getElementsByType("player")) do thePlayersAccount = getPlayerAccount(playerAbc) setAccountData(thePlayersAccount, "isTeamAdmin", false) setAccountData(thePlayersAccount, "isTeamLeader", false) setAccountData(thePlayersAccount, "invited_to_team", false) setAccountData(thePlayersAccount, "team_invited_to", false) end --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x-- function getPlayerFromPartialName(who) --Useful Function | Author: TAPL local who = who and who:gsub("#%x%x%x%x%x%x", ""):lower() or nil if who then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(who, 1, true) then return player end end end end --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x-- function createATeam(source, commandName, teamName) local team = getPlayerTeam(source) if team then outputChatBox("You are already in a team", source, 255, 0, 0) return end if teamName then --Check if team already exists local xmlFile = xmlLoadFile("teams.xml", "root") local children = xmlNodeGetChildren(xmlFile) for i,node in pairs(children) do local attribute = xmlNodeGetAttribute(node, "name") if attribute == teamName then outputChatBox("This team already exists", source, 255, 0 ,0) return end end xmlUnloadFile(xmlFile) --END local newTeam = createTeam(teamName) if newTeam then setPlayerTeam(source, newTeam) local playerAccount = getPlayerAccount(source) setAccountData(playerAccount, "isTeamLeader", true) --XML local xmlFile = xmlLoadFile("teams.xml", "root") local team = xmlCreateChild(xmlFile, "team") local success = xmlNodeSetAttribute(team, "name", teamName) if success then xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end --END XML outputChatBox("Successfully created team with name: "..teamName, source, 0, 255, 0) triggerEvent("setBlip", root) else outputChatBox("An error accrued while creating the team", source, 255, 0, 0) end else outputChatBox("Please enter a team name", thePlayer, 255, 0, 0) end end addCommandHandler("create", createATeam) function inviteToTeam(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true then local target = getPlayerFromPartialName(who) if target then if target ~= thePlayer then if not getElementData(target, "invited_to_team") then local teamName = getTeamName(team) setElementData(target, "invited_to_team", true) setElementData(target, "team_invited_to", teamName) outputChatBox("Invited player "..getPlayerName(target).." to team !", thePlayer, 0, 255, 0) outputChatBox("You were invited to the team: "..teamName.." !", target, 0, 255, 0) outputChatBox("Type '/team accept' or '/team deny'", target, 0, 255, 0) elseif getElementData(target, "invited_to_team") then outputChatBox("The player is already invited to a team", thePlayer, 255, 0, 0) return end else outputChatBox("You cannot invite yourself", thePlayer, 255, 0, 0) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access forbidden", thePlayer, 255, 0, 0) end else outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("invite", inviteToTeam) function inviteHandling(thePlayer, cmd, arg) if arg then if getElementData(thePlayer, "invited_to_team") == true then if arg == "accept" then local team = getPlayerTeam(thePlayer) if not (team) then local theTeam = getTeamFromName(getElementData(thePlayer, "team_invited_to")) local playerName = getPlayerName(thePlayer) local teamPlayers = getPlayersInTeam(theTeam) setPlayerTeam(thePlayer, theTeam) outputChatBox("Joined team "..getTeamName(theTeam), thePlayer, 0, 255, 0) for playerKey, playerValue in ipairs(teamPlayers) do outputChatBox(playerName.." joined the team !", playerValue, 0, 255, 0) end setElementData(thePlayer, "invited_to_team", false) triggerEvent("setBlip", root) elseif team then outputChatBox("You are already in a team ! Leave it before joining another.", thePlayer, 255, 0, 0) end elseif arg == "deny" then local playerName = getPlayerName(thePlayer) setElementData(thePlayer, "invited_to_team", false) setElementData(thePlayer, "team_invited_to", false) --outputChatBox(playerName.." has declined the invitation !", inviter, 255, 0, 0) outputChatBox("Invitation declined", thePlayer, 0, 255, 0) end else outputChatBox("You are not invited to any team", thePlayer, 255, 0, 0) end else outputChatBox("Argument 2 is missing. arg2 = accept/deny", thePlayer, 255, 0, 0) end end addCommandHandler("team", inviteHandling) function permitAPlayer(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true then target = getPlayerFromPartialName(who) if target then local targetAccount = getPlayerAccount(target) if not getAccountData(targetAccount, "isTeamLeader") then if target ~= thePlayer then if getPlayerTeam(target) == team then if not getAccountData(targetAccount, "isTeamAdmin") then setAccountData(targetAccount, "isTeamAdmin", true) local targetPlayerName = getPlayerName(target) outputChatBox(targetPlayerName.." added as admin !", thePlayer, 0, 255, 0) local teamName = getTeamName(team) outputChatBox("You were added as a admin in team: "..teamName.." !", target, 0, 255, 0) elseif getAccountData(targetAccount, "isTeamAdmin") then setAccountData(targetAccount, "isTeamAdmin", false) local targetPlayerName = getPlayerName(target) outputChatBox(targetPlayerName.." removed as admin !", thePlayer, 0, 255, 0) local teamName = getTeamName(team) outputChatBox("You were removed as a admin in team: "..teamName.." !", target, 0, 255, 0) end else outputChatBox("Player not in team", thePlayer, 255, 0, 0) end else outputChatBox("You cannot permit yourself", thePlayer, 255, 0, 0) end else outputChatBox("You cannot permit a leader", thePlayer) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access Forbidden", thePlayer, 255, 0, 0) end elseif not (team) then outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("permit", permitAPlayer) function kickFromTeam(thePlayer, cmd, who) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if getAccountData(playerAccount, "isTeamLeader") == true or getAccountData(playerAccount, "isTeamAdmin") == true then target = getPlayerFromPartialName(who) if target then if target ~= thePlayer then if getPlayerTeam(target) == team then local targetAccount = getPlayerAccount(target) if not getAccountData(targetAccount, "isTeamLeader") then setPlayerTeam(target, nil) local targetPlayerName = getPlayerName(target) outputChatBox("Kicked "..targetPlayerName.." from team !", thePlayer, 0, 255, 00) outputChatBox("You were kicked from the team ! D:", target, 255, 0, 0) triggerEvent("setBlip", root) else outputChatBox("You cannot kick the leader !", thePlayer) end else outputChatBox("Player not in team", thePlayer, 255, 0, 0) end else outputChatBox("You cannot kick yourself", thePlayer, 255, 0, 0) end else outputChatBox("Failed to fetch target", thePlayer, 255, 0, 0) end else outputChatBox("Access Forbidden", thePlayer, 255, 0, 0) end elseif not (team) then outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("tkick", kickFromTeam) function leaveTeam(thePlayer) local team = getPlayerTeam(thePlayer) if team then local playerAccount = getPlayerAccount(thePlayer) if not getAccountData(playerAccount, "isTeamLeader") then if getAccountData(playerAccount, "isTeamAdmin") then setAccountData(playerAccount, "isTeamAdmin", false) end setPlayerTeam(thePlayer, nil) local teamName = getTeamName(team) outputChatBox("You left the team "..teamName.." !", thePlayer, 0, 255, 0) local teamPlayers = getPlayersInTeam(team) local playerName = getPlayerName(thePlayer) for playerKey, playerValue in ipairs(teamPlayers) do outputChatBox(playerName.." left the team ! D:", playerValue, 255, 0, 0) end triggerEvent("setBlip", root) else outputChatBox("You can not leave as a leader", thePlayer, 255, 0, 0) end elseif not (team) then outputChatBox("You are not in a team", thePlayer, 255, 0, 0) end end addCommandHandler("leave", leaveTeam) function deleteTeam(thePlayer) local team = getPlayerTeam(thePlayer) if Link to comment
Tekken Posted March 3, 2015 Share Posted March 3, 2015 You need to remuve the old one : function showPlayersFromTeamOnGPS() team = getPlayerTeam(getLocalPlayer()) if team then teamPlayers = getPlayersInTeam(team) for playerKey,playerValue in ipairs(teamPlayers) do if playerValue ~= getLocalPlayer() then teamBlip = createBlipAttachedTo(playerValue, 0, 2, 0, 255, 255, 255) end end end end addEvent("setBlip", true) addEventHandler("setBlip", getRootElement(), showPlayersFromTeamOnGPS) Link to comment
steadyfi Posted March 3, 2015 Author Share Posted March 3, 2015 You need to remuve the old one : function showPlayersFromTeamOnGPS() team = getPlayerTeam(getLocalPlayer()) if team then teamPlayers = getPlayersInTeam(team) for playerKey,playerValue in ipairs(teamPlayers) do if playerValue ~= getLocalPlayer() then teamBlip = createBlipAttachedTo(playerValue, 0, 2, 0, 255, 255, 255) end end end end addEvent("setBlip", true) addEventHandler("setBlip", getRootElement(), showPlayersFromTeamOnGPS) Thank you, I will test it later because I have a bit of work right now. #SOLVED i hope 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