Jump to content

[IMPRTANT]group system problem


Recommended Posts

hi guyz.. when i give promote any player to any rank in group then the player do /reconnect when he came back his rang get back to trail where is the problem ??

local balanceTable = {} 
 
function viewGroupAdmin()
    if (getLocalPlayerGroup(localPlayer)) then
        if (getLocalGroupRank(localPlayer) == "Founder" or getLocalGroupRank(localPlayer) == "Deputy") then
            guiSetVisible(management_wnd, true)
            guiBringToFront(management_wnd)
            guiGridListClear(managementGrid)
            for index, members in pairs(getElementsByType("player")) do
                local pg = getLocalPlayerGroup(members)
                if (pg and pg == getLocalPlayerGroup(localPlayer)) then
                    local name = getPlayerName(members)
                    local rank = getLocalGroupRank(members)
                    local row = guiGridListAddRow(managementGrid)
                    guiGridListSetItemText(managementGrid, row, 1, name, false, false)
                    guiGridListSetItemText(managementGrid, row, 2, rank, false, false)
                end
            end
        end
    end
end
 
function viewInvites()
    guiSetVisible(invites_wnd, true)
    guiBringToFront(invites_wnd)
end
 
function viewGroupList()
    triggerServerEvent("UIPgroups.getGroupList", root)
    guiSetVisible(list_wnd, true)
    guiBringToFront(list_wnd)
    guiGridListClear(list_grid)
end
 
function viewGroupPage()
    if (getLocalPlayerGroup(localPlayer)) then
        guiSetVisible(myGroup_wnd, true)
        guiBringToFront(myGroup_wnd)
        guiGridListClear(myGroupGrid)
        triggerServerEvent("UIPgroups.viewMyPage", root)
    end
end
 
function viewCreate()
    if (getLocalPlayerGroup(localPlayer)) then
        exports.UIPtexts:output("You must leave your current group first", 255, 0, 0)
    else
        guiSetVisible(createGroup_wnd, true)
        guiBringToFront(createGroup_wnd)
    end
end
 
function viewLeave()
    if (getLocalPlayerGroup(localPlayer)) then
        guiSetVisible(leave_wnd, true)
        guiBringToFront(leave_wnd)
    else
        exports.UIPtexts:output("You are not currently in a group", 255, 0, 0)
    end
end
 
function leaveGroup()
    guiSetVisible(leave_wnd, false)
    triggerServerEvent("UIPgroups.leaveGroup", root)
end
 
function acceptInvite()
    local group = guiGridListGetItemText(invites_grid, guiGridListGetSelectedItem(invites_grid), 1)
    local sender = guiGridListGetItemText(invites_grid, guiGridListGetSelectedItem(invites_grid), 2)
    if (group == "") then return end
    guiGridListRemoveRow(invites_grid, guiGridListGetSelectedItem(invites_grid))
    triggerServerEvent("UIPgroups.acceptedInvite", root, group, sender)
end
 
function rejectInvite()
    local group = guiGridListGetItemText(invites_grid, guiGridListGetSelectedItem(invites_grid), 1)
    local sender = guiGridListGetItemText(invites_grid, guiGridListGetSelectedItem(invites_grid), 2)
    if (group == "") then return end
    guiGridListRemoveRow(invites_grid, guiGridListGetSelectedItem(invites_grid))
    exports.UIPtexts:output("Rejected "..sender.."'s invite to join "..group, 0, 255, 0)
end
 
function createGroup()
    if (getLocalPlayerGroup(localPlayer)) then
        exports.UIPtexts:output("You must leave your current group first", 255, 0, 0)
    else
        local theName = guiGetText(createGroupEdit)
        if (badWords[theName]) then
            exports.UIPtexts:output(theName.." contains words that are not allowed to use", 255, 0, 0)
            return
        end
        if (theName:len() > 25) then
            exports.UIPtexts:output("Group name can not contain more than 25 characters", 255, 0, 0)
            return
        end
        if (theName:len() < 3) then
            exports.UIPtexts:output("Group name must contain more than 3 characters", 255, 0, 0)
            return
        end
        guiSetVisible(createGroup_wnd, false)
        triggerServerEvent("UIPgroups.createGroup", root, theName)
    end
end
 
function demoteMember()
    local selected = getPlayerFromName(guiGridListGetItemText(managementGrid, guiGridListGetSelectedItem(managementGrid), 1))
    if (isElement(selected)) then
        triggerServerEvent("UIPgroups.demoteSomebody", root, selected)
    end
end
 
function promoteMember()
    local selected = getPlayerFromName(guiGridListGetItemText(managementGrid, guiGridListGetSelectedItem(managementGrid), 1))
    if (isElement(selected)) then
        triggerServerEvent("UIPgroups.promoteSomebody", root, selected)
    end
end
 
function viewUpdateInfo()
    guiSetVisible(setInfo_wnd, true)
    guiBringToFront(setInfo_wnd)
    triggerServerEvent("UIPgroups.getTextAdmin", root)
end
 
