Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
mafia для pvpgn
#1
может немного не в тему форума , но именно на вашем сайте я нахожу все ответы на вопросы ...
так вот поставил стелсбота и скрипт на мафию .. все вроде хорошо, но бот не реагирует на команды .kill , .save , и т.д. ... не подскажите в чем проблема может быть ?

вот код скрипта
Код:
'///////////mafia for stealthbot ver 1.22

'///////////Created by nice-day (http://mafa.hotmail.ru)



public const AdminFilePath = "admin.ini"

dim game_active 'если true то игра запущена
dim day_time 'длинна дня в секундах
dim night_time 'длинна ночи в секундах
dim time_counter 'счётчик времени игры(за день проходит 2 круга - один для дня и один для ночи)
dim it_is_night 'если ночь, то true

dim people(200,20) 'всё по игрокам
dim people_quantity 'количество игроков

dim classic_counter 'счётчик первых classic_time секунд игры
dim classic_active ' работает ли классическая мафия
dim classic_time ' начальное время перед стартом игры
dim classic_array(200) 'массив присоединившихся игроков в классике
dim classic_array_counter ' маркер длинны массива
dim master ' хозяин бота
dim reconnectTimer 'время реконнекта

dim idle_message_counter 'счётчик промежуточного сообщения
dim idle_message 'промежуточное сообщение
dim idle_time 'промежуток между сообщениями

dim max_players ' максимум игроков в игре (0-не ограниченно)
dim players_joined ' количество подключившихся игроков
'/////////////////////////////////////////////////////////////////////////


Sub Load_admin '/////подпрограмма загрузки администратора игры из файла
On Error Resume Next
        

    Dim fso, admin_file
        
    master=""
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set admin_file = fso.OpenTextFile(AdminFilePath, 1, True)
    master=trim(admin_file.ReadLine)
    admin_file.close
    if (Err.Number>0) then
        master=""
'        AddChat vbGreen, "error in Load_admin " & Err.Number
'        Addq "/w " & master & " error in Load_admin " & Err.Number
    end if    
    On Error GoTo 0
End Sub


Sub Start_game 'запуск игры

On Error Resume Next



    if (game_active=false) then
        time_counter=night_time
        it_is_night=true
        game_active=true
        Victory_test
    end if    


if (Err.Number>0) then
AddChat vbGreen, "error in Start_game " & Err.Number
Addq "/w " & master & " error in Start_game " & Err.Number
end if    
On Error GoTo 0

End SUB
'///////////////////////////////////////////////////////////////////////////

Sub Stop_game 'прекращение игры

On Error Resume Next


    classic_counter=0
    classic_array_counter=0
    classic_active=false
    game_active=false
    time_counter=night_time
    it_is_night=true
    Init_people
    max_players=0
    players_joined=0

if (Err.Number>0) then
AddChat vbGreen, "error in Stop_game " & Err.Number
Addq "/w " & master & " error in Stop_game " & Err.Number
end if    
On Error GoTo 0


End Sub
'/////////////////////////////////////////////////////////////////////////////

Sub Start_classic

On Error Resume Next


        if (max_players>12) then
            max_players=12
        end if

        players_joined=0
        time_counter=night_time
        it_is_night=true
        classic_active=true
        game_active=true

        if (max_players>=1 and max_players<=12) then
            classic_counter=600 '10 минут на сбор
        else
            classic_counter=classic_time
        end if




if (Err.Number>0) then
AddChat vbGreen, "error in Start_classic " & Err.Number
Addq "/w " & master & " error in Start_classic " & Err.Number
end if    
On Error GoTo 0

end Sub

'/////////////////////////////////////////////////////////////////////////////////

Sub Init_people '/////подпрограмма инициализации массива игроков

On Error Resume Next


    for i=0 to (200-1)
        for j=0 to (20-1)
            people(i,j)=-1
        next        
    next
    people_quantity=0
    people(0,0)="Username"
    people(0,1)=0 '"side" '//0-deadman 1-peasant 2-mafia 3-maniac
    people(0,2)=0 ' "profession" '1-doctor 2-lawyer 3-policeman
    people(0,3)=1 ' "voted" '0-no 1-yes
    people(0,4)="EMPTY SLOT"
    people(0,5)=0 ' "voting counter" '0-noone vote N-quantity of votes
    people(0,6)=0 ' "protection by DOCTOR or LAWYER" '0-no 1-y
    people(0,7)=0 ' "maniac's victim" '0-no 1-y
    people(0,8)=0 ' "voting's victim" '0-no 1-y
    people(0,9)=0 ' "leaver" '0-no 1-y
    people(0,10)=1 ' "used ability this round" '0-no 1-y

if (Err.Number>0) then
AddChat vbGreen, "error in Init_people " & Err.Number
Addq "/w " & master & " error in Init_people " & Err.Number
end if    
On Error GoTo 0

End Sub
'///////////////////////////////////////////////////////////////////////////////////
Sub Alive_players 'выводит список играющих игроков

On Error Resume Next

    five=0
    str="/me Ceйчac живы: "
    
    for i=1 to (people_quantity)
        if (people(i,1)>0) then
            five=five+1
            str=(str & "(" & i & ")" & "-" & people(i,0) & "; ")
            if (five>4) then
                AddQ str
                str="/me Ceйчac живы: "
                five=0    
            end if        
        end if
    next
    if (five>0) then
            AddQ str
    end if

if (Err.Number>0) then
AddChat vbGreen, "error in Alive_players " & Err.Number
Addq "/w " & master & " error in Alive_players " & Err.Number
end if    
On Error GoTo 0

end Sub

'///////////////////////////////////////////////////////////////////////////////////////

Sub Victory_test 'проверка на победу и отключение игры в случае победы

