FAQ  •  Register  •  Login

BFLogBot

<<

Fordcars

User avatar

Posts: 1016

Joined: Fri Apr 20, 2012 3:51 pm

Location: Some city, somewhere

Post Wed Apr 03, 2013 6:17 pm

BFLogBot

Sorry, I was bored again :/

This bot will log everything said in chat. Make sure that you create a file called "bflog.txt" and write the path to that file in the code, where it says so :roll:

Examples:
  Code:
file = io.open("/users/BitfighterRocks/DesktopFolder/bflog.txt", "a+")

file = io.open("C:/Documents and Settings/BF/desktop/bflog.txt", "a+")

file = io.open("/usr/BF/desktop/bflog.txt", "a+")


Happy bitting!

BOT CODE:
  Code:
---------BFLogBot
---------by fordcars


function getName() -- Called once
    return("BFLogBot")
end

function main() -- This is the first code ran, after loose code
    playerShip = nil

    subscribe(Event.MsgReceived)

    file = nil

    file = io.open("ENTER TXT PATH HERE", "a+")
    file:write("---------------------------------- \n")
    file:close()
end

function onMsgReceived(message, player)

    file = io.open("ENTER TXT PATH HERE", "a+")

    if (player:getName() == nil) then
        file:write("UNKNOWN: " .. message .. "\n")
        file:close()
        return
    else
        playerShip = player:getName()
        file:write(playerShip .. ": " .. message .. "\n")
        file:close()
        return
    end
end


 
Last edited by Fordcars on Wed Apr 03, 2013 6:29 pm, edited 1 time in total.
skybax: Why is this health pack following me?
bobdaduck: uh, it likes you.
<<

raptor

Posts: 1046

Joined: Mon Oct 11, 2010 9:03 pm

Post Wed Apr 03, 2013 6:25 pm

Re: BFLogBot

This is awesome!
<<

Fordcars

User avatar

Posts: 1016

Joined: Fri Apr 20, 2012 3:51 pm

Location: Some city, somewhere

Post Wed Apr 03, 2013 6:31 pm

Re: BFLogBot

Thanks!
skybax: Why is this health pack following me?
bobdaduck: uh, it likes you.
<<

watusimoto

Site Admin

Posts: 1558

Joined: Tue Feb 23, 2010 7:07 pm

Location: Quartz's mom's house

Post Thu Apr 04, 2013 8:21 am

Re: BFLogBot

I think this might be better as a levelgen script, so people can't kill the logbot!
<<

Fordcars

User avatar

Posts: 1016

Joined: Fri Apr 20, 2012 3:51 pm

Location: Some city, somewhere

Post Thu Apr 04, 2013 4:10 pm

Re: BFLogBot

haha yeah, well this was a test for using external files...
But I can't get levelgens to work, probably need a newer Bitfighter.
skybax: Why is this health pack following me?
bobdaduck: uh, it likes you.
<<

amgine

Posts: 1399

Joined: Thu Apr 19, 2012 2:57 pm

Post Mon Apr 08, 2013 8:22 pm

Re: BFLogBot

actually this could be helpful for reporting bad players but should be off screen auto running as a option not a bot......
Bitfighter Forever.
<<

Little_Apple

User avatar

Posts: 839

Joined: Sat Jun 11, 2011 12:31 pm

Location: Zanzibar Land

Post Wed Apr 10, 2013 3:00 pm

Re: BFLogBot

edited version that runs as a levelgen:
  Code:
---------BFLogBot
---------by fordcars
---------edited by that handsome devil Little_Apple

function main() -- This is the first code ran, after loose code
    playerShip = nil

    subscribe(Event.MsgReceived)

    file = nil

    file = io.open("PUT PATH HERE", "a+")
    file:write("---------------------------------- \n")
    file:close()
end

function onMsgReceived(message, player)

    file = io.open("PUT PATH HERE", "a+")

    if (player:getName() == nil) then
        file:write("UNKNOWN: " .. message .. "\n")
        file:close()
        return
    else
        playerShip = player:getName()
        file:write(playerShip .. ": " .. message .. "\n")
        file:close()
        return
    end
end


 
Hee-ho!
<<

Fordcars

User avatar

Posts: 1016

Joined: Fri Apr 20, 2012 3:51 pm

Location: Some city, somewhere

Post Wed Apr 10, 2013 3:01 pm

Re: BFLogBot

handsome devil :twisted:
skybax: Why is this health pack following me?
bobdaduck: uh, it likes you.
<<

karamazovapy

Posts: 1567

Joined: Tue Feb 23, 2010 7:52 pm

Post Thu Jul 25, 2013 3:02 am

Re: BFLogBot

Neat idea.
<<

watusimoto

Site Admin

Posts: 1558

Joined: Tue Feb 23, 2010 7:07 pm

Location: Quartz's mom's house

Post Thu Jul 25, 2013 7:20 am

Re: BFLogBot

It would be better not to open and close the file with each write... ideally, you'd open it once when the script is run, and we'd have an onShutdown() method that gets run when the script is terminating that would close the file.

That would be far more efficient.
<<

Fordcars

User avatar

Posts: 1016

Joined: Fri Apr 20, 2012 3:51 pm

Location: Some city, somewhere

Post Wed Jul 31, 2013 11:16 am

Re: BFLogBot

Hehe, yeah :p
skybax: Why is this health pack following me?
bobdaduck: uh, it likes you.

Return to Bots

Who is online

Users browsing this forum: No registered users and 1 guest

cron