Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2018-12-01, 14:54


Ognisty_12877







Wiek: 24
Na forum: 3033 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

Witam nie mam poj?cia jak wzi??? lidera gracza czyli founder do pliku w kt?rym jest on wymagany, oba pliki sa po stronie serwera. Stawiam zimne piwerko

kod grup tam gdzie jest lider:
local groupTable = {}
local logging = false 
local debugInfo = false 
local GAC = {} -- index = account (string), [1] = group name, [2] = rank, [3] = warning level, [4] = date Joined, [5] = last time online (Not Available)
local users = {}
local myGang = {}
local char = "[^0-9a-zA-Z_]"
local rankCache = {}
local db = dbConnect("sqlite", "group/database.db")
dbExec(db, "CREATE TABLE IF NOT EXISTS groupmember (account TEXT, groupName TEXT, rank TEXT, warningLvl TEXT, joined TEXT, lastTime TEXT)")
dbExec(db, "CREATE TABLE IF NOT EXISTS groups (name TEXT, leader TEXT, message TEXT, chatcolor TEXT, notecolor TEXT, date TEXT, turfcolor TEXT, cashflow TEXT)")
dbExec(db, "CREATE TABLE IF NOT EXISTS groupRanks (groupName TEXT, name TEXT, permissions TEXT)")
dbExec(db, "CREATE TABLE IF NOT EXISTS groupVault (groupName TEXT, leader TEXT)")
playerTeam = createTeam("Player")

--Some misc functions
_outputDebugString = outputDebugString
function outputDebugString(string)
    if (debugInfo) then _outputDebugString(string) end
end

function getTheTime()
    local time = getRealTime()
    local date = string.format("%02d/%02d/%02d", time.monthday, (time.month+1), (time.year-100) )
    local time = string.format("%02d:%02d", time.hour, time.minute)
    return date, time
end

MTAoutput = outputChatBox
function outputChatBox(message, player, r, g, b, bool)
    if (isElement(message) and getElementType(message) == "player") then
        MTAoutput(player, message, r, g, b, bool)
    else
        MTAoutput(message, player, r, g, b, bool)
    end
end

function groupLog(group, message)
    if (logging) then
        outputServerLog("GROUP: "..group.." - "..message)
    end
    --[[
    if (debugInfo) then
        outputDebugString("GROUP: "..group.." - "..message)
    end
    ]]
end

--Lets start
local permToTable = {
    [1] = "invite",
    [2] = "promote",
    [3] = "demote",
    [4] = "kick",
    [5] = "warn",
    [6] = "delete",
    [7] = "deposit",
    [8] = "withdraw",
    [9] = "editInfo",
    [10] = "viewLog",
    [11] = "viewBlacklist",
    [12] = "addBlacklist",
    [13] = "modifyAlliance",
    [14] = "modifyRanks",
}

function GetAccount(plr)
    if (plr and isElement(plr)) then
        return getAccountName(getPlayerAccount(plr))
    end
end

function loadGroupRanks(query)
    local the_table = dbPoll(query, 0)
    if (the_table) then
        for ind, data in pairs(the_table) do
            if (not rankCache[data.groupName]) then rankCache[data.groupName] = {} end
            if (not rankCache[data.groupName][data.name]) then rankCache[data.groupName][data.name] = {} end
            local JSONtable = fromJSON(data.permissions)
            for ind, value in pairs(JSONtable) do
                if (value and ind) then
                    rankCache[data.groupName][data.name][ind] = true
                end
            end
        end
    end
end
dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks")

function loadGroupStuff(query)
    local g_table = dbPoll(query, 0)
    
    if (not g_table) then return end
    
    for ind, data in ipairs(g_table) do
        groupTable[data.name] = {data.leader, data.message, data.chatcolor, data.notecolor, data.date, data.turfcolor, data.cashflow}
    end
end
dbQuery(loadGroupStuff, db, "SELECT * FROM groups")

function loadClientGroup(query)
    local g_table = dbPoll(query, 0)
    
    if (not g_table) then return end
    
    for ind, data in ipairs(g_table) do
        if (getAccount(data.account)) then
            local player = getAccountPlayer(getAccount(data.account))
            users[data.groupName] = {}
            table.insert(users[data.groupName], data.account)
            if (player) then
                setElementData(player, "Group", data.groupName)
                myGang[player] = data.groupName
            end
            GAC[data.account] = {data.groupName, data.rank, data.warningLvl, data.joined, data.lastTime or 0}
        end
    end
end
dbQuery(loadClientGroup, db, "SELECT * FROM groupmember")

function addRank(group, rank, permissionTable)
    if (not rankCache[group]) then rankCache[group] = {} end
    --rankCache[group][rank] = {fromJSON(permissionTable)}
    dbExec(db, "INSERT INTO groupRanks VALUES (?, ?, ?)", tostring(group), tostring(rank), permissionTable)
    dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks")
end

function removeRank(group, rank)
    if (not rankCache[group]) then return true end
    if (rankCache[group][rank]) then
        rankCache[group][rank] = nil
        dbExec(db, "DELETE FROM groupRanks WHERE name=? AND groupName=?", tostring(rank), tostring(group))
        dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks")
        return true
    end
end

function isRank(group, rank)
    if (not rankCache[group]) then return false end
    return rankCache[group][rank]
end

function groupMemberLogin()
    if (GAC[GetAccount(source)]) then
        myGang[source] = GAC[GetAccount(source)][1]
        setElementData(source, "Group", GAC[GetAccount(source)][1])
        setPlayerTeam(source,playerTeam)
        local date, time = getTheTime()
        local date = date.." - "..time
        GAC[GetAccount(source)][5] = date
    end
end
addEventHandler("onPlayerLogin", root, groupMemberLogin)

function groupMemberQuit()
    if (GAC[GetAccount(source)]) then
        local date, time = getTheTime()
        local date = date.." - "..time
        GAC[GetAccount(source)][5] = date
    end
end
addEventHandler("onPlayerQuit", root, groupMemberQuit)

function getGroupMembers(group)
    local temp = {}
    for ind, data in pairs(users) do
        if (ind == group) then
            table.insert(temp, data[1])
        end
    end
    return temp
end

function getPlayerGroup(player)
    if (not GAC[GetAccount(player)]) then return false end
    return GAC[GetAccount(player)][1]
end

function getPlayerGroupRank(player)
    if (not GAC[GetAccount(player)]) then return false end
    return GAC[GetAccount(player)][2]
end

function getPlayerWarningLevel(player)
    if (not GAC[GetAccount(player)]) then return false end
    return GAC[GetAccount(player)][3]
end

function getGroupBankAmount(group)
    if (not groupTable[group]) then return end
    return groupTable[group][7]
end

function getPlayerJoinDate(player)
    if (not GAC[GetAccount(player)]) then return false end
    return GAC[GetAccount(player)][4]
end

function getHexCode(r, g, b)
    if (r and g and b) then
        return string.format("#%.2X%.2X%.2X", r, g, b)
    end
end

function getGroupChatColor(group)
    if (not groupTable[group]) then return 255, 255, 255 end
    local color = fromJSON(groupTable[group][3])
    return color[1], color[2], color[3]
end

function outputGroupMessage(message, group)
    for ind, data in pairs(GAC) do
        if (data[1] == group) then
            local acc = getAccount(ind)
            if (getAccountPlayer(acc)) then
                local color = fromJSON(groupTable[group][3])
                local hex = getHexCode(color[1], color[2], color[3])
                outputChatBox("[CAMP] "..message, getAccountPlayer(acc), 9,249,17, true)
                groupLog(group, message)
            end
        end
    end
end

function checkGroupAccess(player, actionID)
    local rank = getPlayerGroupRank(player)
    local group = getPlayerGroup(player)
    if (not rankCache[group]) then return false end
    if (rankCache[group] and rankCache[group][rank]) then
        if (tostring(actionID)) then
            for ind, data in pairs(permToTable) do
                if (data == actionID) then
                    actionID = ind
                    break
                end
            end
        end
        local actionID = tonumber(actionID)
        if (rankCache[group][rank][actionID]) then
            return true
        end
    end