On Error Resume Next


    dim side(4)
    side(1)=side(2)=side(3)=0
    for i=1 to (people_quantity)
        if (people(i,1)>0) then
            side(people(i,1))=side(people(i,1))+1
                
        end if
    next
    if (side(1)>0 AND (side(2)=0 AND side(3)=0))  then
    'мирные победили
        Alive_players
        AddQ "/me MИPHЫE ГPAЖДAHE пoбeдили в игpe!"
        Stop_game
    end if
    if (side(2)>0 AND (side(1)=0 AND side(3)=0))  then
    'мафия победила
        Alive_players
        AddQ "/me MAФИЯ пoбeдилa в игpe!"
        Stop_game
    end if
    if (side(3)=1 AND (side(1)=0 AND side(2)=0))  then
        Alive_players
        AddQ "/me MAHЬЯK пoбeдил в игpe"
        Stop_game
    end if
    if (side(3)=0 AND (side(1)=0 AND side(2)=0))  then
        Alive_players
        AddQ "/me Hичeйнaя пoбeдa. HИKTO нe выжил"
        Stop_game
    end if


if (Err.Number>0) then
AddChat vbGreen, "error in Victory_test " & Err.Number
Addq "/w " & master & " error in Victory_test " & Err.Number
end if    
On Error GoTo 0


end Sub
'//////////////////////////////////////////////////////////////////////////////////////////////////////
Sub Vote_result 'podvodim itogi golosovania i obnylyaem shethik golosovania(v samom  konce dniy i nochi)

On Error Resume Next

    max_vote=0 'наибольший результат
    max_num=0 ' число людей с наибольшим результатом
    max_id=0 ' номер игрока с наибольшим результатом
    maf_num=0' число мафий

    for i=1 to (people_quantity)
        if (people(i,1)>0) then
            if (people(i,1)=2) then
                maf_num=maf_num+1
            end if            

            if (people(i,5)=max_vote) then
                
                
                max_num=max_num+1
            end if
            if (people(i,5)>max_vote) then
                max_vote=people(i,5)
                max_id=i
                max_num=1
            end if
        end if
    next
    if(max_num=1 AND max_vote>0) then
    'если найдена жертва с большинством голосов
        people(max_id,8)=1
    else
        if(it_is_night=true ) then
            if( maf_num>0) then
                Addq "/me HИKTO нe был убит MAФИEЙ нoчью(ничeйнoe гoлoсoвaниe)."
            end if
        else
            Addq "/me HИKTO нe был кaзнён днём(ничeйнoe гoлoсoваниe)"
        end if
            
    end if    

    'обнуляем счётчики
    for i=1 to (people_quantity)
        if (people(i,1)>0) then
            people(i,5)=0
        end if
    next

if (Err.Number>0) then
AddChat vbGreen, "error in Vote_result " & Err.Number
Addq "/w " & master & " error in Vote_result " & Err.Number
end if    
On Error GoTo 0
    
end Sub
'////////////////////////////////////////////////////////////////////////////////////////////////////////
Sub Death_results 'здесь вычисляем кто умер, убиваем их и выводим сообщения об убийсвах и покушениях(такж обнуляем флаги)

On Error Resume Next

    for i=1 to (people_quantity)
        if (people(i,1)>0 AND (people(i,7)=1 OR people(i,8)=1) ) then
        'если жив и если пытаются убить
            killer_str=""
            protector_str=""
            if (it_is_night=true) then
            'если ночью
                if (people(i,6)=1) then
                'если защитили
                    protector_str=" ДOKTOP "
                end if
                if (people(i,7)=1 AND people(i,8)=1) then
                'если убивают мафия и маньяк
                    killer_str=" MAФИEЙ и MAHЬЯKOM "
                end if
                if (people(i,7)=1 AND people(i,8)=0) then
                'если убивает маньяк
                    killer_str=" MAHЬЯKOM "
                end if
                if (people(i,7)=0 AND people(i,8)=1) then
                'если убивает мафия
                    killer_str=" MAФИEЙ "
                end if

            else
            'если днём
                if (people(i,6)=1) then
                'если защитили
                    protector_str=" AДBOKAT "
                end if
                if people(i,8)=1 then
                'если убивают мирные
                    killer_str=" ГPAЖДAHAMИ "
                end if
            end if
            if (people(i,6)=1) then
            'если защитили(итог)
                ADDQ "/me " & killer_str & "былa пoпыткa убить " & "(" & i & ")-"& people(i,0) & " ,нo " & protector_str & " cпac eгo."
                'обнуляем всё, кроме сигнала о том что человек вышел с канала            
                people(i,6)=0
                people(i,7)=0
                people(i,8)=0
                for j=3 to 8
                    people(i,j)=0
                next
                for j=10 to (20-1)
                    people(i,j)=0
                next
            else
            'если не защитили(итог)
                ADDQ "/me " & "(" & i & ")-"& people(i,0) & " " & Get_user_status(i) & " был убит " & killer_str
                people(i,1)=0
                for j=2 to (20-1)
                    people(i,j)=-1
                next
            end if
        else
        'обнуляем флаги
            for j=3 to 8
                people(i,j)=0
            next
            for j=10 to (20-1)
                people(i,j)=0
            next
            
        end if
        

    next
    ' убиваем ливеров
    for i=1 to (people_quantity)
        if (people(i,9)=1) then
            Addq  "/me " & people(i,0) & " " & Get_user_status(i) & " умep пpи пoрыткe пoкинуть кaнaл игpы"
            people(i,1)=0
            for j=2 to (20-1)
                people(i,j)=-1
            next
            
        end if
    next


if (Err.Number>0) then
AddChat vbGreen, "error in Death_results " & Err.Number
Addq "/w " & master & " error in Death_results " & Err.Number
end if    
On Error GoTo 0

end Sub
'////////////////////////////////////////////////////////////////////////////////
Sub Give_classic_roles 'разадаём роли для классики

