Jump to content

TCP Help?


 Share

Recommended Posts

So my program is an "Admin Bot" for Soldier of Fortune 2. When Players "report" another player while in game, It logs thier Id, and the reason they were reported. When a player has been reported 3 times, I want it to send an admin running the program a message saying that they are needed in the server, but have no clue how to do that.

My guess would be to use TCP but have to clue how to make it work, any help :unsure:

Func reportAdd()
$kill = IniRead("demo/MP/AdminBot/Reports.ini", "ID: " & $userName, $reason,0)
$kills = ($kill + 1)

$totalReport = IniRead("demo/MP/AdminBot/Reports.ini", "ID: " & $userName, "Total Reports ",0)
$totalReports = ($totalReport + 1)
IniWrite("demo/MP/AdminBot/Reports.ini", "ID: " & $userName, $reason, $kills)
IniWrite("demo/MP/AdminBot/Reports.ini", "ID: " & $userName, "Total Reports ", $totalReports)

If $totalReports = 3 Then
    _KickReportWarn()
Elseif $totalReports = 5 Then
    _KickReport()
Else
printReport()
EndIf
EndFunc

Func printReport()
    $s_FileName = _TempFile("demo/MP/", "vPlaybind", ".cfg")
    FileWrite("demo/MP/vPlaybind.cfg",'rcon "')
    FileWrite("demo/MP/vPlaybind.cfg","^3[^3AdminBot^3]^7: ID: ^3" & $userName & " ^7has been reported for: ^3" & $reason)
    FileWrite("demo/MP/vPlaybind.cfg",'"')
    Sleep(1755)
    Send("{Home}")
    FileDelete("demo/MP/vPlaybind.cfg")
EndFunc

Func _KickReportWarn()
    $s_FileName = _TempFile("demo/MP/", "vPlaybind", ".cfg")
    FileWrite("demo/MP/vPlaybind.cfg",'rcon "')
    FileWrite("demo/MP/vPlaybind.cfg","^3[^3AdminBot^3]^7: ID: ^3" & $userName & " ^7has been reported ^33 ^7or more times.")
    FileWrite("demo/MP/vPlaybind.cfg",'"')
    Sleep(1755)
    Send("{Home}")
    FileDelete("demo/MP/vPlaybind.cfg")
    _SendAdmin()
EndFunc


Func _SendAdmin()
    $s_FileName = _TempFile("demo/MP/", "vPlaybind", ".cfg")
    FileWrite("demo/MP/vPlaybind.cfg",'rcon "')
    FileWrite("demo/MP/vPlaybind.cfg","^3[^3AdminBot^3]^7: ID: ^3" & $userName & " ^7has been ^3Reported^7 to an Admin.")
    FileWrite("demo/MP/vPlaybind.cfg",'"')
    Sleep(1755)
        ;This is where i would add the TCP message or whatever I need to do.
    _GetStatus()
EndFunc
Link to comment
Share on other sites

But this isn't a game automation. For example if someone is constantly swearing in our server, I want to message an admin that there is someone doing it. Then the admin will go into the game and check it out. So the Bot is just reading logs and if something it sees is wrong it flags an admin. :> Thats it :unsure:

P.S - The name doesn't really mean its a bot. Basicly the program is for our admins. ITs annoying to sit and watch the server 24/7 when they have other shit they could be doing. This just messages them when they are needed.

Edited by Mumms
Link to comment
Share on other sites

I assume you're thinking of having some kind of client program the admins would run to connect and wait for messages?

It wouldn't have to be a very complex program if all it has to do is connect and wait for notifications, but you then would have to consider how to handle things server side if no admins are connected. Some kind of notice queue that gets dumped on the next admin to connect I imagine.

You'll need to check out the TCPListen() and TCPAccept() functions for server side. Also TCPConnect() and TCPRecv() for client side (at the least). Reviewing all of the TCP functions and their examples should really get you started.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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