Autor Tema: Script pega pega para Xteam  (Leído 3042 veces)

jcouti

Venho liberar um pega pega feito por mim para servidores da xteam.

Facam bom proveito!

Código
--[[

    [SCRIPT] > Pega Pega;
    [E-MAIL] > [email protected];
    [PHONE]  > (21) 99620-7217;

]]--

BridgeFunctionAttach("OnReadScript","PegaPega_Read");
BridgeFunctionAttach("OnTimerThread","PegaPega_Timer");
BridgeFunctionAttach("OnCommandManager","PegaPega_Command");
BridgeFunctionAttach("OnCheckUserTarget","PegaPega_Target");
BridgeFunctionAttach("OnCharacterClose","PegaPega_Close");

Character = {};
Event = { GameMasters = {} };
Configuration = {};

PegaPega_Read = function()

    Configuration["EntryTime"]              = 60;   -- Tempo, em segundos, para entrar no evento.
    Configuration["RaceTime"]               = 10;   -- Tempo, em segundos, para repetir a mensagem de entrada acima.   
    Configuration["MessageTime"]            = 20;   -- Tempo, em segundos, para correr após iniciar o evento.   

    Configuration["MinPlayers"]             = 2;    -- Mínimo de participantes.
    Configuration["MaxPlayers"]             = 2;    -- Máximo de participantes.
    Configuration["MinLevel"]               = 6;    -- Level mínimo.

    Configuration["CommandCodeFunctions"]   = 60; -- Código do comando usado pelos GameMasters, havendo -> /command LIGAR, /command DESLIGAR, /command ENTRAR

    Configuration["CommandNameEntry"]       = "/pegapega";  -- Nome do comando cadastrado no CommandManager.txt
    Configuration["CommandCodeEntry"]       = 61;           -- Código do comando cadastrado no CommandManager.txt utilizado para que os players entrem.

    Configuration["Spawn"]                  = { Map = 0, X = 174, Y = 125 }; -- Local de nascimento do evento.

    Configuration["BlockItems"]             = {[0] = "sword", [1] = "sword", [2] = "helmo", [3] = "armadura", [4] = "calça", [5] = "luva",[7] = "asa", [8] = "8", [9] = "9"};

    Configuration["RewardMessage1"]          = "1 kriss, 1 kriss, 1 kriss, 1 kriss";
    Configuration["Reward1"]                 = [[
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
    ]]
    Configuration["RewardMessage2"]          = "1 kriss, 1 kriss, 1 kriss, 1 kriss";
    Configuration["Reward2"]                 = [[
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
    ]]
    Configuration["RewardMessage3"]          = "1 kriss, 1 kriss, 1 kriss, 1 kriss";
    Configuration["Reward3"]                 = [[
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
        ItemGiveEx(aIndex,0,0,0,0,0,0,0,0,0,0);
    ]]
   
    --[[
        ItemGiveEx(aIndex,7202,0,255,0,0,0,0,0,0,0,255,255,255,255,255,255,0);
        ItemGiveEx(aIndex,7202,0,255,0,0,0,0,0,0,0,255,255,255,255,255,255,0);
        ItemGiveEx(aIndex,7202,0,255,0,0,0,0,0,0,0,255,255,255,255,255,255,0);
    ]]


end

PegaPega_Timer = function()

    if Event.State ~= nil then

        if      Event.State == 1 then

            if Event.Time == 0 then
                if Event.CountTable(Character) >= Configuration["MinPlayers"] then
                    NoticeSendToAll(0, ". : [ PEGA PEGA ] : .");
                    NoticeSendToAll(0, "Tempo esgotado, evento iniciado");
                    Event.Time  = Configuration["RaceTime"];
                    Event.State = 2;
                else
                    NoticeSendToAll(0, ". : [ PEGA PEGA ] : .");
                    NoticeSendToAll(0, "Evento cancelado, mínimo de participantes não atingido");
                    Event.Close("não ter o mínimo de participantes");
                end
            else
                if Event.Time%Configuration["MessageTime"] == 0 then
                    NoticeSendToAll(0, ". : [ PEGA PEGA ] : .");
                    NoticeSendToAll(0, string.format("O evento iniciará em %d segundos(s)", Event.Time));
                    NoticeSendToAll(0, string.format("Digite %s para participar", Configuration["CommandNameEntry"]));
                end
                Event.Time = Event.Time - 1;
            end

        elseif  Event.State == 2 then

            if Event.Time == 0 then
                Event.NoticeGM("PEGUE-OS!!!!!", 0);
                Event.NoticeGM("PEGUE-OS!!!!!", 1);
                Event.Notice("COOOORRAAAA!!!!!!!!!!!", 0);
                Event.Notice("COOOORRAAAA!!!!!!!!!!!", 1);
                Event.Time = -1;
            elseif Event.Time > 0 then
                if Event.Time <= 5 then
                    Event.Notice(string.format("PREPARE-SE PARA CORRER! COMEÇA EM %d SEGUNDO(S)!!!", Event.Time), 0);
                    Event.NoticeGM(string.format("PREPARE-SE PARA CORRER! COMEÇA EM %d SEGUNDO(S)!!!", Event.Time), 0);
                end;
                Event.NoticeGM(string.format("[PegaPega]: O evento começará em %d segundo(s), prepare-se!!!", Event.Time), 1);
                Event.Notice(string.format("[PegaPega]: O evento começará em %d segundo(s), prepare-se!!!", Event.Time), 1);
                Event.Time = Event.Time - 1;
            end

        end

    end