On Error Resume Next


    dim good_array(200) 'временный массив чтобы упорядочить пользователей

    number_of_ppl=0
    for i=1 to classic_array_counter
        if (classic_array(i)<>"") then
            number_of_ppl=number_of_ppl+1
            good_array(number_of_ppl)=classic_array(i)
        end if
    next
    num_maniac=FIX(0.126*number_of_ppl)
    num_mafia=FIX(0.330*number_of_ppl)
    num_peasant=FIX(0.544*number_of_ppl)
    num_delta=number_of_ppl-(num_peasant+num_mafia+num_maniac)
    num_peasant=num_peasant+num_delta
    num_doctor=0
    num_policeman=0
    num_lawyer=0
    if (num_peasant=1) then
        num_peasant=num_peasant-1
        num_doctor=num_doctor+1
    end if

    if (num_peasant>1) then
        num_peasant=num_peasant-2
        num_doctor=num_doctor+1
        num_policeman=num_policeman+1
    end if
    if (num_mafia>0) then
        num_mafia=num_mafia-1
        num_lawyer=num_lawyer+1
    end if
    
    ADDQ "/me ИГPAЮT: " & num_doctor & " дoктop; " &  num_policeman & " мeнт; " & num_peasant & " гpaждaне; "
    ADDQ "/me ИГРАЮТ: " & num_lawyer & " мaфия-aдвoкaт; "  & num_mafia & " мaфия; " & num_maniac & " мaньяк; "
    i=1
    Do While i<=number_of_ppl
        chk=0
        rand=rnd(1)
        doctor_deg=CDbl(num_doctor/number_of_ppl)
        lawyer_deg=CDbl(num_lawyer/number_of_ppl)
        policeman_deg=CDbl(num_policeman/number_of_ppl)
        mafia_deg=CDbl(num_mafia/number_of_ppl)
        maniac_deg=CDbl(num_maniac/number_of_ppl)
        peasant_deg=CDbl(num_peasant/number_of_ppl)

        if (rand<doctor_deg AND num_doctor>0) then
        'доктор
            temp=Add_user(good_array(i),2)
            num_doctor=num_doctor-1
            chk=1
        end if
        if (rand>=doctor_deg AND rand<(doctor_deg+lawyer_deg) AND num_lawyer>0) then
        'адвокат
            temp=Add_user(good_array(i),3)
            num_lawyer=num_lawyer-1
            chk=1
        end if
        if (rand>=(doctor_deg+lawyer_deg) AND rand<(doctor_deg+lawyer_deg+policeman_deg) AND num_policeman>0) then
        'мент
            temp=Add_user(good_array(i),4)
            num_policeman=num_policeman-1
            chk=1
        end if
        if (rand>=(doctor_deg+lawyer_deg+policeman_deg) AND rand<(doctor_deg+lawyer_deg+policeman_deg+mafia_deg) AND num_mafia>0) then
        'мафия
            temp=Add_user(good_array(i),5)
            num_mafia=num_mafia-1
            chk=1
        end if
        if (rand>=(doctor_deg+lawyer_deg+policeman_deg+mafia_deg) AND rand<(doctor_deg+lawyer_deg+policeman_deg+mafia_deg+maniac_deg) AND num_maniac>0) then
        'маньяк
            temp=Add_user(good_array(i),6)
            num_maniac=num_maniac-1
            chk=1
        end if
        if (rand>=(doctor_deg+lawyer_deg+policeman_deg+mafia_deg+maniac_deg) AND num_peasant>0) then
        'пизант
            temp=Add_user(good_array(i),1)
            num_peasant=num_peasant-1
            chk=1
        end if
        
        if (chk=0) then
            i=i-1
        end if
        i=i+1
    loop    



if (Err.Number>0) then
AddChat vbGreen, "error in Give_classic_roles " & Err.Number
Addq "/w " & master & " error in Give_classic_roles " & Err.Number
end if    
On Error GoTo 0


End Sub

'/////////////////////////////////////////////////////////////////////////////////
'//добавляет пользователя с именем  user в игру, назначая роль role:0 -случайно, 1-пизант 2-доктор 3-адвокат;4-мент; 5-мафия; 6-маньяк
Function Add_user(user, role)
    
On Error Resume Next

    for i=1 to (people_quantity)
        if (people(i,0)=user) then


if (Err.Number>0) then
AddChat vbGreen, "error in Add_user " & Err.Number
Addq "/w " & master & " error in Add_user " & Err.Number
end if    
On Error GoTo 0


            Exit Function
        end if
    next

    if (role=0) then
    'если случайный выбор
        people_quantity=people_quantity+1    
        people(people_quantity,0)=user
    


        rand=rnd(1)
        if (rand<0.05) then
        'maniac
            people(people_quantity,1)=3
            people(people_quantity,2)=0
            AddQ "/w " & user & " ты MAHЬЯK"
        end if
        if (rand>=0.05 AND rand<0.25) then
        'mafia
            people(people_quantity,1)=2
            people(people_quantity,2)=0
            AddQ "/w " & user & " ты MAФИЯ"
        end if
        if (rand>=0.25 AND rand<0.30) then
        'doctor
            people(people_quantity,1)=1
            people(people_quantity,2)=1
            AddQ "/w " & user & " ты ДOKTOP"
        end if
        if (rand>=0.30 AND rand<0.35) then
        'lawyer
            people(people_quantity,1)=2
            people(people_quantity,2)=2
            AddQ "/w " & user & " ты AДBOKAT-МАФИИ"
        end if
        if (rand>=0.35 AND rand<0.40) then
        'policeman
            people(people_quantity,1)=1
            people(people_quantity,2)=3
            AddQ "/w " & user & " ты MEHT"
        end if
        if (rand>=0.40) then
        'peasant
            people(people_quantity,1)=1
            people(people_quantity,2)=0
            AddQ "/w " & user & " ты ГPAЖДAHИH"
        end if
    
        for i=3 to 20
        'обнуляем все настройки
            people(people_quantity,i)=0
        next
    end if
    
    if (role>0 AND role<7) then
    'если заданный выбор

        people_quantity=people_quantity+1    
        people(people_quantity,0)=user
        if (role=1) then
        'если пизант
            people(people_quantity,1)=1
            people(people_quantity,2)=0
            AddQ "/w " & user & " ты ГPAЖДAHИH"
        end if
        if (role=2) then
        'если доктор
            people(people_quantity,1)=1
            people(people_quantity,2)=1
            AddQ "/w " & user & " ты ДOKTOP"
        end if

        if (role=3) then
        'если адвокат
            people(people_quantity,1)=2
            people(people_quantity,2)=2
            AddQ "/w " & user & " ты MAФИЯ-AДBOKAT"
        end if

        if (role=4) then
        'если мент
            people(people_quantity,1)=1
            people(people_quantity,2)=3
            AddQ "/w " & user & " ты MEHT"
        end if


        if (role=5) then
        'если мафия
            people(people_quantity,1)=2
            people(people_quantity,2)=0
            AddQ "/w " & user & " ты MAФИЯ"
        end if


        if (role=6) then
        'если маньяк
            people(people_quantity,1)=3
            people(people_quantity,2)=0
            AddQ "/w " & user & " ты MAHЬЯK"
        end if


        for i=3 to 20
        'обнуляем все настройки
            people(people_quantity,i)=0
        next
    end if

