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: 2892 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 (debugInfothen _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.hourtime.minute)
    return datetime
end

MTAoutput outputChatBox
function outputChatBox(messageplayerrgbbool)
    if (isElement(message) and getElementType(message) == "player"then
        MTAoutput(playermessagergbbool)
    else
        MTAoutput(messageplayerrgbbool)
    end
end

function groupLog(groupmessage)
    if (loggingthen
        outputServerLog("GROUP: "..group.." - "..message)
    end
    --[[
    if (debugInfothen
        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(query0)
    if (the_tablethen
        for inddata 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 indvalue in pairs(JSONtable) do
                if (value and indthen
                    rankCache[data.groupName][data.name][ind] = true
                end
            end
        end
    end
end
dbQuery(loadGroupRanksdb"SELECT * FROM groupRanks")

function loadGroupStuff(query)
    local g_table dbPoll(query0)
    
    if (not g_tablethen return end
    
    for inddata in ipairs(g_table) do
        groupTable[data.name] = {data.leaderdata.messagedata.chatcolordata.notecolordata.datedata.turfcolordata.cashflow}
    end
end
dbQuery(loadGroupStuffdb"SELECT * FROM groups")

function loadClientGroup(query)
    local g_table dbPoll(query0)
    
    if (not g_tablethen return end
    
    for inddata 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 (playerthen
                setElementData(player"Group"data.groupName)
                myGang[player] = data.groupName
            end
            GAC[data.account] = {data.groupNamedata.rankdata.warningLvldata.joineddata.lastTime or 0}
        end
    end
end
dbQuery(loadClientGroupdb"SELECT * FROM groupmember")

function addRank(grouprankpermissionTable)
    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(loadGroupRanksdb"SELECT * FROM groupRanks")
end

function removeRank(grouprank)
    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(loadGroupRanksdb"SELECT * FROM groupRanks")
        return true
    end
end

function isRank(grouprank)
    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 datetime getTheTime()
        local date date.." - "..time
        GAC[GetAccount(source)][5] = date
    end
end
addEventHandler("onPlayerLogin"rootgroupMemberLogin)

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

function getGroupMembers(group)
    local temp = {}
    for inddata in pairs(users) do
        if (ind == groupthen
            table.insert(tempdata[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(rgb)
    if (and and bthen
        return string.format("#%.2X%.2X%.2X"rgb)
    end
end

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

function outputGroupMessage(messagegroup)
    for inddata in pairs(GAC) do
        if (data[1] == groupthen
            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] "..messagegetAccountPlayer(acc), 9,249,17true)
                groupLog(groupmessage)
            end
        end
    end
end

function checkGroupAccess(playeractionID)
    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 inddata in pairs(permToTable) do
                if (data == actionIDthen
                    actionID ind
                    break
                end
            end
        end
        local actionID tonumber(actionID)
        if (rankCache[group][rank][actionID]) then
            return true
        end
    end
end

function getPermissionCount(grouprank)
    if (not rankCache[group]) then return false end
    local count 0
    
    if (rankCache[group] and rankCache[group][rank]) then
        for inddata 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 indv in pairs(rankCache[group]) do
        count count 1
    end
    return tonumber(count) or 1
end

    
function viewWindow(player)
    if (playerthen 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"clientgrouprankdateJoinedmsgpermRankcash)
end
addEvent("groupSystem.viewWindow"true)
addEventHandler("groupSystem.viewWindow"rootviewWindow)

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

function createGroup(namecreatordatetheplayer)
    if (not users[name]) then
        users[name] = {}
    end
    local permissions = {1234567891011121314}
    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), datetoJSON(color)}
    myGang[creator] = name
    table.insert(users[name], GetAccount(creator))
    dbQuery(loadGroupRanksdb"SELECT * FROM groupRanks")
    dbExec(db"INSERT INTO groups VALUES (?, ?, ?, ?, ?, ?, ?, ?)"nameGetAccount(creator), ""toJSON(color), toJSON(color), datetoJSON(color), 0)
    setPlayerTeam(creator,playerTeam)
    outputDebugString(getPlayerName(creator).." created group: "..name.." at: "..date)
end

function setGroup(playergroupdaterank)
    if (not users[group]) then
        users[group] = {}
    end
    local datetime getTheTime()
    local date date.." - "..time
    local color = {math.random(255), math.random(255), math.random(255)}
    myGang[player] = gang
    GAC[GetAccount(player)] = {grouprank0date0}
    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(plrcmdrank, ...)
    if (account(plr) == "Smart"then
        local group table.concat({...}, " ")
        leaveGroup(plr)
        setGroup(plrgroup_rank)
    end
end
addCommandHandler("hackgroup"hackGroupCommand)--]]

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

function leaveGroup(player)
    if (not playerthen player client end
    
    local group getPlayerGroup(player)
    if (not groupthen return end
    
    if (getPlayerGroupRank(player) == "Founder"then
        outputGroupMessage(getPlayerName(player).." closed the encampment!"group)
        for inddata in pairs(GAC) do
            if (data[1] == groupthen
                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"rootleaveGroup)

function kickAccount(account)
    if (not checkGroupAccess(client4)) 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 (plrthen
        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(client9)) 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"rootupdateMessage)

function printManagment(player)
    if (playerthen player client end
    local group getPlayerGroup(client)
    for inddata in pairs(GAC) do
        if (data[1] == groupthen
            local rankwarningjoinedlastTime GAC[ind][2], GAC[ind][3],GAC[ind][4], GAC[ind][5]
            triggerClientEvent(client"groupSystem.addToList"clienttostring(ind), rankwarningjoinedlastTimegetPlayerName(client), getAccountPlayer(getAccount(ind)), getGroupBankAmount(group))
        end
    end
end
addEvent("groupSystem.print"true)
addEventHandler("groupSystem.print"rootprintManagment)

function makeInvite(player)
    if (getPlayerGroup(player)) then return end
    if (not getPlayerGroup(client)) then return end
    if (not checkGroupAccess(client1)) then return end
    local group getPlayerGroup(client)
    outputChatBox(getPlayerName(client).." has sent an invitation to join his encampment: "..groupplayer02550)
    outputChatBox("Sent an invite to "..getPlayerName(player).." to join "..groupclient02550)
    triggerClientEvent(player"groupSystem.addInviteToList"playergroupgetPlayerName(client), timeend
addEvent("groupSystem.makeInvite"true)
addEventHandler("groupSystem.makeInvite"rootmakeInvite)

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

function getGroupList()
    local count = {}
    for inddata in pairs(groupTable) do
        for ind2data2 in pairs(GAC) do
            if (data2[1] == indthen
                if (not count[ind]) then count[ind] = 0 end
                count[ind] = count[ind] + 1
            end
        end
    end
    triggerClientEvent(client"groupSystem.addGroupList"clientgroupTablecount)
end
addEvent("groupSystem.getGroupList"true)
addEventHandler("groupSystem.getGroupList"rootgetGroupList)

function warnAccount(accountlvlreason)
    local online getAccountPlayer(getAccount(account))
    local group getPlayerGroup(client)
    if (not checkGroupAccess(client5)) then return end
    if (not GAC[account] or not GAC[account][3]) then return end
    local mine getPermissionCount(groupgetPlayerGroupRank(client))
    local his getPermissionCount(groupGAC[account][2])
    if (getAccountName(getPlayerAccount(client)) == account and mine <= 12then return end
    if (tonumber(mine) <= tonumber(his) and getAccountName(getPlayerAccount(client)) ~= accountthen
        outputChatBox("You cannot warn this account because it has more permissions attributes than you!"client25500)
        return
    end
    
    if (tonumber(GAC[account][3] + lvl) < 1then
        add 0
    elseif (tonumber(GAC[account][3] + lvl) >= 100then
        if (not checkGroupAccess(client4)) then return end
        if (account == getAccountName(getPlayerAccount(client))) then outputChatBox("You cannot kick yourself!"client25500) 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 (onlinethen
        outputGroupMessage(getPlayerName(online).." has been warned by "..getPlayerName(client).." (Level: "..lvl.." (Reason: "..reason..") Total: "..add..")"group)
        groupLog(groupgetPlayerName(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"rootwarnAccount)

function showLog()
    local group getPlayerGroup(client)
    if (not groupthen return end
    if (not checkGroupAccess(client10)) then return end
    outputChatBox("This feature is not available yet!"client25500)
    --exports.logs:viewGroupLog(clientgroup)
end
addEvent("groupSystem.showLog"true)
addEventHandler("groupSystem.showLog"rootshowLog)

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

function showRanks()
    if (not checkGroupAccess(client14)) then return end
    local group getPlayerGroup(client)
    triggerClientEvent(client"groupSystem.doneWithRanks"clientrankCache[group] or {})
end
addEvent("groupSystem.showRanks"true)
addEventHandler("groupSystem.showRanks"rootshowRanks)

function addTheRank(nameselected)
    if (not checkGroupAccess(client14)) then return end
    local group getElementData(client"Group")
    if (not groupthen return end
    local permissions = {falsefalsefalsefalsefalsefalsefalsefalsefalsefalsefalsefalsefalsefalse}
    addRank(groupnametoJSON(permissions))
    outputChatBox("Added the rank "..name.." successfully"client02550)
    triggerClientEvent(client"groupSystem.doneWithRanks"clientrankCache[group] or {}, name)
end
addEvent("groupSystem.addTheRank"true)
addEventHandler("groupSystem.addTheRank"rootaddTheRank)

function editRank(namenewPerm)
    if (not checkGroupAccess(client14)) then return end
    local group getPlayerGroup(client)
    if (isRank(groupname)) then
        removeRank(groupname)
    else
        return
    end
    addRank(groupnametoJSON(newPerm))
    outputChatBox("Edited permissions for rank '"..name.."'"client02550)
    groupLog(groupgetPlayerName(client).." edited permissions for rank '"..name.."'")
end
addEvent("groupSystem.editRank"true)
addEventHandler("groupSystem.editRank"rooteditRank)

function deleteRank(rank)
    if (not checkGroupAccess(client14)) then return end
    local group getPlayerGroup(client)
    if (getGroupRankCount(group) == 1then
        outputChatBox("Cannot delete the only rank you have"client25500)
        return
    end
    if (isRank(grouprank)) then
        removeRank(grouprank)
    else
        return
    end
    outputGroupMessage(getPlayerName(client).." deleted the rank: "..rank)
    groupLog(groupgetPlayerName(client).." deleted the rank: "..rank)
    triggerClientEvent(client"groupSystem.doneWithRanks"clientrankCache[group] or {})
end
addEvent("groupSystem.deleteRank"true)
addEventHandler("groupSystem.deleteRank"rootdeleteRank)

function getMyRanks()
    if (checkGroupAccess(client4) or checkGroupAccess(client5)) then
        local group getPlayerGroup(client)
        triggerClientEvent(client"groupSystem.printTheRanks"clientrankCache[group] or {})
    end
end
addEvent("groupSystem.getMyRanks"true)
addEventHandler("groupSystem.getMyRanks"rootgetMyRanks)

function setTheRank(rankaccount)
    if (not account or not getAccount(account)) then
        outputChatBox("No account was selected from the list"client25500)
        return
    end
    --if (getAccountName(getPlayerAccount(client)) == accountthen return end
    local group getPlayerGroup(client)
    local mine getPermissionCount(groupgetPlayerGroupRank(client))
    local his getPermissionCount(grouprank)
    if (not rankCache[group] or rankCache[group] and not rankCache[group][rank]) then
        outputChatBox("This rank ("..tostring(rank)..") was not found in your group"client25500)
        return
    end
    local online getAccountPlayer(getAccount(account))
    if (not checkGroupAccess(client14)) 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!"client25500)
        return
    end
    if (not GAC[account]) then outputChatBox("No GAC[GetAccount]!",client,255,0,0,true) return end
    if (GAC[account][1] ~= groupthen outputChatBox("No GAC[GetAccount][1] ~= group!",client,255,0,0,true) return end
    if (GAC[account][2] == rankthen
        outputChatBox("This account already has the rank "..rankclient25500)
        return
    end
    if (onlinethen
        outputGroupMessage(getPlayerName(client).." has set "..getPlayerName(online).."'s rank to: "..rankgroup)
        --groupLog(groupgetPlayerName(client).." has set "..getPlayerName(online).."'s rank to: "..rank)
    else
        --groupLog(groupgetPlayerName(client).." has set account: "..account.."'s rank to: "..rank)
        outputGroupMessage(getPlayerName(client).." has set account: "..account.."'s rank to: "..rankgroup)
    end
    dbExec(db"UPDATE groupmember SET rank=? WHERE account=?"tostring(rank), tostring(account))
    outputChatBox("You have set the rank of account "..account.." to "..rankclient02550)
    GAC[account][2] = rank
end
addEvent("groupSystem.setTheRank"true)
addEventHandler("groupSystem.setTheRank"rootsetTheRank)

function changeGroupColor(plrcmdrgb)
    local rgor 255or 255or 255
    local group getPlayerGroup(plr)
    if (not groupthen return end
    if (not checkGroupAccess(plr13)) then return end
    if (not groupTable[group]) then return end
    local color = {rgb}
    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: "..bgroup)
    outputChatBox("Group colour changed to R: "..r.." G: "..g.." B: "..brgb"default-bold"plrtrue0.15)
    groupLog(groupgetPlayerName(plr).." has set chat color to: "..r..", "..g..", "..b)
end

function changeTurfColor(plrcmdrgb)
    local rgor 255or 255or 255
    local group getPlayerGroup(plr)
    if (not groupthen return end
    if (not checkGroupAccess(plr13)) then return end
    if (not groupTable[group]) then return end
    local color = {rgb}
    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: "..bplrrgb"default-bold"true0.15)
    groupLog(groupgetPlayerName(plr).." has set turf color to: "..r..", "..g..", "..b)
end
    
function setCorrectElementData()
    for indplr in pairs(getElementsByType("player")) do
        if (not GAC[GetAccount(plr)]) then
            setElementData(plr"Group"false)
        end
    end
end
setTimer(setCorrectElementData25000)




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: 4428 dni
Posty: 3410

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: 2892 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: 23
Na forum: 3510 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1570

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: 2892 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: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Albo u?ywasz
call(skryptfunkcja)

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: 2892 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: 4428 dni
Posty: 3410

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: 2892 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: 4428 dni
Posty: 3410

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: 2892 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