Snow-Man Posted December 10, 2016 Share Posted December 10, 2016 (edited) i'm making group system and i have got a problem to count group member using setElementData getElementData function getGroupMembers(group) if (not group) then return false end local memberCount = getElementData(group, "Members") or 0 return tonumber(memberCount) end Edited December 10, 2016 by Snow-Man Link to comment
LoPollo Posted December 10, 2016 Share Posted December 10, 2016 (edited) where do you set the member count of a group? post that block/function(s) Edited December 10, 2016 by LoPollo Link to comment
Snow-Man Posted December 10, 2016 Author Share Posted December 10, 2016 function createGroup(groupName) local account = getPlayerAccount(client) if (isGuestAccount(account)) then return end if (groupName) then outputChatBox(groupName.." is already an existing group", client, 255, 0, 0) return end setElementData(client, "Group", groupName) setElementData(client, "Rank", "Founder") setElementData(groupName, "Members", 1) outputChatBox("You have succesfully made a group called "..groupName, client, 0, 255, 0) end addEvent("createGroup", true) addEventHandler("createGroup", root, createGroup) that's a part of creating Group Link to comment
LoPollo Posted December 10, 2016 Share Posted December 10, 2016 (edited) createTeam Why not use it? and what do you want to do with if (groupName) then outputChatBox(groupName.." is already an existing group", client, 255, 0, 0) return end ? Answer to you question: it's a data bound to the player, you are not passing the player in the first post. You are passing "group", is it a string or what? Edited December 10, 2016 by LoPollo Link to comment
Snow-Man Posted December 10, 2016 Author Share Posted December 10, 2016 I'm making Group system not team Link to comment
LoPollo Posted December 10, 2016 Share Posted December 10, 2016 ok, sorry i didn't understand. I think you should keep track of the group as a separate element, instead of setting a player data. I'm not sure, i never used it, but createElement can be used to create an element right? create an element in which you store all the necessary data, if you really need an element. Another solution is to make a table that stores all the informations, it will be easier to manage also. local groups = { --["yourGroupName"] = { members = {somePlayer1, somePlayer2}, color = {255,255,255}, whatever = someValue }, } --member count of "yourGroupName" = #groups.yourGroupName.members Link to comment
Snow-Man Posted December 10, 2016 Author Share Posted December 10, 2016 i'm thinking to attach members to group and get info using player how can i do that? like tree elements in same time Link to comment
LoPollo Posted December 10, 2016 Share Posted December 10, 2016 Players are not meant to be used as data storage/database. I don't think that the elemnet tree can be used in this way to get data 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