if (Err.Number>0) then
AddChat vbGreen, "error in Add_user " & Err.Number
Addq "/w " & master & " error in Add_user " & Err.Number
end if    
On Error GoTo 0

end Function

'///////////////////////////////////////////////////////////////////////

Function Get_id_by_name(user) ' получить номер игрока по его нику 0-если такого нет

'On Error Resume Next


    for i=1 to (people_quantity)
        if (lcase(trim(people(i,0)))=lcase(trim(user))) then
            Get_id_by_name=i


if (Err.Number>0) then
AddChat vbGreen, "error in Get_id_by_name " & Err.Number
Addq "/w " & master & " error in Get_id_by_name " & Err.Number
end if    
On Error GoTo 0


            Exit Function    
        end if
    next
    Get_id_by_name=0



if (Err.Number>0) then
AddChat vbGreen, "error in Get_id_by_name " & Err.Number
Addq "/w " & master & " error in Get_id_by_name " & Err.Number
end if    
On Error GoTo 0

end Function

'//////////////////////////////////////////////////////////////////////////

Function Kill_leaver(user) 'убивает чела покидающего канал

On Error Resume Next


    id1=Get_id_by_name(user)
    if(id1>0) then
        If (people(id1,1)>0) then
            people(id1,9)=1

        end if
    end if    
    

if (Err.Number>0) then
AddChat vbGreen, "error in Kill_leaver " & Err.Number
Addq "/w " & master & " error in Kill_leaver " & Err.Number
end if    
On Error GoTo 0


end Function
'///////////////////////////////////////////////////////////////////////

Function Get_user_status(userID) 'строковый статус игрока с номером userID

On Error Resume Next

    if(people(userID,1)=0) then
        Get_user_status="TPУП"
    end if        
    if(people(userID,1)=1) then
        Get_user_status="ГPAЖДAHИH"
        if (people(userID,2)=1) then
            Get_user_status="ДOKTOP"
        end if
        if (people(userID,2)=3) then
            Get_user_status="MEHT"
        end if
    end if
    if(people(userID,1)=2) then
        Get_user_status="MAФИЯ"
        if (people(userID,2)=2) then
            Get_user_status="MAФИЯ-AДBOKAT"
        end if
    end if    
    if(people(userID,1)=3) then
        Get_user_status="MAHЬЯK"
    end if                



if (Err.Number>0) then
AddChat vbGreen, "error in Get_user_status " & Err.Number
Addq "/w " & master & " error in Get_user_status " & Err.Number
end if    
On Error GoTo 0


end Function

'////////////////////////////////////////////////////////////////////////////////////////
'// функция делит сообщение Message, состоящие из 2 слов разделённых пробелом, на отдельные 2 слова и
'// возвращает номер первое слово, если numOfReturn=0 и 2-ое, если numOfReturn=1
Function DivideMessage (message, numOfReturn)

On Error Resume Next

    DivideMessage = Message
    if(numOfReturn=0) then
        DivideMessage=Left(Trim(message),InStr(Trim(message) & " "," ")-1)
    else






        DivideMessage=Trim(Mid(Trim(message),InStr(Trim(message)+" "," ")+1,Len(Trim(message))-Len(Left(Trim(message),InStr(Trim(message)+" "," ")))))




    end if



if (Err.Number>0) then
DivideMessage = ""
AddChat vbGreen, "error in DivideMessage " & Err.Number
Addq "/w " & master & " error in DivideMessage " & Err.Number
end if    
On Error GoTo 0


End Function

'/////////////////////////////////////////////////////////////////////////////////////////////

'// функция добовляет точку к началу сообщения, если точки ещё нет
Function AddPoint(message)

On Error Resume Next

    AddPoint = Message
    if  (Left(Message,1)<> ".") then
        AddPoint="." & Message
    else
        AddPoint=Message    
    
    end if
    



    



if (Err.Number>0) then
DivideMessage = ""
AddChat vbGreen, "error in AddPoint " & Err.Number
Addq "/w " & master & " error in AddPoint " & Err.Number
end if    
On Error GoTo 0


End Function





'/////////////////////////////////////////////////////////////////////////////////////////////
Function Str_to_num (message) 'если строка числовая и число от 1 до 200(макс число игроков), то она превращается в число, а иначе 0

On Error Resume Next

    
        if (IsNumeric(message)=true and Len(trim(message))<9 ) then
    'если строка цифровая и если число не более 8 цифр
        if (CLng(message)<=200 AND CLng(message)>0) then
            Str_to_num=CLng(message)
        else
            Str_to_num=0
        end if
    else
        Str_to_num=0
    end if
    
if (Err.Number>0) then
Str_to_num=0
AddChat vbGreen, "error in Str_to_num " & Err.Number
Addq "/w " & master & " error in Str_to_num " & Err.Number
end if    
On Error GoTo 0

End Function
'/////////////////////////////////////////////////////////////////////////////////////////////

Function Who_is_mafia() 'фукция возвращает номер босса или 0 если нет мафии

On Error Resume Next

    mafia1="MAФИЯ: "
    mafia2="Hoмepa игpoкoв MAФИИ: "
    mafia_num=0

    for i=1 to (people_quantity)
        if (people(i,1)=2) then
            mafia1=mafia1 & "(" & i & ")-" & people(i,0) & "; "
            mafia2=mafia2 & i &"; "
            mafia_num=mafia_num+1
        end if
    next    
    if (mafia_num>3) then
        Who_is_mafia=mafia2
    else
        Who_is_mafia=mafia1
    end if