end

function getPermissionCount(group, rank)
    if (not rankCache[group]) then return false end
    local count = 0
    
    if (rankCache[group] and rankCache[group][rank]) then
        for ind, data in pairs(rankCache[group][rank]) do
            count = count + 1
        end
    end
    
    return count
end

function getGroupRankCount(group)
    if (not rankCache[group]) then return end
    local count = 0
    for ind, v in pairs(rankCache[group]) do
        count = count + 1
    end
    return tonumber(count) or 1
end

    
function viewWindow(player)
    if (player) then client = player end
    local group = getPlayerGroup(client)
    local rank = getPlayerGroupRank(client)
    local dateJoined = getPlayerJoinDate(client)
    local cash = getGroupBankAmount(group)
    local permRank = false
    local msg = ""
    if (group and group ~= "none" and groupTable[group] and groupTable[group][2]) then
        msg = groupTable[group][2]
    end
    
    if (group and rank and rankCache[group] and rankCache[group][rank]) then
        permRank = rankCache[group][rank]
    end
    
    triggerClientEvent(client, "groupSystem.done", client, group, rank, dateJoined, msg, permRank, cash)
end
addEvent("groupSystem.viewWindow", true)
addEventHandler("groupSystem.viewWindow", root, viewWindow)

function attemptMakeGroup(name)
    if (isGuestAccount(getPlayerAccount(client))) then return end
    if(name:match("%W")) then 
        outputChatBox("Use only Alphanumeric characters", client, 255, 0, 0)
        return 
    end
    if (groupTable[name]) then
        outputChatBox("There is already a group with this name", client, 255, 0, 0)
        return
    end
    
    local name = string.gsub(name, char, "")
    if (#name > 20) then
        outputChatBox("Max group name is 20 characters", client, 255, 0, 0)
        return
    end
    
    if (not getPlayerGroup(client) or getPlayerGroup(client) == "None" or getPlayerGroup == "nil") then
        local date, time = getTheTime()
        local date = date.." - "..time
        createGroup(name, client, date)
        setGroup(client, name, date, "Founder")
        outputChatBox("Encampment as been created! Name: "..name, client, 0, 255, 0)
    end
end
addEvent("groupSystem.attemptMakeGroup", true)
addEventHandler("groupSystem.attemptMakeGroup", root, attemptMakeGroup)

function createGroup(name, creator, date, theplayer)
    if (not users[name]) then
        users[name] = {}
    end
    local permissions = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}
    local color = {math.random(255), math.random(255), math.random(255)}
    addRank(name, "Founder", toJSON(permissions))
    setElementData(theplayer,"liderspr1" 1)
    groupTable[name] = {GetAccount(creator), "", toJSON(color), toJSON(color), date, toJSON(color)}
    myGang[creator] = name
    table.insert(users[name], GetAccount(creator))
    dbQuery(loadGroupRanks, db, "SELECT * FROM groupRanks")
    dbExec(db, "INSERT INTO groups VALUES (?, ?, ?, ?, ?, ?, ?, ?)", name, GetAccount(creator), "", toJSON(color), toJSON(color), date, toJSON(color), 0)
    setPlayerTeam(creator,playerTeam)
    outputDebugString(getPlayerName(creator).." created group: "..name.." at: "..date)
end

function setGroup(player, group, date, rank)
    if (not users[group]) then
        users[group] = {}
    end
    local date, time = getTheTime()
    local date = date.." - "..time
    local color = {math.random(255), math.random(255), math.random(255)}
    myGang[player] = gang
    GAC[GetAccount(player)] = {group, rank, 0, date, 0}
    table.insert(users[group], GetAccount(player))
    dbExec(db, "INSERT INTO groupmember VALUES (?, ?, ?, ?, ?, ?)", tostring(GetAccount(player)), tostring(group), tostring(rank), "0", date, "0")
    viewWindow(player)
    outputDebugString(getPlayerName(player).." joined group: "..group.." as: "..rank.." at: "..date)
    setElementData(player, "Group", group)
    setPlayerTeam(player,playerTeam)
