Tutorials

Tutorials

These are tutorials for doing various things with data output by Sendere. If any of these don't work, please post a copy of the response and a copy of the listener in the comments box ON THIS TUTORIALS PAGE.

Sending E-Mails to Server Staff When Someone Is Kicked

This involves simply adding the following lines to your listener:

<?php
$subject = $_GET[ "c" ] . "was naughty!"; //The subject line in the message
$message = $_GET[ "c" ] . "has been kicked from the server. " . $_GET[ "c" ] . "was kicked for the following reason:
" . $_GET[ "b" ]; //Set the message to be sent.
$headers = 'From: "A Super-Amazing Admin" <[email protected]>;
MIME-Version: 1.0;
Content-Type: text/plain; charset=ISO-8859-1'; //Headers for the message. The only one that needs to be messed with is From, and, if you are changing the message to be HTML, Content-Type (You would change it to text/html).

$emails = file( "staffEmails.txt" ); //Get the list of emails to send to. One email permitted per line, and just the email. No fancy formatting.
foreach( $emails as $email ){
    mail( $email, $subject, $message, $headers ); //Sends the e-mail.
}
?>

This may not work on all web servers, but it should work on most.

Tallying peoples' deaths

This one involves a little more, but is equally as easy as the last one. Before you copy and paste the below code into your listener, you must create a new folder called "Deaths" in the same directory as your listener, and make sure that the listener has permission to write to it. Then, copy and paste this into your listener:

<?php
$file = "Deaths/" . $_GET[ "c" ];
if( @file_exists( $file ) ){
    $deaths = file_get_contents( $file );
    $deaths = str_replace( "\r", "\n", "\r\n", "", $deaths ); //Remove line breaks, if present.
    $newDeaths = intval( $deaths ) + 1; //Increase the number of deaths by one.
    file_put_contents( $file, $newDeaths );
} else {
    file_put_contents( $file, "1" );
}
?>

If you have a cookie set to a person's username, you can use this as a reader to the person about his/her death count:

<?php
if( @isset( $_COOKIE[ "user" ] ){
    if( @file_exists( "Deaths/" . $_COOKIE[ "user" ] ) ){
        echo "You have died " . file_get_contents( "Deaths/" . $_COOKIE[ "user" ] ) . " times.";
    } else {
        echo "You haven't died... yet. Watch your back!";
    }
} else {
    echo "Please log in to see how many times you have died!";
}
?>

Show What Everyone On The Server Is Talking About

This one is very simple. Simply copy and paste the following code into your listener:

<?php
if( @$_GET[ "a" ] == "AsyncPlayerChat" ){
    file_put_contents(  "chatLog.txt", "\n" . "<" . $_GET["c"] . "> " . str_replace( "<[;:]>", " ", $_GET["b"] ), FILE_APPEND );
}
?>

Then, you could use Ajax (Part of JavaScript) to read the file out to the website's viewer. I, personally, prefer to use the Ajax function in jQuery. This would not be on the listener file, but on whichever file you are using to display chat. To use the code that I have below, remove the ", FILE_APPEND" from the code above. The following JavaScript code assumes that you already have jQuery:

setInterval(
    function(){
        $.ajax(
            {
                url: "chatLog.txt",
                success: function(data){
                    document.getElementById( "chatOutput" ).innerHTML = data + document.getElementById( "chatOutput" ).innerHTML
                },
                error: function(data){
                    document.getElementById( "chatOutput" ).innerHTML = "Oh no! There has been an error! Please check back later."
                }
            }
        )
    },
    10
)

Comments

Posts Quoted:
Reply
Clear All Quotes