function viewInviteMember()
    guiSetVisible(inviteMember_wnd, true)
    guiBringToFront(inviteMember_wnd)
    guiGridListClear(inviteMemberGrid)
    for index, player in pairs(getElementsByType("player")) do
        local row = guiGridListAddRow(inviteMemberGrid)
        guiGridListSetItemText(inviteMemberGrid, row, 1, getPlayerName(player), false, false)
    end
end
 
function viewBank()
    guiSetVisible(groupBank_wnd, true)
    guiBringToFront(groupBank_wnd)
end
 
function deleteGroup()
    if (getLocalGroupRank(localPlayer) == "Founder") then
        triggerServerEvent("UIPgroups.deleteGroup", root)
    end
end
 
function passLeadership()
    -- Give leadership to selected player (from gridlist)
end
 
function kickMember()
    local selected = getPlayerFromName(guiGridListGetItemText(managementGrid, guiGridListGetSelectedItem(managementGrid), 1))
    if (isElement(selected)) then
        triggerServerEvent("UIPgroups.kickSomebody", root, selected)
    end
end
 
function invitePlayer()
    local selected = getPlayerFromName(guiGridListGetItemText(inviteMemberGrid, guiGridListGetSelectedItem(inviteMemberGrid), 1))
    if (isElement(selected)) then
        triggerServerEvent("UIPgroups.sendInvite", root, selected)
    end
end
 
function searchInvite()
    guiGridListClear(inviteMemberGrid)
    local name = guiGetText(source)
    for index, players in pairs(getElementsByType("player")) do
        local newName = getPlayerName(players)
        if (string.find(newName:lower(), name:lower(), 1, true)) then
            local row = guiGridListAddRow(inviteMemberGrid)
            guiGridListSetItemText(inviteMemberGrid, row, 1, newName, false, false)
        end
    end
end
 
function depositMoney()
    -- Deposit money into the group bank
end
 
function withdrawMoney()
    -- Withdraw the money from the group bank
end
 
function saveInfo()
    local newText = guiGetText(setInfo_memo)
    triggerServerEvent("UIPgroups.updateText", root, newText)
end
 
 
function myGroupDeposit()
    local amount = guiGetText(myGroupBankEdit)
    if (tonumber(amount) < 0 or not tonumber(amount)) then
        exports.UIPtexts:output("Invalid amount to deposit", 255, 0, 0)
        return
    end
    if (getPlayerMoney() < tonumber(amount)) then
        exports.UIPtexts:output("Missing $"..amount - getPlayerMoney(), 255, 0, 0)
        return
    end
    if (balanceTable[getLocalPlayerGroup(localPlayer)]) then
        local old = balanceTable[getLocalPlayerGroup(localPlayer)] or 0
        local nBalance = old + tonumber(amount)
        local formatted = exports.UIPmisc:formatNumber(nBalance)
        guiSetText(myGroupBankBalace, "Group Balance: $"..formatted)
        balanceTable[getLocalPlayerGroup(localPlayer)] = nBalance
    end
    triggerServerEvent("UIPgroups.depositMoney", root, tonumber(amount))
end
 
----------------------------------------------------------------------------------------------------------------------------------------------
 
function addGroupToList(name, founder, count)
    if (name and founder and count) then
        local row = guiGridListAddRow(list_grid)
        guiGridListSetItemText(list_grid, row, 1, name, false, false)
        guiGridListSetItemText(list_grid, row, 2, founder, false, false)
        guiGridListSetItemText(list_grid, row, 3, tostring(count), false, false)
        if (name == getLocalPlayerGroup(localPlayer)) then
            guiGridListSetItemColor(list_grid, row, 1, 0, 255, 0)
            guiGridListSetItemColor(list_grid, row, 2, 0, 255, 0)
            guiGridListSetItemColor(list_grid, row, 3, 0, 255, 0)
        end
    end
end
addEvent("UIPgroups.addGroupToList", true)
addEventHandler("UIPgroups.addGroupToList", root, addGroupToList)
 
function addInvite(group, sender)
    if (group and sender) then
        local row = guiGridListAddRow(invites_grid)
        guiGridListSetItemText(invites_grid, row, 1, group, false, false)
        guiGridListSetItemText(invites_grid, row, 2, sender, false, false)
    end
end
addEvent("UIPgroups.addInvite", true)
addEventHandler("UIPgroups.addInvite", root, addInvite)
 
function setMotdTextAdmin(text)
    guiSetText(setInfo_memo, text)
end
addEvent("UIPgroups.setMotdTextAdmin", true)
addEventHandler("UIPgroups.setMotdTextAdmin", root, setMotdTextAdmin)
 
 
function addToMyPage(account, rank, balance, motd, player)
    if (account and rank and motd) then
        local balance = balance or 0
        local formatted = exports.UIPmisc:formatNumber(balance)
        guiSetText(myGroupBankBalace, "Group Balance: $"..formatted)
        guiSetText(myGroupInfo, motd)
        balanceTable[getLocalPlayerGroup(localPlayer)] = balance
       
Edited by Guest
Link to comment
Very simple, his rank doesn't get saved when he leaves the server. Or, if you did implent that, give us that piece of code (Rule number) and also check /debugscript 3 for errors.

sorry but i didnt understand how his rank didnt save ? can u more enplane ? can i give u my group system resoures and u fix it ?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...