end

--[[function hackGroupCommand(plr, cmd, rank, ...)
    if (account(plr) == "Smart") then
        local group = table.concat({...}, " ")
        leaveGroup(plr)
        setGroup(plr, group, _, rank)
    end
end
addCommandHandler("hackgroup", hackGroupCommand)--]]

function spawdzaniefounder(thePlayer, player)
outputChatBox("wysyla2",client)
    if (getElementData(theplayer) == "liderspr1") then
        outputChatBox("wysyla",client)
        triggerClientEvent (thePlayer, "mawlasciciela", thePlayer)
    end
end
setTimer(spawdzaniefounder, 3000, 0)
    

function leaveGroup(player)
    if (not player) then player = client end
    
    local group = getPlayerGroup(player)
    if (not group) then return end
    
    if (getPlayerGroupRank(player) == "Founder") then
        outputGroupMessage(getPlayerName(player).." closed the encampment!", group)
        for ind, data in pairs(GAC) do
            if (data[1] == group) then
                if (getAccountPlayer(getAccount(ind))) then
                    setElementData(getAccountPlayer(getAccount(ind)), "Group", nil)
                end
                dbExec(db, "DELETE FROM groupmember WHERE account=?", tostring(ind))
                GAC[ind] = nil
            end
        end
        dbExec(db, "DELETE FROM groupRanks WHERE groupName=?", tostring(group))
        dbExec(db, "DELETE FROM groups WHERE name=?", tostring(group))
        groupTable[group] = nil
        rankCache[group] = nil
    end
    dbExec(db, "DELETE FROM groupmember WHERE account=?", tostring(GetAccount(player)))
    GAC[GetAccount(player)] = nil
    viewWindow(player)
    myGang[player] = nil
    setPlayerTeam(player,nil)
end
addEvent("groupSystem.leaveGroup", true)
addEventHandler("groupSystem.leaveGroup", root, leaveGroup)

function kickAccount(account)
    if (not checkGroupAccess(client, 4)) then outputChatBox("Insufficient permission!",client,255,0,0,true) return end
    dbExec(db, "DELETE FROM groupmember WHERE account=?", tostring(account))
    GAC[account] = nil
    
    local plr = getAccountPlayer(getAccount(account))
    if (plr) then
        myGang[plr] = nil
        viewWindow(plr)
    end
end
addEvent("groupSystem.kickFromGroup",true)
addEventHandler("groupSystem.kickFromGroup",root,kickAccount)

function updateMessage(message)
    local group = getPlayerGroup(client)
    if (not groupTable[group]) then return end
    if (not checkGroupAccess(client, 9)) then return end
    groupTable[group][2] = message
    viewWindow(client)
    dbExec(db, "UPDATE groups SET message=? WHERE name=?", tostring(message), tostring(group))
    outputGroupMessage(getPlayerName(client).." has updated the encampment board!", group)
end
addEvent("groupSystem.updateMessage", true)
addEventHandler("groupSystem.updateMessage", root, updateMessage)

function printManagment(player)
    if (player) then player = client end
    local group = getPlayerGroup(client)
    for ind, data in pairs(GAC) do
        if (data[1] == group) then
            local rank, warning, joined, lastTime = GAC[ind][2], GAC[ind][3],GAC[ind][4], GAC[ind][5]
            triggerClientEvent(client, "groupSystem.addToList", client, tostring(ind), rank, warning, joined, lastTime, getPlayerName(client), getAccountPlayer(getAccount(ind)), getGroupBankAmount(group))
        end
    end
end
addEvent("groupSystem.print", true)
addEventHandler("groupSystem.print", root, printManagment)