if (Err.Number>0) then
AddChat vbGreen, "error in Who_is_mafia " & Err.Number
Addq "/w " & master & " error in Who_is_mafia " & Err.Number
end if    
On Error GoTo 0


End Function
'//////////////////////////////////////////////////////////////////////

'добавляет юзера в массив классики
Function Add_classic(user)

On Error Resume Next

    for i=1 to classic_array_counter
        if (lcase(user)=lcase(classic_array(i))) then


if (Err.Number>0) then
AddChat vbGreen, "error in Add_classic " & Err.Number
Addq "/w " & master & " error in Add_classic " & Err.Number
end if    
On Error GoTo 0

            Exit Function
        end if
    next
    classic_array_counter=classic_array_counter+1
    classic_array(classic_array_counter)=user
    players_joined=players_joined+1
    addq "/me " & user & " в игpe"



if (Err.Number>0) then
AddChat vbGreen, "error in Add_classic " & Err.Number
Addq "/w " & master & " error in Add_classic " & Err.Number
end if    
On Error GoTo 0


End Function

'///////////////////////////////////////////////////////////////////

Function Del_classic(user) 'удаляет юзера из массива классики

On Error Resume Next

    for i=1 to classic_array_counter
        if (lcase(user)=lcase(classic_array(i))) then
            addq "/me " & user & " ушёл"
            players_joined=players_joined-1
            classic_array(i)=""
        end if
    next

if (Err.Number>0) then
AddChat vbGreen, "error in Del_classic " & Err.Number
Addq "/w " & master & " error in Del_classic " & Err.Number
end if    
On Error GoTo 0


End Function
'////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////
'////////////////////////////////////////////////////////////////
'// Fires when the bot executes.

Sub Event_Load()


On Error Resume Next


reconnectTimer=25

Randomize
'/////////////////////

    Load_admin

'    master="administrator"
    day_time=180
    night_time=180
    classic_time=60
    idle_time=600
'//////////////////////

Init_people

scTimer.Interval = 1000
scTimer.Enabled = true

classic_counter=0
game_active =false
classic_active=false
idle_message_counter=idle_time
idle_message="/me Узнать правила игры МАФИЯ можно на сайте http://mafa.hotmail.ru"

max_players=0
players_joined=0



if (Err.Number>0) then
AddChat vbGreen, "error in Event_Load " & Err.Number
Addq "/w " & master & " error in Event_Load " & Err.Number
end if    
On Error GoTo 0


End Sub

'////////////////////////////////////////////////////////////////////////////


'// Fires when the server sends a blue INFO-type message. (Includes ban and kick messages.)

Sub Event_ServerInfo(Message)

On Error Resume Next



if (Err.Number>0) then
AddChat vbGreen, "error in Event_ServerInfo " & Err.Number
Addq "/w " & master & " error in Event_ServerInfo " & Err.Number
end if    
On Error GoTo 0

End Sub

'//////////////////////////////////////////////////////////////////////////////
'// Fires when the server sends a red ERROR-type message. (Includes "That user is not logged on." etc.)

Sub Event_ServerError(Message)


On Error Resume Next



if (Err.Number>0) then
AddChat vbGreen, "error in Event_ServerError " & Err.Number
Addq "/w " & master & " error in Event_ServerError " & Err.Number
end if    
On Error GoTo 0


End Sub

'//////////////////////////////////////////////////////////////////////////////
'// Fires when a user on battle.net talks.

Sub Event_UserTalk(Username, Flags, Message, Ping)

On Error Resume Next


Png=Ping
    
    Select Case AddPoint(lcase(trim(DivideMessage(Message, 0))))
        Case ".start"
            if (classic_active=true AND classic_counter>60  AND (trim(lcase(Username))=trim(lcase(master)) OR trim(master)="")) then
                classic_counter=65
            end if
        Case ".stop"
            if (classic_active=true AND classic_counter>0 AND master<>"" AND trim(lcase(Username))=trim(lcase(master))) then
                Stop_game
                addq "/me игpa ocтaнoвлeнa"
            end if
        Case ".go"

            if (game_active=false and (lcase(Username)=lcase(master) OR master="" ) ) then
                Stop_game
                
                max_players=Str_to_num(DivideMessage(Message, 1))

                Start_classic
            end if
'        Case ".pause"
'            game_active=false
        Case ".join"
            If (classic_active=true AND classic_counter>0)    then
                if ((players_joined<max_players AND max_players>0) OR (max_players=0)) then
                    Add_classic(Username)
                end if
            end if
    '        if (classic_active=false) then
    '            temp=Add_user( Username , 0)
        
    '        end if
    End Select
    
    if (game_active=true) then
    'только если игра идёт
        Select Case AddPoint(trim(lcase(DivideMessage (Message, 0))))
            Case ".vote"
                if (it_is_night=false AND people(Get_id_by_name(Username),1)>0 AND people(Str_to_num(DivideMessage(Message, 1)),1)>0 AND people(Get_id_by_name(Username),3)=0 AND Trim(DivideMessage(Message, 1))<>"") then
                'мирные  голусуют (есль день, ты ALL, твоя цель жива и ты не голосовал)
                    people(Str_to_num(DivideMessage(Message, 1)),5)=people(Str_to_num(DivideMessage(Message, 1)),5)+1
                    people(Get_id_by_name(Username),3)=1
                    addq "/me " & Username & " гoлocуeт зa " & people(Str_to_num(DivideMessage(Message, 1)),0)
                end if
        End Select
    end if    




if (Err.Number>0) then
AddChat vbGreen, "error in Event_UserTalk " & Err.Number
Addq "/w " & master & " error in Event_UserTalk " & Err.Number
end if    
On Error GoTo 0



End Sub

'///////////////////////////////////////////////////////////////////////
'// Fires when a user speaks with /emote.

