fargot.. Posted March 9, 2017 Share Posted March 9, 2017 السلام عليكم و رحمة الله وبركاته انا معي مود قروب سيستم ما يشتغل بعد ما شغلت حقت بقات يظهر لي كذا WARNING: Group_System/server.lua:58: Bad argument @ 'aclGroupRemoveObject' [Expected acl -group at argument 1, got boolean] وش معنا ذي و كيف اصلحها ارجو الرد Link to comment
AHMED MOSTAFA Posted March 9, 2017 Share Posted March 9, 2017 5 minutes ago, Ad[N]a[N]e said: السلام عليكم و رحمة الله وبركاته انا معي مود قروب سيستم ما يشتغل بعد ما شغلت حقت بقات يظهر لي كذا WARNING: Group_System/server.lua:58: Bad argument @ 'aclGroupRemoveObject' [Expected acl -group at argument 1, got boolean] وش معنا ذي و كيف اصلحها ارجو الرد اطرح السطر 58 في ملف server.lua 1 Link to comment
fargot.. Posted March 9, 2017 Author Share Posted March 9, 2017 7 minutes ago, Killer Project said: اطرح السطر 58 في ملف server.lua كيف اطرح 58 ؟؟ Link to comment
AHMED MOSTAFA Posted March 9, 2017 Share Posted March 9, 2017 Just now, Ad[N]a[N]e said: كيف اطرح 58 ؟؟ اعرضه لنا او يفضل تعرض ملف سيرفر كله 1 Link to comment
fargot.. Posted March 9, 2017 Author Share Posted March 9, 2017 8 minutes ago, a7zan said: اطرح الاكواد 14 minutes ago, Killer Project said: اعرضه لنا او يفضل تعرض ملف سيرفر كله ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------ ------ ------|Group System|------ ------ ------ ------ ------- ------- ------- ------- ------- ------- ------- ------- ------- output = function( text, element, r, g, b, vaule ) exports["guimessages"]:outputServer(element, text, r, g, b) end function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end function getTopPointGroup() local results = dbPoll(dbQuery(db, "SELECT group_name, total_turf FROM groups"), -1) if #results >= 1 then local sortedPointGroupTable = {} for i, values in pairs(results) do table.insert(sortedPointGroupTable, {values["group_name"], values["total_turf"]}) end table.sort(sortedPointGroupTable, function(a, b) return tonumber(a[2]) > tonumber(b[2]) end) local finalTablePointGroup = {} for i, valueT in pairs(sortedPointGroupTable) do if i >= 1 and i <= 1 then table.insert(finalTablePointGroup, {valueT[1], valueT[2]}) end return finalTablePointGroup end end if i == 1 then return finalTablePointGroup end end addEvent("OnBestHeltheGroup", true) addEventHandler("OnBestHeltheGroup", root, function () setPedStat (source, 24, 700 ) setElementHealth( source, 200 ) end ) addEvent("OnGiveTagPointGroup", true) addEventHandler("OnGiveTagPointGroup", root, function() aclGroupAddObject (aclGetGroup("Best-Group"), "user."..getAccountName(getPlayerAccount(source))) end ) addEvent("OnRemoveTagPointGroup", true) addEventHandler("OnRemoveTagPointGroup", root, function() aclGroupRemoveObject (aclGetGroup("Best-Group"), "user."..getAccountName(getPlayerAccount(source))) end ) function GivePointGroup() dbExec(db,"UPDATE groups SET total_turf = total_turf + 1 WHERE group_name = ?",getElementData ( source,"Group" )) end addEvent("OnPointGroups", true) addEventHandler("OnPointGroups", root, GivePointGroup) setTimer(function() triggerEvent("Send_Groups_List",root) end,60000,0,true) function restPoint(player) if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)),aclGetGroup("Staff")) then dbExec(db,"UPDATE groups SET total_turf = 0") triggerEvent("Send_Groups_List",root) exports["guimessages"]:outputServer (player,"[Point System] #00FF00Restart Point Group Has been Successfully", 0, 255, 255) end end addCommandHandler("RePG", restPoint) function myPointGroups(player) if getElementData(player,"Group") then local h = dbQuery(db,"SELECT total_turf FROM groups WHERE group_name = ?",getElementData(player,"Group")) local MyPointGrpi = dbPoll(h, -1) if(#MyPointGrpi == 0) then exports["guimessages"]:outputServer (player,"[Point System] #FFFF00Your Points Group #00FF00("..convertNumber(MyPointGrpi[1].total_turf)..") #FFFF00Point !", 0, 255, 255,true) else exports["guimessages"]:outputServer (player,"[Point System] #FFFF00Your Points #C8223BGroup #00FF00("..convertNumber(MyPointGrpi[1].total_turf)..") #FFFF00Point !", 0, 255, 255,true) end end end addCommandHandler("mypointgroup", myPointGroups) addCommandHandler("mypointgroup", myPointGroups) addCommandHandler("mypointgroup", myPointGroups) addCommandHandler("mypointgroup", myPointGroups) addCommandHandler("addpointgroup", function ( player,cmd,Group,point ) if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)),aclGetGroup("Staff")) then if (point) then if (Group) then local groups = getPlayerGroup(player) if groups then dbExec(db,"UPDATE groups SET total_turf = total_turf + "..point.." WHERE group_name = ?", getElementData (player,"Group" )) exports["guimessages"]:outputServer (player,"[Point System] #00FF00You Take Group #FFFF00"..Group..", #FFFFFF"..point.." #00FF00Point Group ", 255, 255, 0) triggerEvent("Send_Groups_List",root) else exports["guimessages"]:outputServer (player,"[Point System] #FF0000Group not found. ", 255, 255, 0)end end else exports["guimessages"]:outputServer (player,"[Point System] #FF0000 Please Get Point ", 255, 255, 0) end else exports["guimessages"]:outputServer (player,"[Point System] #FF0000 Please Creer Group to get point ", 255, 255, 0) end end ) function data() local time = getRealTime() return time.monthday.."/"..time.month + 1 .."/"..time.year + 1900 end addEventHandler("onResourceStart", resourceRoot, function() local data = data() exports.scoreboard:addScoreboardColumn("Group", root, 3, 80) db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS groups (group_name, group_owner, group_members INT, members_limit, group_info, group_history, group_bank INT, turf_color, total_turf, skinID, MessageLeaved, Chat_color)") dbExec(db, "CREATE TABLE IF NOT EXISTS group_ranks (group_name, group_rank_name, group_rank_permission, rank_type)") dbExec(db, "CREATE TABLE IF NOT EXISTS group_members (group_name, member_account, member_name, member_status, member_rank, last_online, WL, mute, AFK)") dbExec(db, "CREATE TABLE IF NOT EXISTS group_invite (group_name, player_account, byy)") dbExec(db, "CREATE TABLE IF NOT EXISTS group_alliances (group_name1, group_name2, status)") dbExec(db, "CREATE TABLE IF NOT EXISTS group_blackList (group_name, player_account, responsible, reason, time)") dbExec(db, "CREATE TABLE IF NOT EXISTS group_history (group_name, action, data)") dbExec(db, "CREATE TABLE IF NOT EXISTS MessageLeaved (group_name, Time, Name, Account, Message)") for i, player in ipairs(getElementsByType("player")) do local groupName = getPlayerGroup(player) if groupName then setElementData(player, "Group", groupName) setElementData(player, "GroupAlliances", getGroupAlliances(groupName)) setElementData(player, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(player)}) dbExec(db, "UPDATE group_members SET member_name = ?, member_status = ?, last_online = ? WHERE group_name = ? AND member_account = ?", getPlayerName(player),"Yes",data,groupName,getAccountName(getPlayerAccount(player))) else setElementData(player, "Group", false) setElementData(player, "GroupAlliances", false) setElementData(player, "GroupRank", false) end end end) function increaseGroupTurfPoint(groupName) if groupName then dbExec(db, "UPDATE groups SET total_turf = total_turf + 2 WHERE group_name = ?", groupName) end end addEvent("onGroupTurf", true) addEventHandler("onGroupTurf", root, increaseGroupTurfPoint) function geMemberMuteStat(accountName) local result = dbPoll(dbQuery(db, "SELECT mute FROM group_members WHERE member_account = ?", accountName), -1) if type(result) == "table" and #result ~= 0 then return result[1]["mute"] end end function geMemberAFKStat(accountName) local result = dbPoll(dbQuery(db, "SELECT AFK FROM group_members"), -1) if type(result) == "table" and #result ~= 0 then return result[1]["AFK"] end end function getGroupTurfColor(group) if group and IsGroupExists(group) then local h = dbQuery(db, "SELECT turf_color FROM groups WHERE group_name = ?", group) local result = dbPoll(h, -1) return split(result[1]["turf_color"], ',') end end function getGroupChatColor(group) if group and IsGroupExists(group) then local h = dbQuery(db, "SELECT Chat_color FROM groups WHERE group_name = ?", group) local result = dbPoll(h, -1) return split(result[1]["Chat_color"], ',') end end addEvent("chgMuteStat", true) addEventHandler("chgMuteStat", root, function(groupName, accountName) if IsGroupExists(groupName) then if geMemberMuteStat(accountName) == "true" then dbExec(db, "UPDATE group_members SET mute = ? WHERE member_account = ?", "false", accountName) exports["guimessages"]:outputServer (source, "[Group System] #00FF00You Have unMuted "..getGroupMemberName(accountName).." On Group Chat.", 51, 153, 255) setNewGrouplog ( groupName, "Player "..getPlayerName(source).." unMuted "..getGroupMemberName(accountName).." on Group Chat.") triggerEvent("Request_myGroup_MembersList", source, getElementData(source, "Group")) local player = getAccountPlayer(getAccount(accountName)) if player then exports["guimessages"]:outputServer (player,"[Group System] #00FF00You have been UnMuted on group chat by #FFFF00"..getPlayerName(source), 51, 153, 255) end else dbExec(db, "UPDATE group_members SET mute = ? WHERE member_account = ?", "true", accountName) exports["guimessages"]:outputServer (source, "[Group System] #FF0000 Have Muted "..getGroupMemberName(accountName).." On Group Chat.", 51, 153, 255) setNewGrouplog ( groupName, "Player "..getPlayerName(source).." Muted "..getGroupMemberName(accountName).." on Group Chat.") triggerEvent("Request_myGroup_MembersList", source, getElementData(source, "Group")) local player = getAccountPlayer(getAccount(accountName)) if player then exports["guimessages"]:outputServer (player,"[Group System] #FF0000You Have been Muted on Group Chat by "..getPlayerName(source), 51, 153, 255) end end else exports["guimessages"]:outputServer (source, "[Group System] #FF0000This group doesn't exists.", 51, 153, 255) end end) function getGroupSkinID(groupName) local result = dbPoll(dbQuery(db, "SELECT skinID FROM groups WHERE group_name = ?", groupName), -1) if type(result) == "table" and #result ~= 0 then return result[1]["skinID"] end end addEventHandler("onPlayerSpawn", root, function() local groupName = getElementData(source, "Group") if groupName and getPlayerTeam(source) and getPlayerTeam(source) == getTeamFromName("No Team") then local skinID = tonumber(getGroupSkinID(groupName)) if skinID then setTimer(setElementModel, 50, 1, source, skinID) end end end) function setGroupSkinID(groupName, skinID) if IsGroupExists(groupName) then dbExec(db, "UPDATE groups SET skinID = ? WHERE group_name = ?", skinID, groupName) exports["guimessages"]:outputServer (source, "[Group System] #00FF00The Group Skin Has Veen Saved.", 51, 153, 255) setNewGrouplog ( groupName, getPlayerName(source).." Has been Changed Skin Group" ) else exports["guimessages"]:outputServer (source, "[Group System] #FF0000This group doesn't exists.", 51, 153, 255) end end addEvent("setTheGroupSkin", true) addEventHandler("setTheGroupSkin", root, setGroupSkinID) function AutoGroupSkin(groupName) if IsGroupExists(groupName) then dbExec(db, "UPDATE groups SET skinID = ? WHERE group_name = ?","", groupName) exports["guimessages"]:outputServer (source, "[Group System] #FFFF00The Group Skin Has Been Auto.", 51, 153, 255) setNewGrouplog ( groupName, getPlayerName(source).." Has been Auto Skin Group" ) else exports["guimessages"]:outputServer (source, "[Group System] #FF0000This group doesn't exists.", 51, 153, 255) end end addEvent("AutoTheGroupSkin", true) addEventHandler("AutoTheGroupSkin", root, AutoGroupSkin) function sortGroupsTurfPoint() local result = dbPoll(dbQuery(db, "SELECT group_name, total_turf FROM groups"), -1) if result and type(result) == "table" and #result >= 1 then local sortedTurfTable = {} for i, value in pairs(result) do table.insert(sortedTurfTable, {value["group_name"], value["total_turf"]}) end table.sort(sortedTurfTable, function(a, b) return a[2] > b[2] end) local finalTable = {} for i, valueT in pairs(sortedTurfTable) do if i >= 1 and i <= 3 then table.insert(finalTable, {"["..i.."] "..valueT[1], valueT[2], 0, 255, 0}) elseif i > 3 and i <= 6 then table.insert(finalTable, {"["..i.."] "..valueT[1], valueT[2], 0, 150, 255}) elseif i > 6 and i <= 9 then table.insert(finalTable, {"["..i.."] "..valueT[1], valueT[2], 255, 255, 0}) elseif i > 9 and i <= 12 then table.insert(finalTable, {"["..i.."] "..valueT[1], valueT[2], 255, 100, 0}) elseif i > 12 and i <= 20 then table.insert(finalTable, {"["..i.."] "..valueT[1], valueT[2], 255, 0, 0}) elseif i > 20 and i <= 30 then table.insert(finalTable, {"["..i.."] "..valueT[1], valueT[2], 255, 255, 255}) end if i == 30 then return finalTable end end return finalTable end end function getDate() local real = getRealTime() local years = real.year local year = tonumber(real.year) + 1900 local month = real.month local monthday = real.monthday local hour = real.hour local second = real.second local minute = real.minute local tstring = "["..tostring(year).."-"..month.."-"..monthday.."-"..hour..":"..minute..":"..second.."]" return tstring end function setNewGrouplog ( Group, Action ) dbExec(db,"INSERT INTO group_history(group_name,action,data) VALUES(?,?,?)",tostring( Group ), Action ,getDate() ) end addEvent( "getGroupHistory", true ) addEventHandler( "getGroupHistory", root, function ( ) local Group = getElementData( source, "Group" ) local h = dbQuery(db,"SELECT * FROM group_history WHERE group_name = ?",Group) local hoistory = dbPoll(h, -1 ) triggerClientEvent( source, "SetGroupHistory", source, hoistory ) end) function getTimeStamp() local time = getRealTime() return time.timestamp end addEvent("BlacListAction", true) addEventHandler("BlacListAction", root, function(type, accountName, reason, time) local groupName = getElementData(source, "Group") if groupName and IsGroupExists(groupName) and accountName then if type == "Add" then if not isAccountInGroupBlackList(accountName, groupName) then if getAccount(accountName) then exports["guimessages"]:outputServer (source, "[Group System] #FF0000The account name #DF7401"..accountName.." #FF0000has been blocked from the group successfully.", 51, 153, 255) setNewGrouplog ( groupName, "The Account Name "..accountName.." has been blocked from the group successfully." ) dbExec(db, "INSERT INTO group_blackList VALUES(?, ?, ?, ?, ?)", groupName, accountName, getPlayerName(source), reason, time > 0 and getTimeStamp()+time or 0) triggerEvent("Send_Groups_List", source) else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #DF7401There no account name with this name.", 0, 255, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #DF7401The account name #FF0000"..accountName.." is already blocked from the group.", 0, 255, 0) setNewGrouplog ( groupName, "The Account Name "..accountName.." is already blocked from the group." ) triggerEvent("Send_Groups_List", source) end elseif type == "Remove" then if isAccountInGroupBlackList(accountName, groupName) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000The account name #DF7401"..accountName.." #FF0000has been removed from the group blacklist successfully.", 0, 255, 0) setNewGrouplog ( groupName, "The Account Name "..accountName.." has been removed from the group blacklist successfully." ) dbExec(db, "DELETE FROM group_blackList WHERE group_name = ? AND player_account = ?", groupName, accountName) triggerEvent("Send_Groups_List", source) end end end end) setTimer(function() local result = dbPoll(dbQuery(db, "SELECT group_name, player_account, time FROM group_blackList"), -1) if result and type(result) == "table" and #result >= 1 then local cTS = getTimeStamp() for i, value in ipairs(result) do if value["time"] > 0 then if cTS >= value["time"] then dbExec(db, "DELETE FROM group_blackList WHERE group_name = ? AND player_account = ?", value["group_name"], value["player_account"]) end end end end end, 10000, 0) function isAccountInGroupBlackList(accountName, groupName) if IsGroupExists(groupName) then local result = dbPoll(dbQuery(db, "SELECT player_account FROM group_blackList WHERE group_name =? AND player_account =?", groupName, accountName), -1) if type(result) == "table" and #result >= 1 and result[1]["player_account"] == accountName then return true else return false end else return false end end function getGroupBlackList(groupName) if IsGroupExists(groupName) then local result = dbPoll(dbQuery(db, "SELECT player_account, responsible, reason, time FROM group_blackList WHERE group_name =?", groupName), -1) if result and type(result) == "table" then return result else return false end else return false end end function getGroupAlliances(groupName) if IsGroupExists(groupName) then local result = dbPoll(dbQuery(db, "SELECT * FROM group_alliances WHERE group_name1 =? OR group_name2 =?", groupName, groupName), -1) if type(result) == "table" then return result end end end addEvent("InviteForAlliances", true) addEventHandler("InviteForAlliances", root, function(groupName) if IsGroupExists(groupName) then local myGroupName = getElementData(source, "Group") if myGroupName then local CurrentMember, limit = getGroupMemberLimit(myGroupName) if CurrentMember >= 2 then local _, rankType = getPlayerGroupRank(source) if rankType == 1 then local result = dbPoll(dbQuery(db, "SELECT group_name1, group_name2 FROM group_alliances WHERE (group_name1 =? OR group_name2 =?) AND (group_name1 =? OR group_name2 =?)", groupName, groupName, myGroupName, myGroupName), -1) if type(result) == "table" and #result <= 0 then dbExec(db, "INSERT INTO group_alliances VALUES(?, ?, ?)", myGroupName, groupName, 0) exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000alliances invite has been sent to group #DF7401"..groupName.." #FF0000successfully.", 0, 255, 0) for i, player in ipairs(getElementsByType("player")) do local gName = getElementData(player, "Group") if (gName == groupName) or (gName == myGroupName) then setElementData(player, "GroupAlliances", getGroupAlliances(gName)) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000This group already been invited for alliances.", 255, 40, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You not allowed to send alliances invite.", 255, 40, 0) end else outputChatBox( "#3399FF[Group System] #FF0000You Can't Alliance with another Group because your Group Members is lower than 2 members",source, 255, 40, 0,true) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have group!", 255, 40, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000This group doesn't exists.", 255, 40, 0) end setNewGrouplog ( groupName, "alliances invite has been sent to group #DF7401"..groupName.." #FF0000successfully." ) end) addEvent("AlliancesInviteAction", true) addEventHandler("AlliancesInviteAction", root, function(type, groupName) if type == "Accept" then if IsGroupExists(groupName) then local myGroupName = getElementData(source, "Group") if myGroupName then local _, rankType = getPlayerGroupRank(source) if rankType == 1 then dbExec(db, "UPDATE group_alliances SET status = ? WHERE (group_name1 = ? AND group_name2 = ?) OR (group_name1 = ? AND group_name2 = ?)", 1, groupName, myGroupName, myGroupName, groupName) exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You have accepted alliances with group #DF7401"..groupName.."!", 0, 255, 0) for i, player in ipairs(getElementsByType("player")) do local gName = getElementData(player, "Group") if (gName == groupName) or (gName == myGroupName) then setElementData(player, "GroupAlliances", getGroupAlliances(gName)) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You not allowed to send alliances invite.", 255, 40, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have group!", 255, 40, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000This group doesn't exists.", 255, 40, 0) end elseif type == "Reject" then if IsGroupExists(groupName) then local myGroupName = getElementData(source, "Group") if myGroupName then local _, rankType = getPlayerGroupRank(source) if rankType == 1 then dbExec(db, "DELETE FROM group_alliances WHERE (group_name1 = ? AND group_name2 = ?) OR (group_name1 = ? AND group_name2 = ?)", groupName, myGroupName, myGroupName, groupName) for i, player in ipairs(getElementsByType("player")) do local gName = getElementData(player, "Group") if (gName == groupName) or (gName == myGroupName) then setElementData(player, "GroupAlliances", getGroupAlliances(gName)) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You not allowed to remove alliances invite.", 255, 40, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have group!", 255, 40, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000This group doesn't exists.", 255, 40, 0) end end setNewGrouplog ( groupName, "The Group ("..groupName..") accepted alliances" ) end) addEventHandler("onResourceStop", resourceRoot, function() for i, player in ipairs(getElementsByType("player")) do setElementData(player, "Group", false) setElementData(player, "GroupRank", false) setElementData(player, "GroupAlliances", false) end end) function getGroupOnlineMember(group) local Table = {} for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == group then table.insert(Table, player) end end return Table end gChatSpam = {} gChatSpama = {} function onGroupChataalince(player,_,...) local group = getElementData(player, "Group") if group then if not gChatSpama[player] then gChatSpama[player] = 0 setTimer(function(player) gChatSpama[player] = nil end, 5000, 1, player) end if gChatSpama[player] == 3 then output("#3399FF [Group System] : #FF0000Don't Spam !",player, 0,255, 255,true) else gChatSpama[player] = gChatSpama[player] + 1 local account = getPlayerAccount(player) if account and not isGuestAccount(account) then local accountName = getAccountName(account) if geMemberMuteStat(accountName) == "true" then output("#3399FF[Group System] : #FF0000You are muted ! ",player, 255, 0, 0,true) return end local msg = table.concat({...}, " ") local nick = getPlayerName(player) local nisck = getPlayerGroupRank(player) local r, g, b if getPlayerTeam(player) then r, g, b = getTeamColor(getPlayerTeam(player)) else r, g, b = 255, 255, 255 end if isPlayerMuted(player) then outputChatBox("You are muted", player, 255, 140, 0, true) return end --[[ for _,v in ipairs(NoSpamGroup) do if string.find(msg, v) then exports["guimessages"]:outputServer(player,"#3399FF [Group System] : #FF0000 This Violation Of The Word !", 0, 255, 255) return end end --]] local color = string.format("#%02X%02X%02X", r, g, b) local value = getElementData(player, "GroupAlliances") if value and type(value) == "table" and #value > 0 then local gMSG = {} for i, gValue in pairs(value) do if gValue["status"] == 1 then if gValue["group_name1"] == group and not gMSG[gValue["group_name2"]] then gMSG[gValue["group_name2"]] = true for i, p in ipairs(getGroupOnlineMember(gValue["group_name2"])) do if doesPlayerHavePermission(player, 17) then playSoundFrontEnd(player, 101) outputChatBox( "("..group..") : #CCCCCC["..nisck.."] "..color..""..nick.." : #33CCCC"..msg,p, 0, 255, 255, true) else outputChatBox( "("..group..") : #FF0000["..nisck.."] "..color..""..nick.." : #E0D0B0"..msg,p, 0, 255, 255, true) end end end if gValue["group_name2"] == group and not gMSG[gValue["group_name1"]] then gMSG[gValue["group_name1"]] = true for i, p in ipairs(getGroupOnlineMember(gValue["group_name1"])) do if doesPlayerHavePermission(player, 17) then playSoundFrontEnd(player, 101) outputChatBox( "("..group..") : #CCCCCC["..nisck.."] "..color..""..nick.." : #33CCCC"..msg,p, 0, 255, 255, true) else outputChatBox( "("..group..") : #FF0000["..nisck.."] "..color..""..nick.." : #E0D0B0"..msg,p, 0, 255, 255, true) end end end end end for i, v in ipairs(getGroupOnlineMember(group)) do if doesPlayerHavePermission(player, 17) then playSoundFrontEnd(player, 101) outputChatBox( "("..group..") : #CCCCCC["..nisck.."] "..color..""..nick.." : #33CCCC"..msg,v, 0, 255, 255, true) else outputChatBox( "("..group..") : #FF0000["..nisck.."] "..color..""..nick.." : #E0D0B0"..msg,v, 0, 255, 255, true) end end else for i, v in ipairs(getGroupOnlineMember(group)) do if doesPlayerHavePermission(player, 17) then playSoundFrontEnd(player, 101) outputChatBox( "("..group..") : #CCCCCC["..nisck.."] "..color..""..nick.." : #33CCCC"..msg,v, 0, 255, 255, true) else outputChatBox( "("..group..") : #FF0000["..nisck.."] "..color..""..nick.." : #E0D0B0"..msg,v, 0, 255, 255, true) end end end else exports["guimessages"]:outputServer ( "#3399FF [Group System] : #FF0000You're not logged in!",player, 0,255, 255,true) end end end end addCommandHandler("GroupAllianceschat",onGroupChataalince) addCommandHandler("GroupAllianceschat",onGroupChataalince) function onGroupChat(player,_,...) local group = getElementData(player, "Group") if group then if not gChatSpam[player] then gChatSpam[player] = 0 setTimer(function(player) gChatSpam[player] = nil end, 5000, 1, player) end if gChatSpam[player] == 3 then output("#3399FF [Group System] : #FF0000Don't Spam !",player, 0,255, 255,true) else gChatSpam[player] = gChatSpam[player] + 1 local account = getPlayerAccount(player) if account and not isGuestAccount(account) then local accountName = getAccountName(account) if geMemberMuteStat(accountName) == "true" then output("#3399FF[Group System] : #FF0000You are muted ! ",player, 255, 0, 0,true) return end if isPlayerMuted(player) then outputChatBox("You are muted", player, 255, 140, 0, true) return end local msg = table.concat({...}, " ") local nick = getPlayerName(player) local nisck = getPlayerGroupRank(player) local r, g, b if getPlayerTeam(player) then r, g, b = getTeamColor(getPlayerTeam(player)) else r, g, b = 255, 255, 255 end --[[ for _,v in ipairs(NoSpamGroup) do if string.find(msg, v) then exports["guimessages"]:outputServer(player,"#3399FF [Group System] : #FF0000 This Violation Of The Word !", 0, 255, 255) return end end --]] local color = string.format("#%02X%02X%02X", r, g, b) local chatColorTable = getGroupChatColor(group) local chatColor = string.format("#%02X%02X%02X", chatColorTable[1], chatColorTable[2], chatColorTable[3]) for _,v in ipairs(getElementsByType("player")) do local account = getAccountName ( getPlayerAccount ( v ) ) if ( isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Staff" ) ) ) and getElementData(v,"SeeGroupChat") and getElementData(v ,"Group") ~= group then outputChatBox("#FFFFFF("..group..")#FF00FF["..nisck.."]"..color..""..nick.." : #FFFF00"..msg, v, 255, 255, 255, true) -- outputDebugString("(Group) ("..group..") "..nick..": "..msg) -- outputServerLog("(Group) ("..group..") "..nick..": "..msg) end end for i, v in ipairs(getGroupOnlineMember(group)) do if doesPlayerHavePermission(player, 17) then playSoundFrontEnd(player, 101) outputChatBox( "(Group) : #CCCCCC["..nisck.."#CCCCCC] "..color..""..nick.." : #33CCCC"..msg,v, 0, 255, 255, true) else outputChatBox( "(Group) : #FF0000["..nisck.."#FF0000] "..color..""..nick.." : "..chatColor..""..msg,v, 0, 255, 255, true) end end end end end end addCommandHandler("Groupchat",onGroupChat) addCommandHandler("groupchat",onGroupChat) addCommandHandler("SeeChat",function(p) local account = getAccountName ( getPlayerAccount ( p ) ) if ( isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Console" ) ) ) then setElementData(p,"SeeGroupChat",true) exports["guimessages"]:outputServer (p,"SeeGroupsChat:#00FF00 ON", 255, 255, 0) end end ) function onCreateGroup(name) if getPlayerGroup(source) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You already have group.", 255, 40, 0) elseif isHasSpace(name) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000The #DF7401Group name #FF0000must be without space, Remove the Space from it.", 255, 40, 0) elseif not isASCII(name) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000Only English #DF7401Groups name #00FF00acceptable#FF0000 chose another name in English.", 255, 40, 0) else if (getElementData(source, "Money") or 0) >= 200000 then if (getElementData(source, "Level") or 0) >= 2 then if getElementData( source, "OnGroup50" ) then setElementData(source, "Money", (getElementData(source, "Money") or 0) - 100000) CreateGroup(source, name) exports["guimessages"]:outputServer (source, "#3399FF[Group System] #00FF00You Create Group #FFFF00[ "..name.." ] #00FF00 Successfully for #FFFFFF$100.000", 255, 20, 0) else setElementData(source, "Money", (getElementData(source, "Money") or 0) - 200000) CreateGroup(source, name) exports["guimessages"]:outputServer (source, "#3399FF[Group System] #00FF00You Create Group #FFFF00[ "..name.." ] #00FF00 Successfully for #FFFFFF$200.000", 255, 20, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You Don't Have #FFFF00Level (3) #FF0000To Make The Group.", 255, 20, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You Don't Have #00ff00$200.000 #FF0000To Make The Group.", 255, 20, 0) end end end addEvent("Create_Group", true) addEventHandler("Create_Group", root, onCreateGroup) function isASCII(text) for i = 1, #text do local byte = text:byte(i) if(byte < 33 or byte > 126)then return false end end return true end function isHasSpace(text) for i = 1, #text do local byte = text:byte(i) if(byte == 32)then return true end end return false end local Ranks_Table = { {"Trial", ""}, {"Regular", ""}, {"Trusted", "6"}, {"Deputy", "1, 2, 3, 5, 6, 8"}, {"Leader", "1, 2, 3, 4, 5, 6, 8, 10, 11, 14"}, {"Founder", "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18"} } function CreateGroup(player, name) if not IsGroupExists(name) then local data = data() local playerName = getPlayerName(player) local accountName = getAccountName(getPlayerAccount(player)) local color = math.random(255)..", "..math.random(255)..", "..math.random(255) dbExec(db, "INSERT INTO groups VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", name, accountName, 1, 20, "The group leader has not made a message Yet", playerName.." ("..accountName..") created the group "..name, 0, color, 0, 45) for i, R in ipairs(Ranks_Table) do if R[1] == "Founder" then dbExec(db, "INSERT INTO group_ranks VALUES(?, ?, ?, ?)", name, R[1], R[2], 1) elseif R[1] == "Trial" then dbExec(db, "INSERT INTO group_ranks VALUES(?, ?, ?, ?)", name, R[1], R[2], 2) else dbExec(db, "INSERT INTO group_ranks VALUES(?, ?, ?, ?)", name, R[1], R[2], 3) end end dbExec(db, "INSERT INTO group_members VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", name, accountName, playerName, "Yes", "Founder", data, 0, "false","false") setElementData(player, "Group", name) setElementData(player, "GroupRank", {getGroupRanks(name), getPlayerGroupRank(player)}) setElementData(player, "GroupAlliances", getGroupAlliances(name)) exports["guimessages"]:outputServer (player, "#3399FF[Group System] #DF7401"..name.." #FF0000has been created successfully.", 0, 255, 0) setNewGrouplog ( name, playerName.." Gas Been Created "..name ) else exports["guimessages"]:outputServer (player, "#3399FF[Group System] #FF0000The Group name #DF7401"..name.." #FF0000is already exists.", 255, 0, 0) end end local turfTimer = {} addEvent("ChangeTurfColor", true) addEventHandler("ChangeTurfColor", root, function(groupName, r, g, b) if groupName and IsGroupExists(groupName) then if not turfTimer[source] then turfTimer[source] = true setTimer(function(source) turfTimer[source] = nil end, 2500, 1, source) if doesPlayerHavePermission(source, 12) then local color = r..", "..g..", "..b dbExec(db, "UPDATE groups SET turf_color = ? WHERE group_name = ?", color, groupName) exports["guimessages"]:outputServer (source, "#FF9600[Turf System] "..string.format("#%.2X%.2X%.2X", r, g, b).."The turf color has been changed successfully.", r, g, b) setNewGrouplog ( Group, getPlayerName(source).." Change Turf Color !" ) else exports["guimessages"]:outputServer (source, "#FF9600[Turf System] #FF0000You don't have permission to change turf color.", 255, 0, 0) end end end end) addEvent("ChangeChatColor", true) addEventHandler("ChangeChatColor", root, function(groupName, r, g, b) if groupName and IsGroupExists(groupName) then if doesPlayerHavePermission(source, 13) then local color = r..", "..g..", "..b dbExec(db, "UPDATE groups SET Chat_color = ? WHERE group_name = ?", color, groupName) exports["guimessages"]:outputServer (source, "#FF9600[Gruop Chat] "..string.format("#%.2X%.2X%.2X", r, g, b).."The chat color has been changed successfully.", r, g, b) local accountName = getAccountName(getPlayerAccount(source)) setNewGrouplog ( Group, getPlayerName(player).." Change Chat Color !" ) else exports["guimessages"]:outputServer (source, "#FF9600[Group Chat] #FF0000You don't have permission to change chat color.", 255, 0, 0) end end end) --[[addCommandHandler("turfcolor", function(player, cmd, r, g, b) if not turfTimer[player] then turfTimer[player] = true setTimer(function(player) turfTimer[player] = nil end, 2500, 1, player) local Group = getElementData(player, "Group") local r = tonumber(r) local g = tonumber(g) local b = tonumber(b) if Group then if doesPlayerHavePermission(player, 12) then if r and g and b then if r <= 255 and r >= 0 and g <= 255 and g >= 0 and b <= 255 and b >= 0 then local color = r..", "..g..", "..b dbExec(db, "UPDATE groups SET turf_color = ? WHERE group_name = ?", color, Group) exports["guimessages"]:outputServer (player, "#FF9600[Turf System] "..string.format("#%.2X%.2X%.2X", r, g, b).."The turf color has been changed successfully.", r, g, b) else exports["guimessages"]:outputServer (player, "#FF9600[Turf System] #FFFF00The color must be a number between 0-255.", 255, 255, 0) end else exports["guimessages"]:outputServer (player, "#FF9600[Turf System] #FFFF00The Syntax: /turfcolor [r] [g] ", 255, 255, 0) exports["guimessages"]:outputServer (player, "#FF9600[Turf System] #00FFFFExample: /turfcolor 255 0 0", 0, 250, 150) end else exports["guimessages"]:outputServer (player, "#FF9600[Turf System] #FF0000You don't have permission to change turf color.", 255, 0, 0) end end end end)--]] function AddAllpoint(player) if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Staff")) then group = getElementData(player,"Group") increaseGroupTurfPoint(group) end end addCommandHandler("AddPoint",AddAllpoint) --[[addEvent("setTurfColor", true) addEventHandler("setTurfColor", root, function(groupName, r, g, b) if doesPlayerHavePermission(client, 12) then local color = r..", "..g..", "..b dbExec(db, "UPDATE groups SET turf_color = ? WHERE group_name = ?", color, groupName) exports["guimessages"]:outputServer (client, "#FF9600[Turf System] #238F88The turf color has been changed successfully.", r, g, b) else exports["guimessages"]:outputServer (client, "#FF9600[Turf System] #FF0000You don't have permission to change turf color.", 255, 0, 0) end setNewGrouplog (groupName,""..getPlayerName(source).." Changed Turf Colour !" ) end)--]] function getGroupBankBalance(group) if group and IsGroupExists(group) then local h = dbQuery(db, "SELECT group_bank FROM groups WHERE group_name = ?", group) local result = dbPoll(h, -1) return result[1]["group_bank"] end end addEvent("getGroupBalance", true) addEventHandler("getGroupBalance", root, function() local groupName = getPlayerGroup(source) if groupName then local balance = getGroupBankBalance(groupName) or 0 triggerClientEvent(source, "receiveGroupBankBalance", source, balance) end end) addEvent("get_Group_BankList", true) addEventHandler("get_Group_BankList", root, function(name) local balancess = getGroupBankBalance(name) or 0 triggerClientEvent(source, "receiveGroupBankBalanceS", source, balancess) end) ---Test--- addEvent("getGroupMaxBank", true) addEventHandler("getGroupMaxBank", root, function(group) if getGroupBankBalance(group) > 5000000 then dbExec(db, "UPDATE groups SET group_bank = 5000000 WHERE group_name = ?", group) end end ) -- || Deposit Money || -- Edit By : i6rzaN addEvent("DepositMoneyInGroupBank", true) addEventHandler("DepositMoneyInGroupBank", root, function(money) local groupName = getPlayerGroup(source) if money and groupName then if doesPlayerHavePermission(source, 10) then local balance = getGroupBankBalance(groupName) or 0 local pMoney = getElementData(source, "Money") or 0 if balance and pMoney >= money and balance+money > 0 then dbExec(db, "UPDATE groups SET group_bank = ? WHERE group_name = ?", balance+money, groupName) setElementData(source, "Money", (pMoney-money) or 0) setNewGrouplog ( groupName, ""..getPlayerName(source).." Deposited $"..money.." Into Group Bank." ) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then outputChatBox("#3399FF[Group System] #C80000"..getPlayerName(source).." #C80000Deposited #00FF00$"..money.." #C80000into group bank.", player, 255, 255, 0, true) triggerClientEvent(player, "receiveGroupBankBalance", player, getGroupBankBalance(groupName) or 0) end end else exports["guimessages"]:outputServer (source, "#04B4AE(Group System) #FF0000You don't have enough money.", 0, 255, 0) end else exports["guimessages"]:outputServer (source, "#04B4AE(Group System) #FF0000You don't have permission to deposit money into the group bank.", 255, 0, 0) end end end) addEvent("GroupMemberGiveMoney", true) addEventHandler("GroupMemberGiveMoney", root, function() local groupName = getPlayerGroup(source) if groupName then local member = getGroupMembers(groupName) triggerClientEvent(source, "ViewGroupMemberGive", source, member) end end) addEvent("GiveMemberMoneyGroup", true) addEventHandler("GiveMemberMoneyGroup", root, function (moneys, name2) local name = getPlayerFromName(name2) local name4 = getPlayerName(source) local Group = getElementData(source, "Group") local ItemGroup = getElementData(getPlayerFromName(name2), "Group") local balance = getGroupBankBalance(Group) or 0 if Group then if doesPlayerHavePermission(source, 11) then if Group == ItemGroup then if name4 ~= name2 then if moneys <= balance then if balance and balance-moneys >= 0 then setElementData(name, "Money", getElementData(name, "Money")+moneys) dbExec(db, "UPDATE groups SET group_bank = ? WHERE group_name = ?", balance-moneys, Group) setNewGrouplog ( Group, "("..getPlayerName( source )..")["..getAccountName(getPlayerAccount(source)).."] Gived ("..name2..")["..getAccountName(getPlayerAccount(getPlayerFromName(name2))).."] $"..convertNumber(moneys) ); triggerClientEvent("receiveGroupBankBalance", source, balance) for k, v in ipairs (getElementsByType("player")) do if getElementData(v, "Group") == Group then exports["guimessages"]:outputServer (v, "#C38EC7[Group System] #C80000"..getPlayerName(source).."#C80000 Has Given "..name2.." #00FF00$"..convertNumber(moneys),255,255,255, true) end end end end else exports["guimessages"]:outputServer (source, "#04B4AE[Group System] #FF0000You Can't Give The Money To Yourself !", 255, 0, 0) end else exports["guimessages"]:outputServer (source, "#04B4AE[Group System] #FF0000 There's No Player With That Name In The Group.", 255, 0, 0) end else exports["guimessages"]:outputServer (source, "#04B4AE[Group System] #FF0000You don't have permission to Give Group members Money.", 255, 0, 0) end end end ); addEvent("GiveAllGroupMoney", true) addEventHandler("GiveAllGroupMoney",root, function (money) local Group = getElementData(source, "Group") local members = getGroupOnlineMember(Group) local balance = getGroupBankBalance(Group) or 0 local amount = math.ceil(money / #members) if doesPlayerHavePermission(source, 11) then if balance and balance-money >= 0 then if doesPlayerHavePermission(source, 15) then for k, v in ipairs(members) do dbExec(db, "UPDATE groups SET group_bank = ? WHERE group_name = ?", balance-money, Group) setElementData(v,"Money",getElementData(v,"Money")+amount) exports["guimessages"]:outputServer (v, "#C38EC7[Group System] #C80000"..getPlayerName(source).." #C80000Given All Group Members #00FF00$"..convertNumber(amount),255,255,0, true) triggerClientEvent("receiveGroupBankBalance", source, getGroupBankBalance(Group) or 0) end setNewGrouplog ( Group, ""..getPlayerName(source).." Has Given $"..convertNumber(amount).." for every member." ) end end else exports["guimessages"]:outputServer (source, "#C38EC7[Group System] #FF0000You don't have permission to withdraw money from the group bank.", 255, 0, 0) end end ); addEvent("OnGroupMemeberOnlince", true) addEventHandler("OnGroupMemeberOnlince",root, function () local Group = getElementData(source, "Group") local Rank = getPlayerGroupRank(source) local members = getGroupOnlineMember(Group) local totalMember,limit = getGroupMemberLimit(Group) local GroupOwner = getGroupOwner(Group) triggerClientEvent(source,"ViewGroupMemberOnlince", source, #members,Rank,limit,GroupOwner) end ); -- || Withdraw Money || -- Edit By : i6rzaN addEvent("WithdrawMoneyInGroupBank", true) addEventHandler("WithdrawMoneyInGroupBank", root, function(money) local groupName = getPlayerGroup(source) if money and groupName then if doesPlayerHavePermission(source, 11) then local balance = getGroupBankBalance(groupName) or 0 local pMoney = getElementData(source, "Money") or 0 if balance and balance-money >= 0 then dbExec(db, "UPDATE groups SET group_bank = ? WHERE group_name = ?", balance-money, groupName) setElementData(source, "Money", (money+pMoney) or pMoney) setNewGrouplog ( groupName, ""..getPlayerName(source).." Withdrawn $"..money.." From Group Bank." ) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then outputChatBox ("#3399FF[Group System] #C80000"..getPlayerName(source).." Withdrawn #00FF00$"..money.." #C80000from group bank.", player, 255, 255, 0, true) triggerClientEvent(player, "receiveGroupBankBalance", player, getGroupBankBalance(groupName) or 0) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000Your group doesn't have this amount of money.", 0, 255, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have permission to withdraw money from the group bank.", 255, 0, 0) end end end) addEvent("setWarningLevel", true) addEventHandler("setWarningLevel", root, function(Account, level, oLevel, Reason) local _, rankType = getPlayerGroupRank(source) if rankType ~= 1 and getAccountName(getPlayerAccount(source)) == Account then return end local groupName = getPlayerGroup(source) if groupName then if doesPlayerHavePermission(source, 14) then dbExec(db, "UPDATE group_members SET WL = ? WHERE group_name = ? AND member_account = ?", level, groupName, Account) local data = data() triggerClientEvent(source, "myGroupList", source, getGroupMembers(groupName), data) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #C80000"..getPlayerName(source).." warned "..getGroupMemberName(Account).." ("..oLevel..") ("..Reason..").", 0, 255, 255, true) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have permission to warn members.", 255, 0, 0) end end setNewGrouplog ( groupName, ""..getPlayerName(source).." Warned "..getGroupMemberName(Account).." ("..oLevel..") ("..Reason..")." ) end) addEvent("AddNewRank", true) addEventHandler("AddNewRank", root, function(rankName, addAfterRank, permission) local groupName = getPlayerGroup(source) local _, rankType = getPlayerGroupRank(source) if groupName and rankType == 1 then local result = dbPoll(dbQuery(db, "SELECT group_rank_name FROM group_ranks WHERE group_name = ? AND group_rank_name = ?", groupName, rankName), -1) if type(result) == "table" and #result == 0 then local result = dbPoll(dbQuery(db, "SELECT * FROM group_ranks WHERE group_name = ?", groupName), -1) if type(result) == "table" and #result ~= 0 then dbExec(db, "DELETE FROM group_ranks WHERE group_name = ?", groupName) for i, R in pairs(result) do dbExec(db, "INSERT INTO group_ranks VALUES(?, ?, ?, ?)", groupName, R["group_rank_name"], R["group_rank_permission"], R["rank_type"]) if R["group_rank_name"] == addAfterRank then dbExec(db, "INSERT INTO group_ranks VALUES(?, ?, ?, ?)", groupName, rankName, permission, 3) exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FFFF00"..rankName.." #00FF00rank added successfully!", 0, 255, 255) end end for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then setElementData(player, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(player)}) end end end end end setNewGrouplog (groupName,""..getPlayerName(source).." Add Rank Name : "..rankName.." !" ) end) addEvent("RemoveRank", true) addEventHandler("RemoveRank", root, function(rankName) local groupName = getPlayerGroup(source) local _, rankType = getPlayerGroupRank(source) if groupName and rankType == 1 then local result = dbPoll(dbQuery(db, "SELECT rank_type FROM group_ranks WHERE group_name = ? AND group_rank_name = ?", groupName, rankName), -1) if type(result) == "table" and #result ~= 0 then if result[1]["rank_type"] == 3 then local result = dbPoll(dbQuery(db, "SELECT group_rank_name FROM group_ranks WHERE group_name = ?", groupName), -1) if type(result) == "table" and #result ~= 0 then for i, R in pairs(result) do if R["group_rank_name"] == rankName then dbExec(db, "UPDATE group_members SET member_rank = ? WHERE group_name = ? AND member_rank = ?", result[i-1]["group_rank_name"], groupName, rankName) end end end dbExec(db, "DELETE FROM group_ranks WHERE group_name = ? AND group_rank_name = ?", groupName, rankName) exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FFFF00"..rankName.." #00FF00Rank Removed successfully!", 0, 255, 0) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then setElementData(player, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(player)}) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000This rank can't be removed.", 255, 40, 0) end end end setNewGrouplog (groupName,""..getPlayerName(source).." Remove Rank "..rankName.." !" ) end) addEvent("EditRank", true) addEventHandler("EditRank", root, function(rankName, newRankName, permission) local groupName = getPlayerGroup(source) local _, rankType = getPlayerGroupRank(source) if groupName and rankType == 1 then dbExec(db, "UPDATE group_ranks SET group_rank_permission = ? WHERE group_name = ? AND group_rank_name = ?", permission, groupName, rankName) exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FFFF00"..rankName.." #00FF00rank updated successfully!", 0, 255, 0) local result = dbPoll(dbQuery(db, "SELECT group_rank_name FROM group_ranks WHERE group_name = ? AND group_rank_name = ?", groupName, newRankName), -1) if type(result) == "table" and #result == 0 then dbExec(db, "UPDATE group_ranks SET group_rank_name = ? WHERE group_name = ? AND group_rank_name = ?", newRankName, groupName, rankName) dbExec(db, "UPDATE group_members SET member_rank = ? WHERE group_name = ? AND member_rank = ?", newRankName, groupName, rankName) end for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then setElementData(player, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(player)}) end end end setNewGrouplog (groupName,""..getPlayerName(source).." Edit Rank "..newRankName.." Changed "..rankName.." !" ) end) function IsGroupExists(name) local h = dbQuery(db, "SELECT * FROM groups WHERE group_name = ?", name) local result = dbPoll(h, -1) if type(result) == "table" and #result ~= 0 then return true end end addEventHandler("onPlayerLogin", root, function(_, accountName) local groupName = getPlayerGroup(source) if groupName then local data = data() dbExec(db, "UPDATE group_members SET member_name = ?, member_status = ?, last_online = ? WHERE group_name = ? AND member_account = ?", getPlayerName(source), "Yes", data, groupName, getAccountName(accountName)) setElementData(source, "Group", groupName) setElementData(source, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(source)}) setElementData(source, "GroupAlliances", getGroupAlliances(groupName)) exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #DF7401"..getPlayerName(source).." #00FF00 Online the Group.",0,255,255,true) else setElementData(source, "Group", false) setElementData(source, "GroupRank", false) setElementData(source, "GroupAlliances", false) end end) function getGroupRanks(groupName) local Rank = dbPoll(dbQuery(db, "SELECT * FROM group_ranks WHERE group_name = ?", groupName), -1) if type(Rank) == "table" and #Rank ~= 0 then return Rank end end function getPlayerGroupRank(player) local groupName = getPlayerGroup(player) if groupName then local Rank = dbPoll(dbQuery(db, "SELECT member_rank FROM group_members WHERE group_name = ? AND member_account = ?", groupName, getAccountName(getPlayerAccount(player))), -1) if type(Rank) == "table" and #Rank ~= 0 then local tt = dbPoll(dbQuery(db, "SELECT rank_type FROM group_ranks WHERE group_name = ? AND group_rank_name = ?", groupName, Rank[1]["member_rank"]), -1) return Rank[1]["member_rank"], tt[1]["rank_type"] end end end function doesPlayerHavePermission(player, permission) permission = tonumber(permission) local groupName = getPlayerGroup(player) if groupName then local Rank = dbPoll(dbQuery(db, "SELECT member_rank FROM group_members WHERE group_name = ? AND member_account = ?", groupName, getAccountName(getPlayerAccount(player))), -1) if type(Rank) == "table" and #Rank ~= 0 then local Permission = dbPoll(dbQuery(db, "SELECT group_rank_permission FROM group_ranks WHERE group_name = ? AND group_rank_name = ?", groupName, Rank[1]["member_rank"]), -1) local pre = split(Permission[1]["group_rank_permission"], ',') if type(pre) == "table" then for i, p in ipairs(pre) do if tonumber(p) == permission then return true end end end end end end function getPlayerGroup(player) local h = dbQuery(db, "SELECT group_name FROM group_members WHERE member_account = ?", getAccountName(getPlayerAccount(player))) local result = dbPoll(h, -1) if type(result) == "table" and #result ~= 0 and result[1]["group_name"] then return tostring(result[1]["group_name"]) end end function addMemberToGroup(player, groupName) if IsGroupExists(groupName) and not getPlayerGroup(player) then local h = dbQuery(db, "SELECT group_members FROM groups WHERE group_name = ?", groupName) local result = dbPoll(h, -1) local cont = result[1]["group_members"] + 1 local data = data() local playerName = getPlayerName(player) local accountName = getAccountName(getPlayerAccount(player)) if not isAccountInGroupBlackList(accountName, groupName) then dbExec(db, "INSERT INTO group_members VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", groupName, accountName, playerName, "Yes", getGroupRanks(groupName)[1]["group_rank_name"], data, 0, "false", "false") dbExec(db, "UPDATE groups SET group_members = ? WHERE group_name = ?", cont, groupName) setElementData(player, "Group", groupName) setElementData(player, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(player)}) setElementData(player, "GroupAlliances", getGroupAlliances(groupName)) triggerClientEvent(player, "Send_Invite_List", player, getPlayerInviteGroupList(player)) for _,v in ipairs(getElementsByType("player")) do if getElementData(v, "Group") == groupName then exports["guimessages"]:outputServer (v, "#3399FF [Group System] : #DF7401"..getPlayerName(player).." #FF0000joined the Group.",0, 255, 255, true) end end else exports["guimessages"]:outputServer (player, "#3399FF[Group System] #FF0000You Can't Join The Group Because You Are in the Blacklist!", 255, 40, 0) end dbExec(db, "DELETE FROM group_invite WHERE player_account = ?", accountName) end end function getGroupOwner(groupName) local result = dbPoll(dbQuery(db, "SELECT group_owner FROM groups WHERE group_name = ?", groupName), -1) if type(result) == "table" and #result ~= 0 then return result[1]["group_owner"] end end function removeMemberFromGroup(player) local groupName = getPlayerGroup(player) if groupName then local groupOwner = getGroupOwner(groupName) if groupOwner ~= getAccountName(getPlayerAccount(player)) then local result = dbPoll(dbQuery(db, "SELECT group_members FROM groups WHERE group_name = ?", groupName), -1) local cont = result[1]["group_members"] - 1 dbExec(db, "DELETE FROM group_members WHERE member_account = ?", getAccountName(getPlayerAccount(player))) dbExec(db, "UPDATE groups SET group_members = ? WHERE group_name = ?", cont, groupName) setElementData(player, "Group", false) setElementData(player, "GroupRank", false) setElementData(player, "GroupAlliances", false) else --exports["guimessages"]:outputServer (player,"#3399FF[Group System] : #FF0000You Can Not leave the group you are the owner, you Can Only Delete The Group.",player, 255, 40, 0,true) exports["guimessages"]:outputServer (player, "#3399FF[Group System] : #FF0000You can not leave the group because you are the only one with Founder .", 255, 40, 0) end if getElementData(player, "Group") then return end for _,v in ipairs(getElementsByType("player")) do if getElementData(v, "Group") == groupName then exports["guimessages"]:outputServer (v, "#3399FF [Group System] : #DF7401"..getPlayerName(player).." #FF0000left the Group.",0,255,255,true) end end end setNewGrouplog (groupName,""..getPlayerName(source).." Left the Group." ) dbExec(db,"INSERT INTO MessageLeaved(group_name,Time,Name,Account,Message) VALUES(?,?,?,?,?)",groupName,getDate(), getPlayerName(source) , getAccountName(getPlayerAccount(source)), "-",true ) end function setGroupInfo(player, name, Texts) if IsGroupExists(name) and doesPlayerHavePermission(player, 5) then local Text = Texts.." Updated by "..getPlayerName(player).." ("..getAccountName(getPlayerAccount(player))..") \n" dbExec(db, "UPDATE groups SET group_info = ? WHERE group_name = ?", Text, name) triggerClientEvent(player, "Send_Group_Info", player, getGroupInfo(name)) for _,v in ipairs(getElementsByType("player")) do if getElementData(v, "Group") == name then exports["guimessages"]:outputServer (v, "#3399FF [Group System] : #DF7401"..getPlayerName(player).." #00FF00has update the Group Information.", 0, 255, 255, true) end end end setNewGrouplog (name,""..getPlayerName(source).." Has Update The Group Information." ) end function getGroupInfo(name) if IsGroupExists(name) then local h = dbQuery(db, "SELECT group_info FROM groups WHERE group_name = ?", name) local result = dbPoll(h, -1) return tostring(result[1]["group_info"]) end end function getGroupMembers(name) local M = dbQuery(db, "SELECT * FROM group_members WHERE group_name = ?", name) local resM = dbPoll(M, -1) if type(resM) == "table" and #resM ~= 0 then return resM end end function getGroupMemberName(account) local h = dbQuery(db, "SELECT member_name FROM group_members WHERE member_account = ?", account) local result = dbPoll(h, -1) if type(result) == "table" and #result ~= 0 then return tostring(result[1]["member_name"]) end end function InvitePlayerToGroup(name,player,by) if isGuestAccount(getPlayerAccount(player)) then return end local result = dbPoll(dbQuery(db, "SELECT * FROM group_invite WHERE group_name = ? AND player_account = ?", name, getAccountName(getPlayerAccount(player))), -1) if type(result) == "table" and #result == 0 or not result and IsGroupExists(name) and not getPlayerGroup(player) then local totalMember, limit = getGroupMemberLimit(name) if totalMember < limit then exports["guimessages"]:outputServer (by, "#3399FF [Group System] : #FF0000You Invite #DF7401"..getPlayerName(player)..".", 0, 255, 255, true) exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #FF0000You have Invited to Join Group #DF7401("..name..") #FF0000by #DF7401"..getPlayerName(by)..".", 0, 255, 255, true) playSoundFrontEnd(player, 40) dbExec(db, "INSERT INTO group_invite VALUES(?, ?, ?)", name, getAccountName(getPlayerAccount(player)), getPlayerName(by).." ("..getAccountName(getPlayerAccount(by))..")") else exports["guimessages"]:outputServer (by, "#3399FF [Group System] : #FF0000You can't Invite because the group is full.", 0, 255, 255, true) end end end function getPlayerInviteGroupList(player) local h = dbQuery(db, "SELECT * FROM group_invite WHERE player_account = ?", getAccountName(getPlayerAccount(player))) local result = dbPoll(h, -1) if type(result) == "table" and #result ~= 0 then return result end end function getGroupMemberLimit(name) local result = dbPoll(dbQuery(db, "SELECT group_members,members_limit FROM groups WHERE group_name = ?", name), -1) if type(result) == "table" and #result ~= 0 then return tonumber(result[1]["group_members"]), tonumber(result[1]["members_limit"]) end end addEvent("Send_Groups_List", true) addEventHandler("Send_Groups_List", root, function() local result = dbPoll(dbQuery(db, "SELECT group_name, group_members,group_owner, members_limit FROM groups"), -1) if type(result) == "table" then triggerClientEvent(source, "GroupList", source, result, getGroupBlackList(getElementData(source, "Group")) or {}, sortGroupsTurfPoint() or {},getTopPointGroup()) end end) addEvent("Invite_Player", true) addEventHandler("Invite_Player", root, function(name, invited) local account = getPlayerAccount(invited) if account and not isGuestAccount(account) then if not isAccountInGroupBlackList(getAccountName(account), name) then InvitePlayerToGroup(name, invited, source) else output("#3399FF[Group System] #FF0000This player can't join as he in the blacklist.", source, 255, 0, 0, true) end else output("#3399FF[Group System] #FF0000This player is not logged in.", source, 255, 0, 0, true) end end) addEvent("Invite_PlayerSs", true) addEventHandler("Invite_PlayerSs", root, function(names, inviteds) local account = getPlayerAccount(inviteds) if account and not isGuestAccount(account) then if not isAccountInGroupBlackList(getAccountName(account), names) then InvitePlayerToGroup(names, inviteds, source) else output("#3399FF[Group Manager] #FF0000This player can't join as he in the blacklist.", source, 255, 0, 0, true) end else output("#3399FF[Group Manager] #FF0000This player is not logged in.", source, 255, 0, 0, true) end end) addEvent("Request_Invite_List", true) addEventHandler("Request_Invite_List", root, function() triggerClientEvent(source, "Send_Invite_List", source, getPlayerInviteGroupList(source)) end) addEvent("Request_Group_Info", true) addEventHandler("Request_Group_Info", root, function(name) triggerClientEvent(source, "Send_Group_Info", source, getGroupInfo(name)) end) addEvent("Request_myGroup_MembersList", true) addEventHandler("Request_myGroup_MembersList", root, function(name) local data = data() local member = getGroupMembers(name) local color1 = getGroupTurfColor(name) local color2 = getGroupChatColor(name) return triggerClientEvent(source, "myGroupList", source, member, data,color1,color2) end) addEventHandler("onPlayerChangeNick", root, function(_,new) local groupName = getPlayerGroup(source) if groupName then local data = data() dbExec(db, "UPDATE group_members SET member_name = ?, member_status = ?, last_online = ? WHERE group_name = ? AND member_account = ?", new, "Yes", data, groupName, getAccountName(getPlayerAccount(source))) end end) addEventHandler("onPlayerLogout", root, function(acc) local groupName = getElementData(source, "Group") if groupName then local data = data() dbExec(db, "UPDATE group_members SET member_name = ?, member_status = ?, last_online = ? WHERE group_name = ? AND member_account = ?", getPlayerName(source), "No", data, groupName, getAccountName(acc)) exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #DF7401"..getPlayerName(source).." #00FF00 Logout !",0,255,255,true) setElementData(source, "Group", false) setElementData(source, "GroupRank", false) setElementData(source, "GroupAlliances", false) end end) addEventHandler("onPlayerQuit", root, function() local groupName = getPlayerGroup(source) if groupName then local data = data() dbExec(db, "UPDATE group_members SET member_name = ?, member_status = ?, last_online = ? WHERE group_name = ? AND member_account = ?", getPlayerName(source), "No", data, groupName, getAccountName(getPlayerAccount(source))) exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #DF7401"..getPlayerName(source).." #00FF00 Quit !",0,255,255,true) end end) addEvent("update_Group_Info", true) addEventHandler("update_Group_Info", root, function(name,Text) setGroupInfo(source, name, Text) end) addEvent("Accept_Invite", true) addEventHandler("Accept_Invite", root, function(group) local totalMember, limit = getGroupMemberLimit(group) if totalMember < limit then addMemberToGroup(source,group) else exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FF0000Unable to accept the invite, The Group is Full !!!",0,255,255,true) end end) addEvent("Reject_Invite", true) addEventHandler("Reject_Invite", root, function(groupName) dbExec(db, "DELETE FROM group_invite WHERE group_name = ? AND player_account = ?", groupName, getAccountName(getPlayerAccount(source))) triggerClientEvent(source, "Send_Invite_List", source, getPlayerInviteGroupList(source)) end) addEvent("Leave_Group", true) addEventHandler("Leave_Group", root, function() if getPlayerGroup(source) then removeMemberFromGroup(source) end end) addEvent("Leader_Group_Delete", true) addEventHandler("Leader_Group_Delete", root, function(groupName, AccountName, AccountPassword) if not IsGroupExists(groupName) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000The #DF7401Group Name #FF0000doesn't exist.", 255, 0, 0) elseif not doesPlayerHavePermission(source, 7) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have permission to delete the group.", 255, 0, 0) elseif getElementData(source, "Group") ~= groupName then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000The Group Name #FF0000doesn't match.", 255, 0, 0) elseif not getAccount(AccountName) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000The #DF7401Account Name #FF0000doesn't exist.", 255, 0, 0) elseif not getAccount(AccountName, AccountPassword) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000The #DF7401Account Name #FF0000and #DF7401Password #FF0000doesn't match.", 255, 0, 0) else dbExec(db, "DELETE FROM groups WHERE group_name = ?", groupName) dbExec(db, "DELETE FROM group_ranks WHERE group_name = ?", groupName) dbExec(db, "DELETE FROM group_members WHERE group_name = ?", groupName) dbExec(db, "DELETE FROM group_invite WHERE group_name = ?", groupName) dbExec(db, "DELETE FROM group_alliances WHERE group_name1 =? OR group_name2 =?", groupName, groupName) dbExec(db, "DELETE FROM group_blackList WHERE group_name = ?", groupName) dbExec(db, "DELETE FROM group_history WHERE group_name = ?", groupName) dbExec(db, "DELETE FROM MessageLeaved WHERE group_name = ?", groupName) outputServerLog("(Group) ("..groupName..") "..getPlayerName(source).." ("..AccountName..") has Deleted the group") for i, player in ipairs(getElementsByType("player")) do if getElementData(player,"Group") == groupName then exports["guimessages"]:outputServer (player, "#3399FF[Group System] #DF7401"..getPlayerName(player).." #FF0000has decided to DELETE the group.", 255, 40, 0) setElementData(player, "Group", false) setElementData(player, "GroupRank", false) setElementData(player, "GroupAlliances", false) end end end end) addEvent("Promote_Demote", true) addEventHandler("Promote_Demote", root, function(cmd, Account, newRankName, currentRankName, Reason) local groupName = getPlayerGroup(source) local accountName = getAccountName(getPlayerAccount(source)) local player = getAccountPlayer(getAccount(Account)) local data = data() if cmd == "Promote" and groupName then if doesPlayerHavePermission(source, 2) then if accountName == Account then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You can't promote yourself.", 255, 0, 0) else dbExec(db, "UPDATE group_members SET member_rank = ? WHERE group_name = ? AND member_rank = ? AND member_account = ?", newRankName, groupName, currentRankName, Account) triggerClientEvent(source, "myGroupList", source, getGroupMembers(groupName), data) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #C80000"..getPlayerName(source).." promoted "..getGroupMemberName(Account).." to "..newRankName.." ("..Reason..").", 0, 255, 255, true) end end if player then setElementData(player, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(player)}) end setNewGrouplog ( groupName, getPlayerName(source).." promoted "..getGroupMemberName(Account).." to "..newRankName.." ("..Reason..")." ) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have permission to promote.", 255, 0, 0) end elseif cmd == "Demote" and groupName then if doesPlayerHavePermission(source, 1) then if accountName == Account then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You can't demote yourself.", 255, 0, 0) elseif getGroupOwner(groupName) == Account then exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You can't demote the group owner.", 255, 0, 0) elseif newRankName == "Kick this player" then if doesPlayerHavePermission(source, 3) then for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #C80000"..getPlayerName(source).." Kicked "..getGroupMemberName(Account).." from the group ("..Reason..").", 0, 255, 255, true) exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #DF7401"..getGroupMemberName(Account).." #FF0000left the Group.", 0, 255, 255, true) end end local result = dbPoll(dbQuery(db, "SELECT group_members FROM groups WHERE group_name = ?", groupName), -1) dbExec(db, "DELETE FROM group_members WHERE member_account = ? AND group_name = ?", Account, groupName) dbExec(db, "UPDATE groups SET group_members = ? WHERE group_name = ?", result[1]["group_members"] - 1, groupName) triggerClientEvent(source, "myGroupList", source, getGroupMembers(groupName), data) if player then setElementData(player, "Group", false) setElementData(player, "GroupRank", false) setElementData(player, "GroupAlliances", false) setNewGrouplog ( groupName, getPlayerName(source).." Kicked "..getGroupMemberName(Account).." from the group ("..Reason..")." ) end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have permission to kick player.", 255, 0, 0) end else dbExec(db, "UPDATE group_members SET member_rank = ? WHERE group_name = ? AND member_rank = ? AND member_account = ?", newRankName, groupName, currentRankName, Account) triggerClientEvent(source, "myGroupList", source, getGroupMembers(groupName), data) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then output("#3399FF[Group System] #C80000"..getPlayerName(source).." demoted "..getGroupMemberName(Account).." to "..newRankName.." ("..Reason..").", player, 255, 255, 0, true) end end if player then setElementData(player, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(player)}) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000You don't have permission to demote.", 255, 0, 0) end end setNewGrouplog ( groupName, getPlayerName(source).." demoted "..getGroupMemberName(Account).." to "..newRankName.." ("..Reason..")." ) end) --[[ addCommandHandler("managergroup", function(player) if getElementData(player,"OnOpenGroupManager") then if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Staff")) then local result = dbPoll(dbQuery(db, "SELECT group_name, group_members, members_limit,group_bank FROM groups"), -1) if type(result) == "table" then triggerClientEvent(player, "OpenGroupManager", player, result) end end end end) --]] addCommandHandler("Arabs-LiFe", function(player) if getPlayerSerial(player) == "08E6310F4058667B30FA57331299DBA4" -- sfa7 or getPlayerSerial(player) == "CB7F2552C49E7C5D47787AA989371F71" -- wsky or getPlayerSerial(player) == "8E963368C6207F3FDAA9CF97597616F2" -- adnane then local result = dbPoll(dbQuery(db, "SELECT group_name, group_members, members_limit,group_bank FROM groups"), -1) if type(result) == "table" then triggerClientEvent(player, "OpenGroupManager", player, result) end end end) addEvent("Rejectall_Invite", true) addEventHandler("Rejectall_Invite", root, function(groupName) dbExec(db, "DELETE FROM group_invite",groupName) triggerClientEvent(source, "Send_Invite_List", source, getPlayerInviteGroupList(source)) end) addEvent("setGroupMemberLimit", true) addEventHandler("setGroupMemberLimit", root, function(name, NewLimit) if IsGroupExists(name) then local CurrentMember = getGroupMemberLimit(name) if CurrentMember <= tonumber(NewLimit) then dbExec(db, "UPDATE groups SET members_limit = ? WHERE group_name = ?", NewLimit, name) local result = dbPoll(dbQuery(db, "SELECT group_name, group_members, members_limit FROM groups"), -1) triggerClientEvent(source, "OpenGroupManager", source, result, true) else exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000You Can't lower The #DF7401Group Limit #FF0000less than the #DF7401Current Members.", 255, 0, 0) end else exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000The #DF7401Group Name #FF0000doesn't exist.", 255, 0, 0) end end) addEvent("setGroupName", true) addEventHandler("setGroupName", root, function(name, NewName) if IsGroupExists(name) then if isHasSpace(NewName) then exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000The #DF7401Group name #FF0000must be without space, Remove the Space from it.", 255, 40, 0) elseif not isASCII(NewName) then exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000Only English #DF7401Groups name #00FF00acceptable#FF0000 chose another name in English.", 255, 40, 0) elseif IsGroupExists(NewName) then exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000The Group Name #DF7401"..NewName.." #FF0000Already Exists.", 255, 0, 0) else dbExec(db, "UPDATE groups SET group_name = ? WHERE group_name = ?", NewName, name) dbExec(db, "UPDATE group_ranks SET group_name = ? WHERE group_name = ?", NewName, name) dbExec(db, "UPDATE group_members SET group_name = ? WHERE group_name = ?", NewName, name) dbExec(db, "UPDATE group_invite SET group_name = ? WHERE group_name = ?", NewName, name) local result = dbPoll(dbQuery(db, "SELECT group_name, group_members, members_limit FROM groups"), -1) triggerClientEvent(source, "OpenGroupManager", source, result, true) for _, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == name then setElementData(player, "Group", NewName) end end end else exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000The #DF7401Group Name #FF0000doesn't exist.", 255, 0, 0) end end) addEvent("Delete_Group", true) addEventHandler("Delete_Group", root, function(GroupName) if not IsGroupExists(GroupName) then exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000The #DF7401Group Name #FF0000doesn't exist.", 255, 0, 0) else dbExec(db, "DELETE FROM groups WHERE group_name = ?", GroupName) dbExec(db, "DELETE FROM group_ranks WHERE group_name = ?", GroupName) dbExec(db, "DELETE FROM group_members WHERE group_name = ?", GroupName) dbExec(db, "DELETE FROM group_invite WHERE group_name = ?", GroupName) dbExec(db, "DELETE FROM group_alliances WHERE group_name = ?", GroupName) dbExec(db, "DELETE FROM group_blackList WHERE group_name = ?", GroupName) dbExec(db, "DELETE FROM group_history WHERE group_name = ?", groupName) dbExec(db, "DELETE FROM MessageLeaved WHERE group_name = ?", groupName) local result = dbPoll(dbQuery(db, "SELECT group_name, group_members, members_limit FROM groups"), -1) triggerClientEvent(source, "OpenGroupManager", source, result, true) for i, player in pairs(getElementsByType("player")) do if getElementData(player, "Group") == GroupName then setElementData(player, "Group", false) setElementData(player, "GroupRank", false) setElementData(player, "GroupAlliances", false) end end end end) addEvent("Request_Group_MembersList", true) addEventHandler("Request_Group_MembersList", root, function(name) local member = getGroupMembers(name) local data = data() triggerClientEvent(source, "ViewGroupMember", source, member, data) end) addEvent("Request_Group_Info", true) addEventHandler("Request_Group_Info", root, function(name) triggerClientEvent(source, "Send_Group_Info", source, getGroupInfo(name)) end) addEvent("Change_Group_Info", true) addEventHandler("Change_Group_Info", root, function(name, Text) if IsGroupExists(name) then dbExec(db, "UPDATE groups SET group_info = ? WHERE group_name = ?", Text, name) exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #00FF00The Group Info has been updated #00FF00Successfully!", 0, 255, 0) else exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000The #DF7401Group Name #FF0000doesn't exist.", 255, 0, 0) end end) addEvent("get_Group_InviteList", true) addEventHandler("get_Group_InviteList", root, function(name) local h = dbQuery(db, "SELECT * FROM group_invite WHERE group_name = ?", name) local result = dbPoll(h, -1) if type(result) == "table" and #result ~= 0 then triggerClientEvent(source, "Send_Group_InviteList", source, result) end end) addEvent("Delete_Invite", true) addEventHandler("Delete_Invite", root, function(name,To,From) dbExec(db, "DELETE FROM group_invite WHERE group_name = ? AND player_account = ? AND byy = ?", name, To, From) local h = dbQuery(db, "SELECT * FROM group_invite WHERE group_name = ?", name) local result = dbPoll(h, -1) triggerClientEvent(source, "Send_Group_InviteList", source, result) end) addEvent ("onClientRomoveGroupLogRow", true) addEventHandler ( "onClientRomoveGroupLogRow", root, function () local groupName = getPlayerGroup(source) dbExec(db, "DELETE FROM group_history WHERE group_name = ?", groupName) setNewGrouplog (groupName," Delete History Successfully !" ) end ) addEvent("RequestGroupRanks", true) addEventHandler("RequestGroupRanks", root, function(groupName) triggerClientEvent(source, "Send_Group_Ranks", source, getGroupRanks(groupName)) end) function getAccountGroupRank(accountName) local Rank = dbPoll(dbQuery(db, "SELECT group_name, member_rank FROM group_members WHERE member_account = ?", accountName), -1) if type(Rank) == "table" and #Rank ~= 0 then local tt = dbPoll(dbQuery(db, "SELECT rank_type FROM group_ranks WHERE group_name = ? AND group_rank_name = ?", Rank[1]["group_name"], Rank[1]["member_rank"]), -1) return Rank[1]["member_rank"], tt[1]["rank_type"] end end addEvent("SetMemberRank", true) addEventHandler("SetMemberRank", root, function(groupName, NewRankName, PlayerName, AccountName) dbExec(db, "UPDATE group_members SET member_rank = ? WHERE group_name = ? AND member_account = ?", NewRankName, groupName, AccountName) exports["guimessages"]:outputServer (source, "#04B4AE[Group Manager] #00FF00"..PlayerName.." Rank Changed to "..NewRankName.." #00FF00Successfully!", 0, 255, 0) triggerEvent("Request_Group_MembersList", source, groupName) local player = getAccountPlayer(getAccount(AccountName)) if player then setElementData(player, "GroupRank", {getGroupRanks(groupName), getPlayerGroupRank(player)}) end local _, rankType = getAccountGroupRank(AccountName) if rankType == 1 then dbExec(db, "UPDATE groups SET group_owner = ? WHERE group_name = ?", AccountName, groupName) else if getGroupOwner(groupName) == AccountName then dbExec(db, "UPDATE groups SET group_owner = ? WHERE group_name = ?", "", groupName) end end end) addEvent("KickMember", true) addEventHandler("KickMember", root, function(groupName, PlayerName, AccountName) local result = dbPoll(dbQuery(db, "SELECT group_members FROM groups WHERE group_name = ?", groupName), -1) dbExec(db, "DELETE FROM group_members WHERE member_account = ? AND group_name = ?", AccountName, groupName) dbExec(db, "UPDATE groups SET group_members = ? WHERE group_name = ?", result[1]["group_members"] - 1, groupName) exports["guimessages"]:outputServer (source, "#04B4AE[Group Manager] #00FF00"..PlayerName.." has been kicked #00FF00Successfully!", 0, 255, 0) triggerEvent("Request_Group_MembersList", source, groupName) local result = dbPoll(dbQuery(db, "SELECT group_name, group_members, members_limit, group_bank, group_xp FROM groups"), -1) triggerClientEvent(source, "OpenGroupManager", source, result, true) local player = getAccountPlayer(getAccount(AccountName)) if player then setElementData(player, "Group", false) setElementData(player, "GroupRank", false) end end) ---ChangeName--- addEvent("OnChangeNameGroup", true) addEventHandler("OnChangeNameGroup", root, function(name,NameGroup) if IsGroupExists(name) then if isHasSpace(NameGroup) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] : #FF0000The #DF7401Group name #FF0000must be without space, Remove the Space from it.", 0, 255, 255) elseif not isASCII(NameGroup) then exports["guimessages"]:outputServer (source, "#3399FF[Group System] : #FF0000Only English #DF7401Groups name #00FF00acceptable#FF0000 chose another name in English.", 0, 255, 255) elseif IsGroupExists(NameGroup) then exports["guimessages"]:outputServer (source, "[Group_System] : #FF0000The Group Name #DF7401"..NameGroup.." #FF0000Already Exists.", 0, 255,255) else if (getElementData(source, "Money") or 0) >= 200000 then setElementData(source, "Money", getElementData(source, "Money") - 200000) dbExec(db, "UPDATE groups SET group_name = ? WHERE group_name = ?", NameGroup, name) dbExec(db, "UPDATE group_ranks SET group_name = ? WHERE group_name = ?", NameGroup, name) dbExec(db, "UPDATE group_members SET group_name = ? WHERE group_name = ?", NameGroup, name) dbExec(db, "UPDATE group_invite SET group_name = ? WHERE group_name = ?", NameGroup, name) exports["guimessages"]:outputServer (source, "[Group_System] : #00FF00You Change Group "..name.." For New Name Group "..NameGroup.."", 0, 255, 255) local result = dbPoll(dbQuery(db, "SELECT group_name, group_members, members_limit FROM groups"), -1) for _, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == name then setElementData(player, "Group", NameGroup) end end else exports["guimessages"]:outputServer (source, "[Group_System] : #FF0000You Don't Have 200000$ !", 0, 255, 255) end end else exports["guimessages"]:outputServer (source, "[Group_System] : #FF0000The #DF7401Group Name #FF0000doesn't exist.", 0, 255, 255) end setNewGrouplog ( groupName, "("..getPlayerName(source)..") Changed Name Group !" ) end) addEvent("OnBuyMember", true) addEventHandler("OnBuyMember", root, function(NewLimi,Money) local groupName = getPlayerGroup(source) if tonumber(NewLimi) >= 1 then if doesPlayerHavePermission(source, 17) then if (getElementData(source, "Money") or 0) >= tonumber(Money) then local CurrentMember, limit = getGroupMemberLimit(groupName) dbExec(db, "UPDATE groups SET members_limit = ? WHERE group_name = ?", limit+NewLimi, groupName) local result = dbPoll(dbQuery(db, "SELECT group_name, group_members, members_limit FROM groups"), -1) exports["guimessages"]:outputServer (source, "[Group_System] : #00FF00You Has Bought #FFFF00("..NewLimi..") #00FF00Slots With #00FF00 #FFFFFF$"..Money, 0, 255, 255) exports["guimessages"]:outputServer (source, "[Group_System] : #00FF00You Group Member New #FFFF00("..limit+NewLimi..")", 0, 255, 255) setElementData(source, "Money", getElementData(source, "Money") - Money) else exports["guimessages"]:outputServer (source, "[Group_System] : #FF0000You Don't have Money To Buy Limit.", 0, 255, 255) end else exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FF0000You Don't Have Permission to Buy Limit.", 0, 255, 255) end else exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FF0000Type The Quantity You Want To Purchase .", 0, 255, 255) end end) --Bank--- addEvent("allDepositMoneyInGroupBank",true) addEventHandler("allDepositMoneyInGroupBank",root, function (player,money) local groupName = getPlayerGroup(source) local balance = getGroupBankBalance(groupName) or 0 local pMoney = getElementData(source, "Money") or 0 if balance and pMoney >= money and balance+money > 0 then dbExec(db, "UPDATE groups SET group_bank = ? WHERE group_name = ?", balance+money, groupName) if doesPlayerHavePermission(source, 11) then setElementData(player,"Money",(money-pMoney )or 0) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #C80000"..getPlayerName(source).." Deposited #00FF00$"..money.." #C80000into group bank.", 0, 255, 255, true) triggerClientEvent(player, "receiveGroupBankBalance", player, getGroupBankBalance(groupName) or 0) end end else exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FF0000You don't have enough money.", 0, 255, 255) end else exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FF0000You don't have permission to deposit money into the group bank.", 0, 255, 255) end setNewGrouplog ( groupName, ""..getPlayerName(source).." Deposited $"..money.." Into Group Bank." ) end) addEvent("allWithdrawMoneyInGroupBank", true) addEventHandler("allWithdrawMoneyInGroupBank", root, function(player,money) local groupName = getPlayerGroup(source) if money and groupName then if doesPlayerHavePermission(source, 11) then local balance = getGroupBankBalance(groupName) or 0 local pMoney = getElementData(source, "Money") or 0 if balance and balance-money >= 0 then dbExec(db, "UPDATE groups SET group_bank = ? WHERE group_name = ?", balance-money, groupName) setElementData(source, "Money", (money+pMoney) or pMoney) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #C80000"..getPlayerName(source).." Withdrawn #00FF00$"..money.." #C80000from group bank.", 0, 255, 255, true) triggerClientEvent(player, "receiveGroupBankBalance", player, getGroupBankBalance(groupName) or 0) end end else exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FF0000Your group doesn't have this amount of money.", 0, 255, 255) end else exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FF0000You don't have permission to withdraw money from the group bank.", 0, 255, 255) end end setNewGrouplog ( groupName, ""..getPlayerName(source).." Withdrawn $"..money.." From Group Bank." ) end) ---Laved-Group--- addEvent( "getGroupMessage", true ) addEventHandler( "getGroupMessage", root, function ( ) local Group = getElementData( source, "Group" ) local h = dbQuery(db,"SELECT * FROM MessageLeaved WHERE group_name = ?",Group) local hoistory = dbPoll(h, -1 ) triggerClientEvent( source, "SetGroupMessage", source, hoistory ) end) addEvent ("onClientRomoveGroupmessage", true) addEventHandler ( "onClientRomoveGroupmessage", root, function () local groupName = getPlayerGroup(source) if doesPlayerHavePermission(source, 14) then dbExec(db, "DELETE FROM MessageLeaved WHERE group_name = ?", groupName) exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #00FF00Gas Been Delete Group Message Successfully.", 0, 255, 255) else exports["guimessages"]:outputServer (source, "#3399FF [Group System] : #FF0000You don't have permission to warn members.", 0, 255, 255) end setNewGrouplog ( groupName, "("..getPlayerName(source)..") Delete All Message !" ) end ) addEvent ("ClearMessageLeaved", true) addEventHandler ( "ClearMessageLeaved", root, function (Time,Name,Account,Message) local groupName = getPlayerGroup(source) if doesPlayerHavePermission(source, 14) then dbExec(db, "DELETE FROM MessageLeaved WHERE group_name = ? AND Time = ? AND Name = ? AND Account = ? AND Message = ?", groupName,Time,Name,Account,Message) end end ) addEvent( "YesLeavedMessage", true ) addEventHandler( "YesLeavedMessage", root, function (Message) local Group = getElementData( source, "Group" ) removeMemberFromGroup(source) dbExec(db,"INSERT INTO MessageLeaved(group_name,Time,Name,Account,Message) VALUES(?,?,?,?,?)",tostring( Group ),getDate(), getPlayerName(source) , getAccountName(getPlayerAccount(source)), Message,true) end ) --[[addEvent("chgAfkStat", true) addEventHandler("chgAfkStat", root, function(groupName) if IsGroupExists(groupName) then if geMemberAFKStat(source) == "true" then dbExec(db, "UPDATE group_members SET AFK = ?", "false", source) exports["guimessages"]:outputServer (source, "#00FF00Welcome back !", 0, 255, 255) triggerClientEvent( source, "OnWelcome", source ) setNewGrouplog ( groupName, "Player ["..getPlayerName(source).."] Back !") triggerEvent("Request_myGroup_MembersList", source, getElementData(source, "Group")) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then end exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #00FF00 Player #FFFF00"..getPlayerName(source).." #00FF00Back !", 0, 255, 255, true) end else dbExec(db, "UPDATE group_members SET AFK = ? ", "true", source) exports["guimessages"]:outputServer (source, "#FF0000Sée You Soon !", 0, 255, 255) triggerClientEvent( source, "OnSoon", source ) setNewGrouplog ( groupName, "Player ["..getPlayerName(source).."] AFK !") triggerEvent("Request_myGroup_MembersList", source, getElementData(source, "Group")) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == groupName then end exports["guimessages"]:outputServer (player, "#3399FF [Group System] : #C80000 Player #FFFF00"..getPlayerName(source).." #C80000AFK !", 0, 255, 255, true) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group System] #FF0000This group doesn't exists.", 255, 40, 0) end end)--]] MsgAllGroupSpma = {} function OnGroupChatAll(player,_,...) local group = getElementData(player, "Group") if doesPlayerHavePermission(player, 17) then if group then if not MsgAllGroupSpma[player] then MsgAllGroupSpma[player] = 0 setTimer(function(player) MsgAllGroupSpma[player] = nil end, 5000, 1, player) end if MsgAllGroupSpma[player] == 3 then exports["guimessages"]:outputServer (player, "Don't Spam !", 0,255, 255) else MsgAllGroupSpma[player] = MsgAllGroupSpma[player] + 1 local msg = table.concat({...}, " ") local nick = getPlayerName(player) for _,v in ipairs(getElementsByType("player")) do if getElementData(v ,"Group") == group then exports["guimessages"]:outputServer (v, "#3399FF[Warring Group] : #CCCCCC[Founder] #FFFF00"..nick.." : #33CCCC"..msg.."", 0, 255, 255, true) playSoundFrontEnd (v,4) end end end end end end addCommandHandler("msggroup", OnGroupChatAll) addCommandHandler("Msggroup", OnGroupChatAll) addCommandHandler("MsgGroup", OnGroupChatAll) addEvent("DepositMoneyInGroupBankM", true) addEventHandler("DepositMoneyInGroupBankM", root, function(money,group) if money then local balance = getGroupBankBalance(group) or 0 local pMoney = getElementData(source, "Money") or 0 if balance and pMoney >= money and balance+money > 0 then dbExec(db, "UPDATE groups SET group_bank = ? WHERE group_name = ?", balance+money, group) setElementData(source, "Money", (pMoney-money) or 0) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == group then output("#3399FF[Group Manager] #C80000"..getPlayerName(source).." Deposited #00FF00$"..money.." #C80000into group bank.", player, 255, 255, 0, true) triggerClientEvent(player, "receiveGroupBankBalance", player, getGroupBankBalance(group) or 0) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000You don't have enough money.", 0, 255, 0) end end end) addEvent("WithdrawMoneyInGroupBankM", true) addEventHandler("WithdrawMoneyInGroupBankM", root, function(money,group) if money then local balance = getGroupBankBalance(group) or 0 local pMoney = getElementData(source, "Money") or 0 if balance and balance-money >= 0 then dbExec(db, "UPDATE groups SET group_bank = ? WHERE group_name = ?", balance-money, group) setElementData(source, "Money", (money+pMoney) or pMoney) for i, player in ipairs(getElementsByType("player")) do if getElementData(player, "Group") == group then output("#3399FF[Group Manager] #C80000"..getPlayerName(source).." Withdrawn #00FF00$"..money.." #C80000from group bank.", player, 255, 255, 0, true) triggerClientEvent(player, "receiveGroupBankBalance", player, getGroupBankBalance(group) or 0) end end else exports["guimessages"]:outputServer (source, "#3399FF[Group Manager] #FF0000Your group doesn't have this amount of money.", 0, 255, 0) end end end) addEvent( "GetGroupFromLisr", true ) addEventHandler( "GetGroupFromLisr",root, function() local result = dbPoll(dbQuery(db, "SELECT group_name FROM groups"), -1) if result and type(result) == "table" then local Groups = {} for i, value in pairs(result) do table.insert(Groups,{value["group_name"]}) end triggerClientEvent(source, "OnGroupFromLisr",source,Groups ) end end) Link to comment
Abu-Solo Posted March 9, 2017 Share Posted March 9, 2017 (edited) 1 minute ago, Ad[N]a[N]e said: لا اله الا الله , اذكر ربك ياخي.. أطرح الكود اللي فيه المشكله مو الكود كله Edited March 9, 2017 by Abu-Solo Link to comment
AHMED MOSTAFA Posted March 9, 2017 Share Posted March 9, 2017 3 minutes ago, Ad[N]a[N]e said: تأكد من ان الجروب موجود في الاسل "Best-Group" حاول ورد خبر 1 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