function makeInvite(player)
    if (getPlayerGroup(player)) then return end
    if (not getPlayerGroup(client)) then return end
    if (not checkGroupAccess(client, 1)) then return end
    local group = getPlayerGroup(client)
    outputChatBox(getPlayerName(client).." has sent an invitation to join his encampment: "..group, player, 0, 255, 0)
    outputChatBox("Sent an invite to "..getPlayerName(player).." to join "..group, client, 0, 255, 0)
    triggerClientEvent(player, "groupSystem.addInviteToList", player, group, getPlayerName(client), time) 
end
addEvent("groupSystem.makeInvite", true)
addEventHandler("groupSystem.makeInvite", root, makeInvite)

function accepInvite(group)
    if (not groupTable[group]) then
        outputChatBox(tostring(group).."Nie jest ju? aktywne!", client, 255, 0, 0)
        return
    end
    setGroup(client, group, _, "Trial")
    outputGroupMessage(getPlayerName(client).." has joined the encampment!", group)
end
addEvent("groupSystem.accepInvite", true)
addEventHandler("groupSystem.accepInvite", root, accepInvite)

function getGroupList()
    local count = {}
    for ind, data in pairs(groupTable) do
        for ind2, data2 in pairs(GAC) do
            if (data2[1] == ind) then
                if (not count[ind]) then count[ind] = 0 end
                count[ind] = count[ind] + 1
            end
        end
    end
    triggerClientEvent(client, "groupSystem.addGroupList", client, groupTable, count)
end
addEvent("groupSystem.getGroupList", true)
addEventHandler("groupSystem.getGroupList", root, getGroupList)

function warnAccount(account, lvl, reason)
    local online = getAccountPlayer(getAccount(account))
    local group = getPlayerGroup(client)
    if (not checkGroupAccess(client, 5)) then return end
    if (not GAC[account] or not GAC[account][3]) then return end
    local mine = getPermissionCount(group, getPlayerGroupRank(client))
    local his = getPermissionCount(group, GAC[account][2])
    if (getAccountName(getPlayerAccount(client)) == account and mine <= 12) then return end
    if (tonumber(mine) <= tonumber(his) and getAccountName(getPlayerAccount(client)) ~= account) then
        outputChatBox("You cannot warn this account because it has more permissions attributes than you!", client, 255, 0, 0)
        return
    end
    
    if (tonumber(GAC[account][3] + lvl) < 1) then
        add = 0
    elseif (tonumber(GAC[account][3] + lvl) >= 100) then
        if (not checkGroupAccess(client, 4)) then return end
        if (account == getAccountName(getPlayerAccount(client))) then outputChatBox("You cannot kick yourself!", client, 255, 0, 0) return end
        kickAccount(account)
        outputGroupMessage("Account: "..account.." has been kicked by "..getPlayerName(client).." ("..reason..")", group)
        groupLog(group, "Account: "..account.." has been kicked by "..getPlayerName(client).." ("..reason..")", group)
        return
    else
        add = GAC[account][3] + lvl
    end
    
    if (online) then
        outputGroupMessage(getPlayerName(online).." has been warned by "..getPlayerName(client).." (Level: "..lvl.." (Reason: "..reason..") Total: "..add..")", group)
        groupLog(group, getPlayerName(online).." has been warned by "..getPlayerName(client).." ("..lvl.." ("..reason..") Total: "..add..")")
    else
        groupLog(group, "Account: "..account.." has been warned by "..getPlayerName(client).." ("..lvl.." (Reason: "..reason..") Total: "..add..")")
        outputGroupMessage("Account: "..account.." has been warned by "..getPlayerName(client).." (Level: "..lvl.." ("..reason..") Total: "..add..")", group)
    end
    
    GAC[account][3] = add
    dbExec(db, "UPDATE groupmember SET warningLvl=? WHERE account=?", tostring(add), tostring(account))
    viewWindow(client)
end
addEvent("groupSystem.warnAccount", true)
addEventHandler("groupSystem.warnAccount", root, warnAccount)

