Results 1 to 7 of 7
  1. #1
    Senior Member
    Join Date
    Nov 2011
    Location
    Germany
    Posts
    154

    Insane Limits - Report Script via Pushbullet (v1.1)

    Report Script via Pushbullet for Insane Limits
    Pushbullet is a free-service! Visit: https://www.pushbullet.com for download

    Functions:
    - Push notification on all devices (Android, iOS, Blackberry, Windows, MacOS, Linux and more)
    - Player can write only a part of playername to report him
    - Get report as private message or send it to a channel for all admins
    - Optional: automatic pbscreenshot

    Command:
    !report <part of playername> <reason>

    Sample:
    You will report a player with the name "Klabustabeere" and two player online with the names "Klabustabeere" and "Klabautermann"

    !report klab reason (not work) -> Multiple players match the target name (klab), try again!
    !report klabu reason (work)
    !report beere reason (work)
    !report klapu reason (not work) -> No such player name matches (klapu)
    !report klabustabeere (not work) -> No reason


    SETUP LIMIT#1
    limit_evaluation: OnAnyChat
    limit_first_check: Expression
    limit_first_check_code: paste the CODE#1 here

    CODE#1
    Code:
    (Regex.Match(player.LastChat, @"!report?", RegexOptions.IgnoreCase).Success)
    ENABLE SECOND CHECK
    limit_second_check: Code
    limit_second_check_code: paste the CODE#2 here

    CODE#2:
    Code:
    // Insane Limits - Pushbullet Report Script v1.1
    // Command: !report <part of playername> <reason>
    
    // Set your Pushbullet Key
    String pbKey = "keystring";
    
    // Set Pushbullet communication way
    // 1 = send as private message
    // 2 = send to channel
    int pbComWay = 1;
    
    // Set Pushbullet channel (only when communication way = send to channel)
    String pbChannel = "Channelname";
    
    // Set Servername // Serveridentification
    String serverName = "Servername";
    
    // Automatic PBScreenshot from reportet player
    // 1 = activated
    // 0 = deactivated
    int pbScreen = 1;
    
    
    // Don't edit
    String playerName = null;
    String playerMessage = null;
    String reportName = null;
    String reportReason = null;
    String pbString = null;
    int foundPlayer = 0;
    Match regexResult = null;
    
    Match regexMatch = Regex.Match(player.LastChat, @"!report\s+([^\s]+)\s+([^.*]+)", RegexOptions.IgnoreCase);
    
    if (regexMatch.Success) {
    	regexResult = regexMatch;
    } else {
    	playerMessage = "Error! Correct command: !report <part of playername> <reason>";
    	plugin.SendPlayerMessage(player.Name, playerMessage);
    	plugin.SendPlayerYell(player.Name, playerMessage, 10);
    	return false;
    }
    
    List<PlayerInfoInterface> allPlayer = new List<PlayerInfoInterface>();
    allPlayer.AddRange(team1.players);
    allPlayer.AddRange(team2.players);
    if (team3.players.Count > 0) allPlayer.AddRange(team3.players);
    if (team4.players.Count > 0) allPlayer.AddRange(team4.players);
    
    reportName = regexResult.Groups[1].Value;
    foreach (PlayerInfoInterface p in allPlayer) {
        if (Regex.Match(p.Name, reportName, RegexOptions.IgnoreCase).Success) {
            ++foundPlayer;
    		playerName = p.Name;
        }
    }
    if (foundPlayer == 0) {
    	playerMessage = "No such player name matches (" + reportName + ")";
        plugin.SendPlayerMessage(player.Name, playerMessage);
    	plugin.SendPlayerYell(player.Name, playerMessage, 10);
        return false;
    } else if (foundPlayer > 1) {
    	playerMessage = "Multiple players match the target name (" + reportName +"), try again!";
        plugin.SendPlayerMessage(player.Name, playerMessage);
    	plugin.SendPlayerYell(player.Name, playerMessage, 10);
        return false;
    } else if (foundPlayer == 1) {
    	if (pbScreen == 1) plugin.ServerCommand("punkBuster.pb_sv_command", "PB_SV_GetSs \"" + reportName + "\"");
    	reportReason = regexResult.Groups[2].Value;
        try {
    		WebRequest request = WebRequest.Create("https://api.pushbullet.com/v2/pushes");
    		request.Method = "POST";
    		request.Headers.Add("Authorization", "Bearer " + pbKey);
    		request.ContentType = "application/json; charset=UTF-8";
    		if (pbComWay == 1) {
    			pbString = "{\"type\": \"note\", \"title\": \"Report for server (" + serverName + ")\", \"body\": \"Reported_from:\\n" + player.Name + "\\n\\nReported_player:\\n" + playerName + "\\n\\nReason:\\n" + reportReason + "\"}";
    		} else if (pbComWay == 2) {
    			pbString = "{\"type\": \"note\", \"title\": \"Report for server (" + serverName + ")\", \"body\": \"Reported_from:\\n" + player.Name + "\\n\\nReported_player:\\n" + playerName + "\\n\\nReason:\\n" + reportReason + "\", \"channel_tag\": \"" + pbChannel + "\"}";
    		}
    		byte[] byteArray = Encoding.UTF8.GetBytes(pbString);
    		request.ContentLength = byteArray.Length;
    		Stream dataStream = request.GetRequestStream();
    		dataStream.Write(byteArray, 0, byteArray.Length);
    		dataStream.Close();
    		plugin.ConsoleWrite("Received a report from " + player.Name);
    		playerMessage = "Thanks, we have received your report!";
    		plugin.SendPlayerMessage(player.Name, playerMessage);
    		plugin.SendPlayerYell(player.Name, playerMessage, 10);
    	} catch (Exception e) {
    		plugin.ConsoleWrite("Error: " + e);
    		playerMessage = "Plugin error! Please try again later.";
    		plugin.SendPlayerMessage(player.Name, playerMessage);
    		plugin.SendPlayerYell(player.Name, playerMessage, 10);
    	}
    }
    
    return false;
    --------------------------------------------

    v1.1 (24-01-2016)
    - added an expression (CODE#1)
    - fixed a bug (CODE#2)

    v1.0 (24-01-2016)
    - original version
    Last edited by Grovax; 24-01-2016 at 18:55.

  2. #2
    Nice! Glad to see there will be a way for people to have this outside of AdKats.

    This functionality is being integrated with AdKats per a request submitted on the 15th of December.

    https://github.com/AdKats/AdKats/issues/846
    ____

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Location
    Alabama
    Posts
    253
    Which one do I need to download, Grovax? I want it to yell to me while in game playing.

    Thanks!

    I know how to add new limit and all that jazz.

  4. #4
    Senior Member
    Join Date
    Nov 2011
    Location
    Germany
    Posts
    154
    Quote Originally Posted by ColColonCleaner View Post
    Nice! Glad to see there will be a way for people to have this outside of AdKats.

    This functionality is being integrated with AdKats per a request submitted on the 15th of December.

    https://github.com/AdKats/AdKats/issues/846
    Thanks ColColonCleaner, good to know

    Quote Originally Posted by Mamba334 View Post
    Which one do I need to download, Grovax? I want it to yell to me while in game playing.

    Thanks!

    I know how to add new limit and all that jazz.
    A ingame yell functions i actually not included, but its a good idea. Otherwise you can download the windows client (downloadlink), in setting you can activate the notification with popup and sound.

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Location
    Alabama
    Posts
    253
    Thanks!

  6. #6
    Senior Member
    Join Date
    Nov 2011
    Location
    Germany
    Posts
    154
    New version available (v1.1)

    v1.1 (24-01-2016)
    - added an expression (CODE#1)
    - fixed a bug (CODE#2)

  7. #7
    Senior Member
    Join Date
    Jul 2014
    Location
    Alabama
    Posts
    253
    Great! I'll give this a go tonight.

 

 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •