1. Cerber0s simple reason why I have a [/url] in mine is because I'm idiot and did not notice the typo

    It should be "uploadpage": "h**p://fps101.com/stats/receive/deathmessages.php",
     
  2. I had a player who had an '%' in their name and it caused the 'Invalid use of % in replacement string' error because, of course '%' is an escape character in Lua. I tried changing the BuildDeathMessage function, but I'm not sure if this will do the trick.
    I'm not sure exactly where the error was thrown, so I'm attempting to gsub it after the string is built in the hopes that the error was thrown when it attempts to print or broadcast the message. If it was thrown in the for loop, then this wouldn't work of course.

    Code:
    function PLUGIN:BuildDeathMessage(tags, str)
       if(not str) then print("Error while making Death message for " .. tags.killer) return end
       local customMessage = str
       for k, v in pairs(tags) do
         customMessage = string.gsub(customMessage, "@{".. k .. "-}", v )
       end
       customMessage = customMessage:gsub("%%", "%%%%")
       print(customMessage)
       if(self.Config.Settings.mysql) then
         self:SendToMysql(tags)
       end
       global.ConsoleSystem.Broadcast("chat.add \"" .. self.Config.ChatName .. "\" \"" .. customMessage .. "\"")
    end
    
     
  3. You need to modify the value thats being replaced into the message in the loop, otherwise it won't help. Basically you need to check the replacement value for % before its's replaced.
    Code:
       for k, v in pairs(tags) do
         v:gsub("%%", "%%%%")
         customMessage = string.gsub(customMessage, "@{".. k .. "-}", v )
       end
     
  4. I thought of that while I was going to bed last night. "Why didn't I just gsub the value while looping through the key/value pairs?" LOL. Funny how the answer comes to us when we're not focused on the problem sometimes. Thanks Mughisi! I think there needs to be a check for backslashes too. I've seen people with names like "\n\n" which I think would cause a problem too. Anything other than '%' and '\' you can think of that might need to be escaped?
     
  5. Any other character should not have any influence on the pattern matching however the "\n" will result in a line-break so it could just be replaced by nothing to solve this.
     
  6. True, but in this case that is the characters name, so their name would not appear at all. If backslashes were escaped like
    Code:
    for k, v in pairs(tags) do
         v:gsub("%%", "%%%%")
          :gsub("\\", "\\\\")
         customMessage = string.gsub(customMessage, "@{".. k .. "-}", v )
    end
    
    that would eliminate the problem of all backslashed escaped characters (\n, \a, \b, etc.), right?

    OH! I also just remembered I had an issue with quotes in character names too. So to go even further...
    Code:
    for k, v in pairs(tags) do
         v:gsub("%%", "%%%%")
          :gsub("\\", "\\\\")
          :gsub("\"", "\\\"")
         customMessage = string.gsub(customMessage, "@{".. k .. "-}", v )
    end
    
    Would that work? The characters wouldn't affect the pattern match, but they might not display correctly. In that case should they be replaced after the string is built? Sorry for all the noob questions. LOL
     
  7. For the quotes we have QuoteSafe(), regarding the \n and stuff, all you would be doing is looking for \\ and replacing it by \\\\. You're probably just want to remove them or look for specific escaped characters and replace those with nothing, a.k.a. remove them.
     
  8. I gotcha. I tried adding QuoteSafe at one point, but that ended up being a nightmare. I ended up with strings like "\\\\\\\\\\\\\\\Mr. Bubbles killed a boar(rifle) with a hit to their head at 50m\\\\\\\\\\" or something like that. It would show in the server console, but not in the global broadcast. Just fixing the '%' for now is good. Reneb has the skills for the rest if he feels its necessary. Thanks for your help, Mughisi.
     
  9. The QuoteSafe is something you want to use after you formed the message and before sending the message as the function to send the message requires the quotes to separate the chatname from the message. Basically it will just escape all the quotes it encounters so it shouldn't really mess up anything.
     
  10. I think I was trying to do it in the loop which is why it ended up being horrendous. Took me a while to get the hang of the global broadcast function. All the quotes and manual escaping can be a bit tricky.
     
  11. You just need to think step by step, think like the code ;)
     
  12. Hey guys, is someone able to help with this. For the life of me i cant get the messages to appear on my site.

    So this is what i have:
    The points etc lay out is there but no player info etc shows up

    <?php
    $db_name = 'rust_deathmessages';
    $db_user = 'rust_*******';
    $db_pass = '*********';
    $db_host = 'localhost';

    ?>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/datatable.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/datatable.min.css">
    <style type="text/css">

    (CSS Below)
    <?php
    $db_name = 'rust_deathmessages';
    $db_user = 'rust_*******';
    $db_pass = '*********';
    $db_host = 'localhost';

    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/datatable.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/datatable.min.css">
    <style type="text/css">

    (CSS Below)
    <meta http-equiv="Content-Type" content="text/html; charset=UTF- 8">
    <?php

    $db_name = 'rust_deathmessages';
    $db_user = 'rust_*******';
    $db_pass = '*********';
    $db_host = 'localhost';
    $key = "******";
    try
    {
    $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
    $bdd = new PDO("mysql:host=".$db_host.";dbname=".$db_name,$db_user,$db_pass, $pdo_options);
    }
    catch (Exception $e)
    {
    echo 'Error : ' . $e->getMessage();
    return;
    }
    if(isset($_GET['key']) && $_GET['key'] == $key)
    {
    $type = $_GET['type'];
    $bodypart = (isset($_GET['bodypart'])?$_GET['bodypart']:"");
    $killer = (isset($_GET['killer'])?Secure($_GET['killer']):"");
    $killer_id = (isset($_GET['killerid'])?$_GET['killerid']:"");
    $killed = (isset($_GET['killed'])?Secure($_GET['killed']):"");
    $killed_id = (isset($_GET['killedid'])?$_GET['killedid']:"");
    $weapon = (isset($_GET['weapon'])?$_GET['weapon']:"");
    $distance = (isset($_GET['distance'])?$_GET['distance']:"");
    $date = date("H:i:s d.m.Y");
    $bdd->exec("INSERT INTO `deathmessages` (`killer`, `killed`, `weapon`, `distance`, `time`,`bodypart`,`killer-id`,`killed-id`,`type`) VALUES ( '{$killer}', '{$killed}', '{$weapon}', '{$distance}', '{$date}','{$bodypart}', '{$killer_id}', '{$killed_id}', '{$type}')");
    return;
    }

    function Secure($input)
    {
    $input = stripslashes($input);
    $input = str_replace("#","",$input);
    return $input;
    }

    ?>
    {
    "playerDeathMessage": "@{killer} killed @{killed} (@{weapon}) with a hit to their @{bodypart} at @{distance}m",
    "Settings": {
    "animalkills": true,
    "animaldeaths": true,
    "players": true,
    "mysql": true
    },
    "SuicideDeaths": true,
    "deathByEntityWhileSleepingMessage": "@{killed} was eaten alive while sleeping by a @{killer}",
    "Mysql": {
    "uploadpage": "http://www.ausnzrust.com/stats/stats.php",
    "key": "*******",
    "naturalcauses": true,
    "pve": true,
    "pvp": true
    },
    "ChatName": "Death",
    "wildlifeDeathMessage": "@{killer} killed a @{killed} (@{weapon}) with a hit to their @{bodypart} at @{distance}m",
    "SuicideDeathsMessage": "@{killed} commited suicide",
    "naturalcausesdeathmessages": {
    "Radiation": "@{killed} got irradiated.",
    "Poison": "@{killed} was poisoned.",
    "Bleeding": "@{killed} bled to death.",
    "Heat": "@{killed} became a dead human torch.",
    "Generic": "@{killed} just died.",
    "Thirst": "@{killed} was too thirsty and died.",
    "Bite": "@{killed} was bitten to death.",
    "Fall": "@{killed} fell and died.",
    "Cold": "@{killed} froze to death.",
    "BluntTrauma": "@{killed} died from a blunt trauma.",
    "Slash": "@{killed} got slashed.",
    "Bullet": "@{killed} died from a bullet.",
    "Suicide": "@{killed} committed suicide.",
    "Hunger": "@{killed} died from hunger.",
    "Drowned": "@{killed} thought he could breathe under water."
    },
    "naturalcausesdeath": true,
    "deathByEntityMessage": "@{killed} has died by a @{killer}",
    "playerDeathWhileSleepingMessage": "@{killer} murdered @{killed} while sleeping with a @{weapon} at @{distance}m"
    }
    Database setup
    [​IMG]
     
    Last edited by a moderator: Dec 30, 2014
  13. Your json file is pointing to stats.php but deathmessages.php handles the data.
     
  14. I just changed upload to "http://ausnzrust.com/stats/receive/deathmessages.php" but it still doesnt seem to be showing anything.

    Ive had the plugin installed for awhile but have only just decided to setup the website side.
    To make changes I'm only doing oxide.reload, does this require a full server restart? even if ive had the plugin installed for awhile?
     
  15. Reloading should be fine, maybe webrequests are bugging or perhaps blocked by your GSP, perhaps try another plugin that uses webrequests to see if that works.
     
  16. hmm it seemed to work back on legacy when i had a chat being sent to the site. Weird.
    Do you know of any other webrequest plugins off the top of your head?
    [DOUBLEPOST=1419930320][/DOUBLEPOST]is there a way to post a console message if webrequest is sending?
     
  17. Think there is a country blocker or something that uses a webrequest when someone connects. Also check for errors in your log and on your webserver.
     
  18. Cheers Mughisi, I'll give the country blocker ago and see what happens!
    [DOUBLEPOST=1419931300][/DOUBLEPOST]
    Interesting, so i added country blocker and blocked NZ (New Zealand where im from) it still let me in.
    Looks like webrequest could be the issue!
     
  19. Webrequests are rfucked, nothing much can be done until they are fixed
     
  20. only way I could get it to start was restarting the server. sometimes it stops working out of the blue and requires a reboot also
    some reason animal kills doesn't work. must be bugged cause pve is set to true...