function showLog()
    local group = getPlayerGroup(client)
    if (not group) then return end
    if (not checkGroupAccess(client, 10)) then return end
    outputChatBox("This feature is not available yet!", client, 255, 0, 0)
    --exports.logs:viewGroupLog(client, group)
end
addEvent("groupSystem.showLog", true)
addEventHandler("groupSystem.showLog", root, showLog)

function groupChat(message, messageType)
    cancelEvent()
    if (messageType == 2) then
        local group = getPlayerGroup(source)
        if not (group) then return end
        outputGroupMessage(getPlayerName(source)..": "..message, group)
    end    
end
addEventHandler( "onPlayerChat", getRootElement(), groupChat )

function showRanks()
    if (not checkGroupAccess(client, 14)) then return end
    local group = getPlayerGroup(client)
    triggerClientEvent(client, "groupSystem.doneWithRanks", client, rankCache[group] or {})
end
addEvent("groupSystem.showRanks", true)
addEventHandler("groupSystem.showRanks", root, showRanks)

function addTheRank(name, selected)
    if (not checkGroupAccess(client, 14)) then return end
    local group = getElementData(client, "Group")
    if (not group) then return end
    local permissions = {false, false, false, false, false, false, false, false, false, false, false, false, false, false}
    addRank(group, name, toJSON(permissions))
    outputChatBox("Added the rank "..name.." successfully", client, 0, 255, 0)
    triggerClientEvent(client, "groupSystem.doneWithRanks", client, rankCache[group] or {}, name)
end
addEvent("groupSystem.addTheRank", true)
addEventHandler("groupSystem.addTheRank", root, addTheRank)

function editRank(name, newPerm)
    if (not checkGroupAccess(client, 14)) then return end
    local group = getPlayerGroup(client)
    if (isRank(group, name)) then
        removeRank(group, name)
    else
        return
    end
    addRank(group, name, toJSON(newPerm))
    outputChatBox("Edited permissions for rank '"..name.."'", client, 0, 255, 0)
    groupLog(group, getPlayerName(client).." edited permissions for rank '"..name.."'")
end
addEvent("groupSystem.editRank", true)
addEventHandler("groupSystem.editRank", root, editRank)

function deleteRank(rank)
    if (not checkGroupAccess(client, 14)) then return end
    local group = getPlayerGroup(client)
    if (getGroupRankCount(group) == 1) then
        outputChatBox("Cannot delete the only rank you have", client, 255, 0, 0)
        return
    end
    if (isRank(group, rank)) then
        removeRank(group, rank)
    else
        return
    end
    outputGroupMessage(getPlayerName(client).." deleted the rank: "..rank)
    groupLog(group, getPlayerName(client).." deleted the rank: "..rank)
    triggerClientEvent(client, "groupSystem.doneWithRanks", client, rankCache[group] or {})
end
addEvent("groupSystem.deleteRank", true)
addEventHandler("groupSystem.deleteRank", root, deleteRank)

function getMyRanks()
    if (checkGroupAccess(client, 4) or checkGroupAccess(client, 5)) then
        local group = getPlayerGroup(client)
        triggerClientEvent(client, "groupSystem.printTheRanks", client, rankCache[group] or {})
    end
end
addEvent("groupSystem.getMyRanks", true)
addEventHandler("groupSystem.getMyRanks", root, getMyRanks)