end

PegaPega_Command = function(aIndex, code, arg)

    if code == Configuration["CommandCodeEntry"] then

        if Event.State ~= nil  and Event.State == 1 then
            if Character[aIndex] == nil then
                if Event.Conditions(aIndex) == 0 then
                    Character[aIndex] = GetObjectName(aIndex);
                    PermissionRemove(aIndex, 1);
                    PermissionRemove(aIndex, 7);
                    PermissionRemove(aIndex, 12);
                    MoveUserEx(aIndex, Configuration["Spawn"].Map, Configuration["Spawn"].X, Configuration["Spawn"].Y);
                    NoticeSend(aIndex, 1, "[PegaPega]: Você entrou no evento!");
                    SetObjectSkillBlockTime(aIndex,6,60*60*60);

if Event.CountTable(Character) == Configuration["MaxPlayers"] then
    NoticeSendToAll(0, ". : [ PEGA PEGA ] : .");
NoticeSendToAll(0, "Evento iniciado, máximo de participantes atingido");
LogPrint("[PEGA_PEGA]: O evento começou, máximo de participantes atingido.");
Event.Time  = Configuration["RaceTime"];
Event.State = 2;
end
                end
            else
                NoticeSend(aIndex, 1, "[PegaPega]: Você já está participando deste evento.");
            end
        else
            NoticeSend(aIndex, 1, "[PegaPega]: Você não pode entrar no evento agora.");
        end

        return 1;
    elseif code == Configuration["CommandCodeFunctions"] then

        local Command = string.upper(CommandGetArgString(arg, 0));

        if CommandCheckGameMasterLevel(aIndex,3) == 1 then

            if      Command == "LIGAR" then

                if Event.State ~= nil then
                    NoticeSend(aIndex, 1, "[PegaPega]: O evento já está ligado, use o argumento 'ENTRAR' no comando para entrar como GM.");
                else
                    Event.State = 1;
                    Event.Time  = Configuration["EntryTime"];
                    Event.GameMasters[aIndex] = GetObjectName(aIndex);
                    MoveUserEx(aIndex, Configuration["Spawn"].Map, Configuration["Spawn"].X, Configuration["Spawn"].Y);
                    LogPrint(string.format("[PEGA_PEGA]: Evento iniciado por %s.", Event.GameMasters[aIndex]));
                end

            elseif  Command == "DESLIGAR" then

                if Event.State ~= nil then
                    NoticeSendToAll(0, ". : [ PEGA PEGA ] : .");
                    NoticeSendToAll(0, string.format("Evento cancelado por %s.", GetObjectName(aIndex)));
                    Event.Close(GetObjectName(aIndex));
                else
                    NoticeSend(aIndex, 1, "[PegaPega]: O evento não está ocorrendo para que possa ser desligado.");
                end

            elseif  Command == "ENTRAR" then

                if Event.State ~= nil then
                    if Event.GameMasters[aIndex] == nil then Event.GameMasters[aIndex] = GetObjectName(aIndex); end;
                    MoveUserEx(aIndex, Configuration["Spawn"].Map, Configuration["Spawn"].X, Configuration["Spawn"].Y);
                else
                    NoticeSend(aIndex, 1, "[PegaPega]: O evento não está ligado, use o argumento 'LIGAR' no comando para ligar o evento.");
                end

else
NoticeSend(aIndex, 1, "[PegaPega]: Argumento inválido.");
            end

        else
            NoticeSend(aIndex, 1, "[PegaPega]: Você não possui permissão para utilizar este comando.");
        end

        return 1;
    end

    return 0;
end

PegaPega_Target = function(aIndex, bIndex)

    if Event.State ~= nil then

        if      Event.State == 1 then
            if Character[aIndex] ~= nil or Character[bIndex] ~= nil then return 0; end;
            if Event.GameMasters[aIndex] ~= nil or Event.GameMasters[bIndex] ~= nil then return 0; end;
        elseif  Event.State == 2 and Event.Time == -1 then

            if Character[aIndex] ~= nil then
return 0;
end

            if Character[bIndex] ~= nil and Event.GameMasters[aIndex] ~= nil then
                Event.Remove(bIndex);
NoticeSend(bIndex, 1, string.format("[PegaPega]: Você foi pego por %s e foi removido.", GetObjectName(aIndex)));
NoticeSendToAll(0, string.format("[PegaPega]: %s pegou %s.", GetObjectName(aIndex), GetObjectName(bIndex)));

                if Event.CountTable(Character) == 3 then
                    NoticeSendToAll(0, ". : [ PEGA PEGA ] : .");
                    Event.Reward(bIndex, 3);
                elseif Event.CountTable(Character) == 2 then
                    NoticeSendToAll(0, ". : [ PEGA PEGA ] : .");
                    Event.Reward(bIndex, 2);
                elseif Event.CountTable(Character) == 1 then
                    NoticeSendToAll(0, ". : [ PEGA PEGA ] : .");
                    Event.Reward(bIndex, 1);
                    Event.State = nil;
                end

                return 0;
            end;

        end

    end

    return 1;
end

PegaPega_Close = function(aIndex)

    if Character[aIndex] ~= nil then
        Event.Remove(aIndex);
        NoticeSendToAll(1, string.format("[PegaPega]: %s foi removido por sair do jogo.", GetObjectName(aIndex)));
    end;

end;

Event.Close = function(String)
    for bIndex in pairs(Character) do
        Event.Remove(bIndex);
        NoticeSend(bIndex, 1, string.format("[PegaPega]: Evento cancelado por %s, você foi movido para fora.", String));
    end;
    for bIndex in pairs(Event.GameMasters) do
        Event.GameMasters[bIndex] = nil;
        NoticeSend(bIndex, 1,  string.format("[PegaPega]: O evento foi encerrado por %s.", String));
    end;
    Event.State = nil;
    if String ~= '' then LogPrint(string.format("[PEGA_PEGA]: Evento fechado por %s.", String)) end;
end

Event.Conditions = function(aIndex)

    for Index in pairs(Configuration["BlockItems"]) do
        if InventoryGetItemIndex(aIndex, Index) ~= -1 then
            if Character[aIndex] ~= nil then
                Event.Remove(aIndex);
                return NoticeSend(aIndex, 1, string.format("[PegaPega]: Você foi removido por equipar sua/seu %s.", Configuration["BlockItems"][Index]));
            else
                return NoticeSend(aIndex, 1, string.format("[PegaPega]: Retire sua/seu %s e tente novamente.", Configuration["BlockItems"][Index]));
            end
        end
    end

    if GetObjectLevel(aIndex) < Configuration["MinLevel"] then
        if Character[aIndex] ~= nil then
            Event.Remove(aIndex);
            return NoticeSend(aIndex, 1, "[PegaPega]: Você foi removido por estar abaixo do level permitido.");
        else
            return NoticeSend(aIndex, 1, string.format("[PegaPega]: Obtenha o level %d para entrar no evento.", Configuration["MinLevel"]));
        end
    end   

if GetObjectMap(aIndex) ~= Configuration["Spawn"].Map then
        if Character[aIndex] ~= nil then
            Event.Remove(aIndex);
            return NoticeSend(aIndex, 1, "[PegaPega]: Você foi removido por estar em outro mapa.");
        end
    end

    return 0;

end

Event.Remove = function(aIndex)

    Character[aIndex] = nil;
    MoveUserEx(aIndex, 0, 125, 125);
    PermissionInsert(aIndex, 1);
    PermissionInsert(aIndex, 7);
    PermissionInsert(aIndex, 12);
    SetObjectSkillBlockTime(aIndex,6,0);

end