Sub Event_UserEmote(Username, Flags, Message)

On Error Resume Next



if (Err.Number>0) then
AddChat vbGreen, "error in Event_UserEmote " & Err.Number
Addq "/w " & master & " error in Event_UserEmote " & Err.Number
end if    
On Error GoTo 0

End Sub

'///////////////////////////////////////////////////////////////////////
'// Fires when a whisper is recieved.

Sub Event_WhisperFromUser(Username, Flags, Message)

On Error Resume Next


    Select Case lcase(DivideMessage (Message, 0))
        Case ".sendbot"
            if (lcase(Username)=lcase(master)) then
                addq "/join " & DivideMessage (Message, 1)
            else
                if (game_active=false) then
                    addq "/join " & DivideMessage (Message, 1)
                else
                    addq "Game is active. Try later"
                end if
            end if
    end select






    if (game_active=true) then
    'только если игра идёт



        Select Case AddPoint(Trim(lcase(DivideMessage (Message, 0))))
            Case ".vote"

                if (it_is_night=true AND people(Get_id_by_name(Username),1)=2 AND people(Str_to_num(DivideMessage(Message, 1)),1)>0 AND people(Get_id_by_name(Username),3)=0 AND Trim(DivideMessage(Message,1))<>"") then
                'мафия голусует (есль ночь, ты мафия, твоя цель жива и ты не голосовал)
                    people(Str_to_num(DivideMessage(Message, 1)),5)=people(Str_to_num(DivideMessage(Message, 1)),5)+1
                    people(Get_id_by_name(Username),3)=1
                    addq "/w " & Username & " ты xoчeшь убить " & people(Str_to_num(DivideMessage(Message, 1)),0)
                end if


                if (it_is_night=false AND people(Get_id_by_name(Username),1)>0 AND people(Str_to_num(DivideMessage(Message, 1)),1)>0 AND people(Get_id_by_name(Username),3)=0 AND Trim(DivideMessage(Message, 1))<>"") then
                'мирные  голусуют (есль день, ты ALL, твоя цель жива и ты не голосовал)
                    people(Str_to_num(DivideMessage(Message, 1)),5)=people(Str_to_num(DivideMessage(Message, 1)),5)+1
                    people(Get_id_by_name(Username),3)=1
                    addq "/me " & Username & " гoлocуeт зa " & people(Str_to_num(DivideMessage(Message, 1)),0)
                end if


            Case ".kill"
                

                if (it_is_night=true AND people(Get_id_by_name(Username),1)=3 AND people(Str_to_num(DivideMessage(Message, 1)),1)>0 AND people(Get_id_by_name(Username),10)=0 AND Trim(DivideMessage(Message, 1))<>"") then
                'маньяк убивает (есль ночь, ты маньяк, твоя цель жива и ты не ещё не убивал)
                    people(Str_to_num(DivideMessage(Message, 1)),7)=1
                    people(Get_id_by_name(Username),10)=1
                    addq "/w " & Username & " ты xoчeшь убить " & people(Str_to_num(DivideMessage(Message, 1)),0)
                end if

            Case ".mafia"
                if (it_is_night=true AND people(Get_id_by_name(Username),1)=2 AND people(Get_id_by_name(Username),10)=0) then
                'ищем мафию (есль ночь, ты мафия и ты не ещё не проверял)
                    people(Get_id_by_name(Username),10)=1
                    addq "/w " & Username & " " & Who_is_mafia()
                end if
            Case ".save"


                if (it_is_night=true AND people(Get_id_by_name(Username),2)=1 AND people(Str_to_num(DivideMessage(Message, 1)),1)>0 AND people(Get_id_by_name(Username),10)=0  AND CInt(Get_id_by_name(Username))<>CInt(Str_to_num(DivideMessage(Message, 1))) AND Trim(DivideMessage(Message, 1))<>"") then
                'доктор спасает  (есль ночь, ты доктор, твоя цель жива и ты  ещё не защищал и номер цели не равен твоему номеру)
                    people(Str_to_num(DivideMessage(Message, 1)),6)=1
                    people(Get_id_by_name(Username),10)=1
                    addq "/w " & Username & " ты зaщитил " & people(Str_to_num(DivideMessage(Message, 1)),0)
                end if
                if (it_is_night=false AND people(Get_id_by_name(Username),2)=2 AND people(Str_to_num(DivideMessage(Message, 1)),1)>0 AND people(Get_id_by_name(Username),10)=0  AND CInt(Get_id_by_name(Username))<>CInt(Str_to_num(DivideMessage(Message, 1))) AND Trim(DivideMessage(Message, 1))<>"") then
                'адвокат спасает  (есль не ночь, ты адвокат, твоя цель жива и ты  ещё не защищал)
                    people(Str_to_num(DivideMessage(Message, 1)),6)=1
                    people(Get_id_by_name(Username),10)=1
                    addq "/w " & Username & " ты зaщитил " & people(Str_to_num(DivideMessage(Message, 1)),0)
                end if
            Case ".check"
                if (it_is_night=false AND people(Get_id_by_name(Username),2)=3 AND people(Str_to_num(DivideMessage(Message, 1)),1)>0 AND people(Get_id_by_name(Username),10)=0 AND Trim(DivideMessage(Message, 1))<>"") then
                'мент проверяет  (есль не ночь, ты мент, твоя цель жива и ты  ещё не проверял
                    people(Get_id_by_name(Username),10)=1
                    addq "/w " & Username & " " & people(Str_to_num(DivideMessage(Message, 1)),0) & " ни ктo инoй, кaк " & Get_user_status(DivideMessage (Message, 1))
                end if

        End Select
    end if




    
    
    Select Case lcase(message)
        
        Case ".pingme"    
                
    End Select











if (Err.Number>0) then
AddChat vbGreen, "error in Event_WhisperFromUser " & Err.Number
Addq "/w " & master & " error in Event_WhisperFromUser " & Err.Number
end if    
On Error GoTo 0


End Sub

