Jump to content

Gang System [ HELP ] [Complex]


Recommended Posts

I own this gang script, more of a problem, it does not work, and has all these functions should work, can help me on what is wrong? Missing the "server" I have only the "client" could help me on how to make "server"?

SCRIPT:

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
 
 
local resourceRoot = getResourceRootElement(getThisResource())
Levels = {
    ['1'] = 'Convidado',
    ['2'] = 'Membro',
    ['3'] = 'Comandante',
    ['4'] = 'Sub-Lider',
    ['5'] = 'Lider'
}
 
permissions = {
    ['Convidado'] = {},
    ['Membro'] = {},
    ['Comandante'] = {},
    ['Sub-Lider'] = {},
    ['Lider'] = {}
}
 
xLevels = {
    ['Convidado'] = '1',
    ['Membro'] = '2',
    ['Comandante'] = '3',
    ['Sub-Lider'] = '4',
    ['Lider'] = '5'
}
 
local gangs = {}
local members = {}
 
local rootNode = xmlLoadFile("gangs.xml")
local children = xmlNodeGetChildren(rootNode)
if children == false then
    return
end
 
for _,node in pairs(children) do
    local attributes = xmlNodeGetAttributes(node)
    if attributes.name and attributes.colorR then
        local name = attributes.name
        local colorRed = attributes.colorR
        local colgangreen = attributes.colgang
        local colorBlue = attributes.colorB
        local gangTag = attributes.tag
        local sublider = attributes.sublider
 
        gangs[name] = {}
        gangs[name]['name'] = tostring(name)
        gangs[name]['tag'] = tostring(gangTag)
        gangs[name]['subLider'] = tostring(subLider)
 
        gangs[name]['color'] = {}
        gangs[name]['color']['r'] = tostring(colorRed)
        gangs[name]['color']['g'] = tostring(colgangreen)
        gangs[name]['color']['b'] = tostring(colorBlue)
 
        --createTeam(name, tonumber(col[1]), tonumber(col[2]), tonumber(col[3]))
    end
end
 
local rootNodem = xmlLoadFile("members.xml")
local childrenm = xmlNodeGetChildren(rootNodem)
if childrenm == false then
    return
end
for _m,nodem in pairs(childrenm) do
    local attributesm = xmlNodeGetAttributes(nodem)
    if attributesm.gangName and attributesm.accName and attributesm.level then
        local accName = attributesm.accName
        local gangName = attributesm.gangName
        local accLevel = attributesm.level
 
        members[accName] = {}
 
        members[accName]['gangName'] = gangName
        members[accName]['level'] = accLevel
        members[accName]['accName'] = accName
    end
end
 
function onStart()
    call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Level",5,5,0.10)
end
addEventHandler("onResourceStart",resourceRoot,onStart)
 
 
function getPlayerFromID(id)
return call(getResourceFromName("gameid"), "getPlayerFromID", tonumber(id))
end
 
function getPlayerID(player)
return  getElementData(player,"id")
end
 
Prices = {
tag = 50000,
cor = 50000,
criar = 100000,
}
 
