Amenic Posted January 30, 2017 Share Posted January 30, 2017 Necessito um painel de clan Leader usando o set team, e convide para enviar a um jogador especifico online.. Não tenho nem ideia de como começar ...Pfv uma força Link to comment
xeon17 Posted January 30, 2017 Share Posted January 30, 2017 Not easy if you are a begginer. Server side can be done using OOP (less pain for the brain xD) If you don't speak English, check the portugues section. Link to comment
Amenic Posted January 30, 2017 Author Share Posted January 30, 2017 Ok, pode me dar um exemplo de (send invite) para aplicar no meu painel Att: Amenic Obrigado Link to comment
xeon17 Posted January 30, 2017 Share Posted January 30, 2017 This code should give you a idea how this can be done, but the last time i tried this code was in July, there could be unknown bugs Gang = {} Gang.__index = Gang Gang.instances = {} function Gang:create(name, r, g, b) local self = setmetatable({}, Gang) self.id = Gang.getFreeId() self.name = name self.team = Team(name, r, g, b) self.team:setData("id", self.id) table.insert(Gang.instances, self) return self end function Gang:getName() return self.name end function Gang:dispose() for index,instance in pairs(Gang.instances) do if (instance == self) then table.remove(Gang.instances, index) self.team:destroy() end end end function Gang.getFromMember(member) for index, gang in pairs(Gang.instances) do if(gang.team == member.team) then return gang end end return false end function Gang.getFromName(name) for index, gang in pairs(Gang.instances) do if(gang.team.name == name) then return gang end end return false end function Gang.getFromID(id) for index,gang in pairs(Gang.instances) do if (gang.id == id) then return gang end end return false end function Gang.getFreeId() for i=1, 100 do if not (Gang.getFromID(i)) then return i end end end addCommandHandler("gang", function (player, command, ...) local parameters = {...} local act = parameters[1] if(act == "create") then local name = table.concat ({parameters[2], parameters[3], parameters[4], parameters[5]}, " ") local gang = Gang:create(name, math.random(0,255),math.random(0,255),math.random(0,255)) player:setTeam(gang.team) player:outputChat("Gang successfully created!", 0, 255, 0) elseif(act == "delete") then local gang = Gang.getFromMember(player) if(gang) then gang:dispose() player:outputChat("Gang successfully deleted!", 0, 255, 0) end elseif (act == "invite") then local target = parameters[2] if (target) and (target ~= "") then if (player.team) then local gang = Gang.getFromName(player.team.name) if (getPlayerFromName(target)) then getPlayerFromName(target):setData("Invite", gang.name, false) player:outputChat("Invite sent to "..getPlayerFromName(target), 255, 255, 0) end else player:outputChat("A player with this name is not online", 255, 0, 0) end else player:outputChat("You have no gang bro", 255, 0, 0) end elseif(act == "accept") then if not (player:getData("Invite") == false) then local gangName = player:getData("Invite") local gang = Gang.getFromName(gangName) if (gang) then player:outputChat("Welcome in "..gangName, 0, 255, 0) player:setTeam(gang.team) player:removeData("Invite") end else player:outputChat("You were not invited to join any gang", 255, 0, 0) end end end) addEventHandler("onResourceStart", resourceRoot, function () addCommandHandler("gangs", function (player, command) player:outputChat("Gangs:", 255, 255, 0) for index,instance in pairs (Gang.instances) do player:outputChat("ID: "..instance.id.." Name: "..instance.name.."", 255, 255, 0) end end) end) 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