'//////////////////////////////////////////////////////////////////////////////////////
'// Fires when a user joins the channel.
'// Level will contain 0 for no-level Warcraft III players or non-Warcraft III products.
'// Message contains the user's PARSED statstring.
'// OriginalStatstring contains the user's UNPARSED statstring.

Sub Event_UserJoins(Username, Flags, Message, Ping, Product, Level, OriginalStatstring)

On Error Resume Next

    id1=Get_id_by_name(Username)
    if(id1>0) then
        If (people(id1,1)>0 AND people(id1,9)=1) then
            people(id1,9)=0

        end if
    end if    


if (Err.Number>0) then
AddChat vbGreen, "error in Event_UserJoins " & Err.Number
Addq "/w " & master & " error in Event_UserJoins " & Err.Number
end if    
On Error GoTo 0

End Sub

'////////////////////////////////////////////////////////////////////////////////////
'// Fires when a user leaves the channel.

Sub Event_UserLeaves(Username, Flags)

On Error Resume Next

    Kill_leaver(Username)
    If (classic_active=true AND classic_counter>0)    then
        Del_classic(Username)
    end if



if (Err.Number>0) then
AddChat vbGreen, "error in Event_UserLeaves " & Err.Number
Addq "/w " & master & " error in Event_UserLeaves " & Err.Number
end if    
On Error GoTo 0

End SUb

'/////////////////////////////////////////////////////////////////////////////
'// Fires when Battle.net updates a user's flags in the channel.

Sub Event_FlagUpdate(Username, NewFlags, Ping)

On Error Resume Next



if (Err.Number>0) then
AddChat vbGreen, "error in Event_FlagUpdate " & Err.Number
Addq "/w " & master & " error in Event_FlagUpdate " & Err.Number
end if    
On Error GoTo 0

End Sub


'// Fires after a successful login.

Sub Event_LoggedOn(Username, Product)

On Error Resume Next

    command botvars.username, "/cq", True
    Stop_game


if (Err.Number>0) then
AddChat vbGreen, "error in Event_LoggedOn " & Err.Number
Addq "/w " & master & " error in Event_LoggedOn " & Err.Number
end if    
On Error GoTo 0


End Sub

'////////////////////////////////////////////////////////////////////////////
'// Fires once for each user in the channel upon joining a channel.

Sub Event_UserInChannel(Username, Flags, Message, Ping, Product)

On Error Resume Next


if (Err.Number>0) then
AddChat vbGreen, "error in Event_UserInChannel " & Err.Number
Addq "/w " & master & " error in Event_UserInChannel " & Err.Number
end if    
On Error GoTo 0

End Sub

'//////////////////////////////////////////////////////////////////////////
'// Flags in this case stores the channel's flags.

Sub Event_ChannelJoin(ChannelName, Flags)

On Error Resume Next


if (Err.Number>0) then
AddChat vbGreen, "error in Event_ChannelJoin " & Err.Number
Addq "/w " & master & " error in Event_ChannelJoin " & Err.Number
end if    
On Error GoTo 0

End Sub

'///////////////////////////////////////////////////////////////////////////
'// Executes every X milliseconds, as set by using its .Interval property.

Sub scTimer_Timer()

On Error Resume Next


    if(game_active AND classic_counter>0 AND classic_active=true) then
    'если идёт время присоединения к классической игре
        if (classic_counter=classic_time AND max_players=0) then
        '(нет максимума игроков)
            for i=0 to 200
                classic_array(i)=""
            next
            classic_array_counter=0

            'в самом начале периода присоединения к игре
            ADDQ "/me Дoбpo пoжaлoвaть в MAФИЮ!!! (http://mafa.hotmail.ru)"

'            ADDQ "/me Bвeдитe кoмaнду '.join', чтoбы игpaть в игpу."
            
'    if ((players_joined<max_players AND max_players>0) OR (max_players=0)) then            
            ADDQ "/me У вac еcть " & classic_time & " ceк., чтoбы зaйти в игpу (ввeдитe '.join')."
            

        end if


        if (classic_counter=600 AND max_players>0) then
        '(установлен максимума игроков)
            for i=0 to 200
                classic_array(i)=""
            next
            classic_array_counter=0

            'в самом начале периода присоединения к игре
            ADDQ "/me Дoбpo пoжaлoвaть в MAФИЮ!!! (http://mafa.hotmail.ru)"            
            ADDQ "/me ПАРАМЕТРЫ: мaкс. игpoкoв - " & max_players & "; макc. вpeмя oжидaния - 10 минут."
            ADDQ "/me Bвeдитe кoмaнду '.join', чтoбы приcoeдинитьcя к игpе."

        end if





        if (players_joined>=max_players AND max_players>0 AND classic_counter>65 ) then
        'если набрали нужное количество игроков
            classic_counter=65
        end if


        if(((classic_counter) Mod 60 = 0) AND (max_players>0)) then
            'каждые 60 сек
            AddQ "/me " & classic_counter/60 & " мин. дo нaчaлa игpы. (" & players_joined & " из " & max_players & " игроков в игpe)"      
        end if
        if(((classic_counter-5) Mod 20 = 0) AND (classic_counter<60)) then
            'каждые 20 сек
            AddQ "/me " & classic_counter & "ceк"    
        end if
    
        if (classic_counter=1) then
            'в конце  периода присоединения к игре
            ADDQ "/me Игpa MAФИЯ нaчaлacь..."
            
            Give_classic_roles
            AddQ "/me B пpoфилe бoтa " & BotVars.Username & " вы нaйдётe кoмaнды игpы."
            Victory_test

        end if

        classic_counter=classic_counter-1
    end if
    if(game_active AND classic_counter=0) then
    'работает только когда игра запущена
        
        if (time_counter>0) then
            if (it_is_night=true) then
            'тут всё что происходит ночью
                if(time_counter=night_time) then
                'в самом начале ночи
                    AddQ "/me .....Hacтaлa HOЧЬ..."