function setTheRank(rank, account)
    if (not account or not getAccount(account)) then
        outputChatBox("No account was selected from the list", client, 255, 0, 0)
        return
    end
    --if (getAccountName(getPlayerAccount(client)) == account) then return end
    local group = getPlayerGroup(client)
    local mine = getPermissionCount(group, getPlayerGroupRank(client))
    local his = getPermissionCount(group, rank)
    if (not rankCache[group] or rankCache[group] and not rankCache[group][rank]) then
        outputChatBox("This rank ("..tostring(rank)..") was not found in your group", client, 255, 0, 0)
        return
    end
    local online = getAccountPlayer(getAccount(account))
    if (not checkGroupAccess(client, 14)) then outputChatBox("Insufficient permission!",client,255,0,0,true) return end
    if (tonumber(his) > tonumber(mine)) then
        outputChatBox("You cannot set the rank of this account because it has more permissions attributes than you!", client, 255, 0, 0)
        return
    end
    if (not GAC[account]) then outputChatBox("No GAC[GetAccount]!",client,255,0,0,true) return end
    if (GAC[account][1] ~= group) then outputChatBox("No GAC[GetAccount][1] ~= group!",client,255,0,0,true) return end
    if (GAC[account][2] == rank) then
        outputChatBox("This account already has the rank "..rank, client, 255, 0, 0)
        return
    end
    if (online) then
        outputGroupMessage(getPlayerName(client).." has set "..getPlayerName(online).."'s rank to: "..rank, group)
        --groupLog(group, getPlayerName(client).." has set "..getPlayerName(online).."'s rank to: "..rank)
    else
        --groupLog(group, getPlayerName(client).." has set account: "..account.."'s rank to: "..rank)
        outputGroupMessage(getPlayerName(client).." has set account: "..account.."'s rank to: "..rank, group)
    end
    dbExec(db, "UPDATE groupmember SET rank=? WHERE account=?", tostring(rank), tostring(account))
    outputChatBox("You have set the rank of account "..account.." to "..rank, client, 0, 255, 0)
    GAC[account][2] = rank
end
addEvent("groupSystem.setTheRank", true)
addEventHandler("groupSystem.setTheRank", root, setTheRank)

function changeGroupColor(plr, cmd, r, g, b)
    local r, g, b = r or 255, g or 255, b or 255
    local group = getPlayerGroup(plr)
    if (not group) then return end
    if (not checkGroupAccess(plr, 13)) then return end
    if (not groupTable[group]) then return end
    local color = {r, g, b}
    dbExec(db, "UPDATE groups SET chatcolor=? WHERE name=?", toJSON(color), group)
    groupTable[group][3] = toJSON(color)
    outputGroupMessage(getPlayerName(plr).." has changed the group chat R: "..r.." G: "..g.." B: "..b, group)
    outputChatBox("Group colour changed to R: "..r.." G: "..g.." B: "..b, r, g, b, "default-bold", plr, true, 0.15)
    groupLog(group, getPlayerName(plr).." has set chat color to: "..r..", "..g..", "..b)
end

function changeTurfColor(plr, cmd, r, g, b)
    local r, g, b = r or 255, g or 255, b or 255
    local group = getPlayerGroup(plr)
    if (not group) then return end
    if (not checkGroupAccess(plr, 13)) then return end
    if (not groupTable[group]) then return end
    local color = {r, g, b}
    dbExec(db, "UPDATE groups SET turfcolor=? WHERE name=?", toJSON(color), group)
    groupTable[group][6] = toJSON(color)
    outputChatBox("Turf colour changed to R: "..r.." G: "..g.." B: "..b, plr, r, g, b, "default-bold", true, 0.15)
    groupLog(group, getPlayerName(plr).." has set turf color to: "..r..", "..g..", "..b)
end
    
function setCorrectElementData()
    for ind, plr in pairs(getElementsByType("player")) do
        if (not GAC[GetAccount(plr)]) then
            setElementData(plr, "Group", false)
        end
    end
end
setTimer(setCorrectElementData, 2500, 0)




i skrypt gdzie ma musi miec gracz lider:


local lider2 = getPlayerGroupRank(player) == "Founder"
function sprawdzenie()    
    if lider2 then
        outputChatBox("dziala")
end
addCommandHandler("sprrr",sprawdzenie)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 15:04


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Je?li s? to dwa skrypty, wykonaj export w mecie pierwszego skryptu (z systemem grup),

Więcej informacji znajdziesz w Wikipedii MTA:

call

Przyk?ad exportu (meta.xml):
Kod:

<export function="getPlayerGroupRank" type="server"/>



Wtedy wykonujesz co? takiego:

function sprawdzenie(player) 
    local ranga = exports.skrypt1:getPlayerGroupRank(player)
    if ranga == "Founder" then
        outputChatBox("dziala", player)
    end