Event.Reward = function(aIndex, x)
    if x == 3 then
        local Name = GetObjectName(aIndex);
        Event.NoticeGM(string.format("[PegaPega]: Terceiro lugar: %s.", Name), 1);
        NoticeSendToAll(0, string.format("[3º Lugar] » %s", Name));
        NoticeSend(aIndex, 1, "[PegaPega]: Você ganhou!!! Parabéns!!!");
        NoticeSend(aIndex, 1, string.format("[PegaPega]: Você recebeu: %s.", Configuration["RewardMessage3"]));
        assert(loadstring(string.gsub(Configuration["Reward3"], 'aIndex', aIndex)))();
        Event.Remove(aIndex);
    elseif x == 2 then
        local Name = GetObjectName(aIndex);
        Event.NoticeGM(string.format("[PegaPega]: Segundo lugar: %s.", Name), 1);
        NoticeSendToAll(0, string.format("[2º Lugar] » %s", Name));
        NoticeSend(aIndex, 1, "[PegaPega]: Você ganhou em segundo lugar!!! Parabéns!!!");
        NoticeSend(aIndex, 1, string.format("[PegaPega]: Você recebeu: %s.", Configuration["RewardMessage2"]));
        assert(loadstring(string.gsub(Configuration["Reward2"], 'aIndex', aIndex)))();
        Event.Remove(aIndex);
    elseif x == 1 then
        local Name = GetObjectName(aIndex);
        Event.NoticeGM(string.format("[PegaPega]: Primeiro lugar: %s.", Name), 1);
        NoticeSendToAll(0, string.format("[1º Lugar] » %s", Name));
        NoticeSend(aIndex, 1, "[PegaPega]: Você ganhou!!! Parabéns!!!");
        NoticeSend(aIndex, 1, string.format("[PegaPega]: Você recebeu: %s.", Configuration["RewardMessage3"]));
        assert(loadstring(string.gsub(Configuration["Reward1"], 'aIndex', aIndex)))();
        Event.Remove(aIndex);
        Character = {};
    end

end

Event.Notice = function(Message, Type) for aIndex in pairs(Character) do NoticeSend(aIndex, Type, Message); end; end;

Event.NoticeGM = function(Message, Type) for aIndex in pairs(Event.GameMasters) do NoticeSend(aIndex, Type, Message); end; end;

Event.CountTable = function(T) local count = 0; for _ in pairs(T) do count = count + 1 end; return count; end;
« Última Modificación: Agosto 23, 2020, 03:33:47 pm por jcouti »

Gracias:

DarkDemo, Louis, zerolshen, wiljipa, lorranmota, aldair8, MFalmeida, mk36, Nation, rodritwm, alefmello, AlexPotro, lolz3976, LoaD, Expert, Yalih, guibnu, candido, jhork91, Yache, Teseu, pkdomal, Guga, =Hacker=, MuDarkAge97D, Dyego, rizato, daezugun, ruojing, loprado, driosm3, MuConexão, ProMD, DiegoShadow, ratm, wellwisher22, sebasrodrigo, debwebco, vitorotero, lobinhopk, Denis Alves, Nicacio, Rafael222, jrlucena88, brunoap, [email protected], legolas01, hinetworks, danielbelmiro, carlosfelipe, Weberson(GWteam), walassi12, polate, lomluhitre, sevin, PostM4lone, ziza, elemento, leozinfln, ish4d0w, HiagoB, wendellandrade159, gu34, VCT-Team, srboga, vitordodo157, sulake9, brahian, robiivagyok, acacoo, AnDeR, kellington, asadas, orl4nd1, joaovithor1, faelcanalha, saddasd, ronaldof7, LTZIN, waynemartins, caps, yagorlm, adamalbino, lucca03, xd22troxa, GamePlay, fabioozzy, brunomalaa, kingpin, havanna, murati, brahian1891, rafaelxd5, mubutter, jukas, silvadesink, mcpatrao, Night, ThZiin, oliverxis, juninsj22, felippe2099, quest, duende01, tosti, lukelphost, darkstilo, nahu2408, junior, iCosTz, oswaldoxo, hadarmax, loopik, nenedario, prepago, thekingg145, itashibk, golias14, cesarar, lucasvieiragames, ghuty, tibue, slasherpro, fabiobf, carlosfelipe20, hamico, gaabiru014, DemonIp, Wohaho, DaThiHost, maritohh, erickstorm, fyre, damiqw, judocas11, AdamantiumMu, muoricalcos, kingvitor00, nasho92, xekematexd, martinsgo, danzin123, chiquilito, nahuel, tiagoassis, luciano259, anjazz, leonardexapps, bobzznnn, srsti, Yowaster, bombastic1, supremo, luukinhaa2, maty1994, fhee94, Gamersdcx

jcouti

Alterem a última linha do script
Event.CountTable = function(T) local count = 0; for _ in pairs(T) do count = count + 1 end; return count; end;

basta mudar o 0 do count para 1, ficando assim:

Event.CountTable = function(T) local count = 1; for _ in pairs(T) do count = count + 1 end; return count; end;

Resolve o problema de estar premiando o 4, 3, 2 e não o 3,2,1.

Causa: Esqueci que as tabelas começam em 1 (em Lua), não 0.

Gracias:


Desconectado cesarar

  • *


  • 1

    0

    0
  • br
server para ssemu tambem ?

 

.