'                    AddQ "/me зaйдитe в пpoфиль бoтa " & BotVars.Username & " чтoбы пocмoтpeть кoмaнды игpы."                    

                    Alive_players

                    
                    'AddQ "/me <MAFIA> - whisper(/w) " & BotVars.Username & " '.vote NUM' to vote for killing of player number NUM."
                    'AddQ "/me  <MAFIA> - whisper(/w) mafiabot '.boss' to find mafia-boss"
                    'AddQ "/me  <MANIAC> - whisper(/w) mafiabot '.kill NUM' to kill player number NUM."
                    'AddQ "/me  <DOCTOR> - whisper(/w) mafiabot '.save NUM' to protect player number NUM."
                    

                end if
                
                if((time_counter-1) Mod 60 = 0) then
                    AddQ "/me :" & time_counter-1 & "ceк"     
                end if
                if((time_counter-1) Mod 30 = 0) then
                'каждые 30 сек ночью
                    no_end=false 'если false то надо закончить раунд а если true то не надо
                    for i=1 to (people_quantity)
                        if ((people(i,1)=2 AND people(i,3)=0) OR (people(i,1)=1 AND people(i,2)=1 AND people(i,10)=0) OR (people(i,1)=3 AND people(i,10)=0) ) then
                            'если кто-то из мафии не голосовал, доктор не защищал, маньяк не убивал
                            no_end=true
                        end if
                    next
                    if (no_end=false) then
                        time_counter=1
                        no_end=true
                    end if
                end if
            else
            'тут всё что происходит днём
                if(time_counter=day_time) then
                'в самом начале дня
                    AddQ "/me .....Hacтaл ДEHЬ..."
                    
'                    AddQ "/me зaйдитe в пpoфиль бoтa " & BotVars.Username & " чтoбы пocмoтpeть кoмaнды игpы."
                    Alive_players
                                        
                    'AddQ "/me  <ALL> - tell '.vote NUM' to vote for the death penalty of player number NUM."
                    'AddQ "/me  <LAWYER> - whisper(/w) mafiabot '.save NUM' to save player NUM from death penalty."
                    'AddQ "/me  <POLICEMAN> - whisper(/w) mafiabot '.check NUM' to check player number NUM if he is criminal."

                end if
                
                if((time_counter-1) Mod 60 = 0) then
                'каждые 60 сек
                    AddQ "/me " & time_counter-1 & "ceк"    
                end if
                if((time_counter-1) Mod 30 = 0) then
                'каждые 30 сек днём
                    no_end=false 'если false то надо закончить раунд а если true то не надо
                    for i=1 to (people_quantity)
                        if ((people(i,1)>0 AND people(i,3)=0)  ) then
                            'если кто-то не голосовал
                            no_end=true
                        end if
                    next
                    if (no_end=false) then
                        time_counter=1
                        no_end=true
                    end if
                end if
            end if

            time_counter=time_counter-1

        else
            if (it_is_night=true) then
            'когда кончается ночь
                Vote_result
                Death_results
                Victory_test
                time_counter=day_time
                it_is_night=false
            else
            'когда кончается день
                Vote_result
                Death_results
                Victory_test
                time_counter=night_time
                it_is_night=true
            end if    
        
        end if        





    end if
    '/////////////////pereconnect
    if ((reconnectTimer=20) AND (ssc.IsOnline()=false)) then
        AddChat vbGreen, "Connect now"
        command botvars.username, "/cq", True
        Stop_game
        Connect()
        Connect()
    end if

    if ((ssc.IsOnline()=false) AND (reconnectTimer=0)) then
        reconnectTimer=1200
    else
        if (ssc.IsOnline()=true) then
            reconnectTimer=0
        end if
    end if
    
    if (reconnectTimer>0) then

        if ((reconnectTimer mod 100 )=0) then
            AddChat vbGreen, reconnectTimer
        end if
        reconnectTimer=reconnectTimer-1
    end if

    '////////////промежуточное сообщение
    if (game_active=false) then
        if (idle_message_counter=0) then
            Addq idle_message
            idle_message_counter=idle_time
        end if
        if (idle_message_counter>0) then
            idle_message_counter=idle_message_counter-1
        end if
    end if





if (Err.Number>0) then
AddChat vbGreen, "error in scTimer_Timer " & Err.Number
Addq "/w " & master & " error in scTimer_Timer " & Err.Number
end if    
On Error GoTo 0


End Sub

'////////////////////////////////////////////////////////////////////////////////
'// Executes after the user presses ENTER in the Send box on the bot. Text will always be processed by the bot and sent to battle.net before arriving here.

Sub Event_PressedEnter(Text)

On Error Resume Next


if (Err.Number>0) then
AddChat vbGreen, "error in Event_PressedEnter " & Err.Number
Addq "/w " & master & " error in Event_PressedEnter " & Err.Number
end if    
On Error GoTo 0

End Sub

'///////////////////////////////////////////////////////////////////////////////////
'// Executes when the bot recieves a Profile return from the server. KeyName will be one of the following:
    ' Profile\Sex
    ' Profile\Location
    ' Profile\Description
'// KeyValue will contain the value of that profile key as a string.

Sub Event_KeyReturn(KeyName, KeyValue)

On Error Resume Next


if (Err.Number>0) then
AddChat vbGreen, "error in Event_KeyReturn " & Err.Number
Addq "/w " & master & " error in Event_KeyReturn " & Err.Number
end if    
On Error GoTo 0

End Sub

'////////////////////////////////////////////////////////////////////////////////////
'// Executes when the bot is closed. You can use this sub to write things to disk before the bot shuts down.

Sub Event_Close()

On Error Resume Next


if (Err.Number>0) then
AddChat vbGreen, "error in Event_Close " & Err.Number
Addq "/w " & master & " error in Event_Close " & Err.Number
end if    
On Error GoTo 0

End Sub
Ответ


Возможно похожие темы ...
Тема Автор Ответы Просмотры Последний пост
  Создание кланов на PvPGN YAphets 1 3,168 10-28-2023, 03:16 AM
Последний пост: Azzlaer
  PvPGN Server WC3 shock666 3 1,021 10-28-2023, 03:16 AM
Последний пост: Azzlaer

Перейти к форуму:


Пользователи, просматривающие эту тему: 2 Гость(ей)