function gang (thePlayer,commandName,mode,playerid,...)
            if mode == "convidar" then
            if getPlayerTeam(thePlayer) then               
                if playerid and getPlayerFromID(playerid) ~= thePlayer then
                    CONVITE = getElementData(getPlayerFromID(playerid),"CONVITE")
                    if CONVITE == false then
                        outputChatBox("#43CD80[GANG] #ffffffConvite Enviado.",thePlayer, 255, 255, 255, true)
                        outputChatBox("#43CD80[GANG] #ffffffVocê foi convidado a entrar na gang "..getTeamName(getPlayerTeam(thePlayer)).."",getPlayerFromID(playerid),255,255,255,true)
                        outputChatBox("#43CD80[GANG] #00ff00Use /gang aceitar ou #ff0000/gang recusar ",getPlayerFromID(playerid),255,255,255,true)
                        setElementData(getPlayerFromID(playerid),"CONVITE",true)
                        setElementData(getPlayerFromID(playerid),"GANGCONVITE",getPlayerTeam(thePlayer))
                        setElementData(getPlayerFromID(playerid),"PLAYERSENDCONVITE",thePlayer)
                        Timer = setTimer(function()
                            setElementData(thePlayer,"CONVITE",false)
                            removeElementData(getPlayerFromID(playerid),"GANGCONVITE")
                            removeElementData(getPlayerFromID(playerid),"PLAYERSENDCONVITE")
                            outputChatBox("#43CD80[GANG] #ffffffSeu Convite Expirou.",getPlayerFromID(playerid),255,255,255, true)
                            end,120000,1)
                    elseif CONVITE == true then
                        outputChatBox("#43CD80[GANG] #ffffffEsse jogador já recebeu um convite para juntar-se a Gang",thePlayer,255,255,255,true)
                    end
                    else
                    outputChatBox('#43CD80[GANG] #ffffffid não encontrado!',thePlayer,255,255,255,true)
                end            
            else
            outputChatBox('#43CD80[GANG] #ffffffVocê não possui uma Gang!',thePlayer,255,255,255,true)
            end
 
         elseif mode == "aceitar" then
            gang = getElementData(thePlayer,"GANGCONVITE")
            if gang then
                outputChatBox("#43CD80[GANG] #ffffffBem vindo a Gang "..getTeamName(gang),thePlayer,255,255,255,true)
                setPlayerTeam(thePlayer,gang)
                setElementData(thePlayer,"CONVITE",false)
                setElementData(thePlayer,"Level","Convidado")
                r,g,b = getTeamColor(gang)
                setPlayerNametagColor ( thePlayer, r, g, b )
                removeElementData(thePlayer,"GANGCONVITE")
                killTimer(Timer)
                setPlayerGang(thePlayer,getTeamName(gang),"1")
                for i,v in ipairs(getPlayersInTeam ( gang )) do
                    outputChatBox("#43CD80[GANG] #ffffff"..getPlayerName(thePlayer).." entrou em sua Gang: ("..Levels['1']..")",v,255,255,255,true)
                end
            else
                outputChatBox("#43CD80[GANG] #ffffffVocê não foi convidado para nenhuma Gang.",thePlayer,255,255,255,true)
            end
        elseif mode == "recusar" then
            gang = getElementData(thePlayer,"GANGCONVITE")
            if gang then
                playersend = getElementData(thePlayer,"PLAYERSENDCONVITE")
                outputChatBox("#43CD80[GANG] #ffffffVocê recusou o convite da Gang "..getTeamName(gang),thePlayer,255,255,255,true)
                outputChatBox("#43CD80[GANG] #ffffff"..getPlayerName(thePlayer).." recusou o seu convite para juntar-se a Gang",playersend,255,255,255,true)
                setElementData(thePlayer,"CONVITE",false)
                removeElementData(thePlayer,"GANGCONVITE")
                removeElementData(thePlayer,"PLAYERSENDCONVITE")
            else
                outputChatBox("#43CD80[GANG] #ffffffVocê não foi convidado para nenhuma Gang.",thePlayer,255,255,255,true)
            end
 
        elseif mode == "level" then
            if getPlayerTeam(thePlayer) then
            if tonumber(xLevels[getAccountLevel(thePlayer)]) >= 3 then
                if playerid then
                    level = ...
                    if level then
                    if getPlayerTeam(thePlayer) == getPlayerTeam(getPlayerFromID(playerid)) then
                    setPlayerLevel(thePlayer,getPlayerFromID(playerid),level)
                    else
                    outputChatBox("#43CD80[GANG] #ffffffEsse Jogador Pertence a Outra Gang.",thePlayer,255,255,255,true)
                    end
                    end
                end
            else
            outputChatBox("#43CD80[GANG] #ffffffSomente o Lider,Sub-Lider ou Comandante pode setar o level.",thePlayer,255,255,255,true)
            end
            else
            outputChatBox('#43CD80[GANG] #ffffffVocê não possui uma Gang!',thePlayer,255,255,255,true)
            end
 
        elseif mode == "tag" then
        local account = getPlayerAccount(thePlayer)
        local playerCash = tonumber(getAccountData(account,"MONEY"))
            if getPlayerTeam(thePlayer) then
                if tonumber(xLevels[getAccountLevel(thePlayer)]) >= 3 then
                if playerCash >= tonumber(Prices.tag) then
                    if playerid then
                        tag = playerid
                        if tag:len() <= 6 then
                            setgangTag(thePlayer,getPlayerTeam(thePlayer),tag)
                            for i,v in ipairs(getPlayersInTeam ( getPlayerTeam(thePlayer) )) do
                                outputChatBox("#43CD80[GANG] #ffffffTag da gang setada para ["..tag.."] por "..getPlayerName(thePlayer),v,255,255,255,true)
                                setElementData(v,"gang.tag",""..tag.."")
                            end
                        else
                            outputChatBox("#43CD80[GANG] #ffffff O Máximo permitido de letras são 4!",thePlayer,255,255,255,true)
                            return
                        end
                    else
                        outputChatBox("#43CD80[GANG] #ffffffUso correto. /gang tag [tag]",thePlayer,255,255,255,true)
                    end
                else
                        outputChatBox ("#43CD80[GANG] #ffffffVocê não possuí dinheiro suficiente. #1e90ff($" .. convertNumber(tonumber(Prices.tag)) .. ")", thePlayer, 255, 255, 255, true)
                    end
                else
                    outputChatBox("#43CD80[GANG] #ffffffSomente o Lider,Sub-Lider ou Comandante pode alterar a tag da Gang.",thePlayer,255,255,255,true)
                end
            else
                outputChatBox('#43CD80[GANG] #ffffffVocê não possui uma Gang!',thePlayer,255,255,255,true)setgangColor(gang,r,g,b)
            end
 
       
        elseif mode == "cor" then
        local account = getPlayerAccount(thePlayer)
        local playerCash = tonumber(getAccountData(account,"MONEY"))
            if getPlayerTeam(thePlayer) then
                if playerCash >= tonumber(Prices.cor) then
                    if tonumber(xLevels[getAccountLevel(thePlayer)]) >= 3 then
                        if playerid then
                            cor1 = playerid
                            color = { ... }
                            if color[1] and color[2] then
                                setgangColor(getPlayerTeam(thePlayer),cor1,color[1],color[2])
                                setAccountData(account,"cash",playerCash - tonumber(Prices.cor))
                                scoreboardRefresh(thePlayer)
                                for i,v in ipairs(getPlayersInTeam ( getPlayerTeam(thePlayer) )) do
                                outputChatBox("[GANG] Cor da Gang setada por "..getPlayerName(thePlayer),v,cor1,color[1],color[2],true)
                                end
                            end
                                                     
                            else
                            outputChatBox("#43CD80[GANG] #ffffffUso correto. /gang cor [r] [g] [b] | Exemplo /gang cor 255 0 0 = #ff0000Vermelho.",thePlayer,255,255,255,true)
                            end
                       
                        else
                            outputChatBox("#43CD80[GANG] #ffffffSomente o Lider,Sub-Lider ou Comandante pode alterar a cor da Gang.",thePlayer,255,255,255,true)
                        end
                    else
                        outputChatBox("#43CD80[GANG] #ffffffÉ necessario #1e90ff($" .. convertNumber(tonumber(Prices.cor)) .. ") para mudar a cor da Gang.",thePlayer,255,255,255,true)
                    end
               
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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