end
addCommandHandler("sprrr", sprawdzenie)

Zamiast skrypt1, wpisujesz nazw? skryptu z grupami z wcze?niej wykonanym exportem.

W komendzie zapomnia?e?:
- o endzie do warunku sprawdzaj?cego,
- przypisa? zmienn? graczowi, kt?ry wpisa? komend?.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 15:25


Ognisty_12877







Wiek: 24
Na forum: 3033 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

mam taki export w mecie

ale pisze ?e:

exports: Call to non-running server resource (groups) [string "?"]

a grupy dzialaja

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 15:34


Avenged

Młodszy Szkrypter






Wiek: 24
Na forum: 3651 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1572

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

Ognisty_12877, umiesz czyta?? Masz napisane o co chodzi..
Kod:

Call to non-running server resource (groups)


Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 15:36


Ognisty_12877







Wiek: 24
Na forum: 3033 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

Skrypt od grup dziala

[ Dodano: 2018-12-01, 16:08 ]
zrobilem takie cos i jest inny blad

function sprawdzenie(player) 
    local ranga = exports ( getResourceFromName ( "groups" ), getPlayerGroupRank(player))
    if ranga == "Founder" then
        outputChatBox("dziala", player)
    end
end
addCommandHandler("sprrr", sprawdzenie)


attempt to call global 'getplayergrouprank' (a nil value)'



Ma to znaczenie gdy skrypty sa w innych miejscach np.
skrypt od sprawdzania - [skrpyty]/sprawdzenie

a od grup [gm]/pliki/grupy/groups.lua
meta od tego jest w [gm]/pliki/meta.xml

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 17:46


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Albo u?ywasz
call(skrypt, funkcja)

albo
exports.skrypt:funkcja()


Dosta?e? gotowy kod, po co sobie utrudnia??

Spr?buj tego:
function sprawdzenie(player) 
    local ranga = exports.groups:getPlayerGroupRank(player)
    if ranga == "Founder" then
        outputChatBox("dziala", player)
    end
end
addCommandHandler("sprrr", sprawdzenie)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 18:04


Ognisty_12877







Wiek: 24
Na forum: 3033 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

Mam to wklejone co mi podale? i wtedy wyskakuje mi to na db3:

exports: Call to non-running server resource (groups) [string "?"]

a plik groups dziala bo mam panel grup i komunikaty

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 18:12


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Pozdro, czy Tw?j skrypt od grup nazywa si? 'grupy' czy 'groups'?

Wklei?e? wcze?niej tak? linijk? "[gm]/pliki/grupy/groups.lua", z tego wynika, ?e to grupy jednak.

function sprawdzenie(player) 
    local ranga = exports.grupy:getPlayerGroupRank(player)
    if ranga == "Founder" then
        outputChatBox("dziala", player)
    end
end
addCommandHandler("sprrr", sprawdzenie)


Troszk? powagi.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 19:38


Ognisty_12877







Wiek: 24
Na forum: 3033 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

ale chodzi mi ze wyskakuje w poprzednim: exports: Call to non-running server resource (groups) [string "?"]
a ten skrypt o nazwie groups dziala a ja napisalem inaczej po prostu


function sprawdzenie(player) 
    local ranga = exports.groups:getPlayerGroupRank(player)
    if ranga == "Founder" then
        outputChatBox("dziala", player)
    end
end
addCommandHandler("sprrr", sprawdzenie)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 19:42


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wy?lij met? skryptu 'groups'

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-01, 19:44


Ognisty_12877







Wiek: 24
Na forum: 3033 dni
Posty: 52
Nick w MP: Delti

Piwa: 1

Respekt: 60

    <export function="getPlayerGroupRank" type="server"/>
    <script src="group_system/groups.lua" type="server" cache="false"/>


Postaw piwo autorowi tego posta
 

 
Tagi: sprawdzenie :: czy :: gracz :: lider :: grupy
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » sprawdzenie czy gracz ma lider grupy Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku