[ADMN] Redeem v1.5 - Transfer items and iConomy money from MySQL to player [1000]

Discussion in 'Inactive/Unsupported Plugins' started by Paah, Jul 4, 2011.

  1. Offline

    Paah

    Redeem - The item redeemer
    Version: 1.5

    Redeem retrieves player's items from MySQL database and places them in his/her inventory. This is particularly useful for server admins who want to be able to grant items to their players as a thank you for donation automatically.

    How to use
    Users - Just type /redeem
    Admins:

    Show Spoiler
    Just insert correct MySQL information to the config file and reload/restart server.
    However, for the plugin to actually do anything, you will need some interaction on your website.
    Here is an example PHP script:
    Code:
    php said: 
    <html>
    <head>
    <title>Redeem</title>
    </head>
    <body>
    <form method="post" action="redeem.php">
    Playername: <input type="text" name="Player" size="45" /> <br />
    Data input: <input type="text" name="Input" size="45" /> <br />
    <input type="submit" value="Add to database" />
    </form>
    </body>
    </html>
    Name this whatever you want (.php)
    Code:
    php said: 
    <?php
    //Input correct values into this section
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = 'pass';
    $dbname = 'minecraft';
    $dbtable = 'redeem';
    //---------------------------------------
    
    $input = $_POST['Input'];
    $player = $_POST['Player'];
    $conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('Error: ' . mysql_error());
    mysql_select_db($dbname);
    $query = "INSERT INTO `".$dbname."`.`".$dbtable."` (`player`, `item`) VALUES ('".$player."', '".$input."')";
    mysql_query($query);
    mysql_close($conn);
    echo "Done!";
    ?>
    Name this one redeem.php and insert your mysql data into the appropriate section.
    Access the first file with your browser for simple data input form. Users will be immediately able to retrieve their items with /redeem command. Correct syntax for input is "<item> <amount>". Without amount it will default to 1. Item should either be the item's data value or name. "diamond 7" would grant 7 diamonds. Use item "money" for iConomy money. You can add ":<number>" behind item name to use damage values. For example "wool:15 27" for 27 black wool.

    Please note that this is not the recommended way to use this plugin. Quite honestly, it will be pretty much useless in this state. You should integrate it into your donation system / whatever you want to make the most of it. This is just overly basic example and functionality tester.



    Download
    <font color="red">If updating from 1.3 or lower, use command "/redeem convert" to update your database. (Requires op)</font>
    <Edit by Moderator: Redacted mediafire url>
    <Edit by Moderator: Redacted mediafire url>
    Place the connector into /lib/ folder in your server root. If you have the connector already no no need to download it again.


    Changelog:
    * 1.5 - Added support for damage values.
    * 1.4 - Updated database structure, sealed up memory leaks, fixed bugs..
    * 1.3 - Now supports iConomy5, use item "money".
    * 1.2 - Added automatic table creation
    * 1.1 - Fixed an issue related to connections.
    * 1.0 - Release

    Known bugs:
    * Plugin will think player's inventory is full if there are no free slots, even if there is partly empty stack of item.

    TODO:
    * Configurable messages
    * Grant permission nodes
    * Grant (permission) group memberships
    * Automatic group membership/permission expiration system
     
    Last edited by a moderator: Nov 27, 2016
    blaize9 and olimoli123 like this.
  2. Offline

    Bonkerz

    i think it's going to be awesome.
     
  3. Offline

    Paah

    Yeah, there is lot of possibilities. Granting ranks, permission nodes, etc..
    Also storing player's full inventory for offline editing. Though that might be another plugin.
     
  4. Offline

    gameswereus

    I really like this plugin! But I have no clue on how to set it up (I read ur post :p) later could you make a tutorial for idiots like me?
     
  5. Offline

    tha d0ctor

    if someone could draft up a simple php script example I would really love this!
     
    Bonkerz likes this.
  6. Offline

    Paah

    Updated to 1.1
    Fixed an issue related to connections.
     
  7. Offline

    gameguy27

    Can you PM the source to me? I'm trying to learn how to communicate with MySql for my own plugin. This is a really cool idea by the way. :3
     
  8. Offline

    Sh00ck

    hmm
    it does not create the Table :D
     
  9. Offline

    Paah

    If you would have taken a closer look at the TODO, you would have seen it was not supposed to create the table (yet).
    But now it does that too. ;)
     
  10. Offline

    Sh00ck

    Oh sry :(

    But GJ :)
     
  11. Offline

    gameswereus

    I downloaded it and couldn't find the detailed instructions
     
  12. Offline

    Paah

    @gameswereus
    You didn't notice the blaring "Redeem README.txt"?
    Or do you have problem that is not explained?
    Please note that you must have basic PHP knowledge yourself to create the other end of the system on your website.
    If you don't have a website or something similar, then this plugin is not for you.

    (I will make some example scripts for the website later, but currently this release only caters to the minecraft server.)
     
  13. Offline

    Poland Fun

    this is an awsome plugin; do you think an update to support money from the major economies (BEOSEconomy, and IConomy). For example when someone types redeem, then it grants them the money alloted.
     
  14. Offline

    Paah

    Updated to 1.3
    • Now supports iConomy - Use item "money" to grant iConomy money!
     
  15. Offline

    arthuryoss

    MySQL:
    Connection:
    Port: 3306
    Host : 'ip here'
    Database: ***
    Username: ***
    Password: ***
    TableName: ***

    I can't connect with this :s
     
  16. Offline

    Paah

  17. Offline

    arthuryoss

    Sorry for the last post t'ats an error into my SQl database Great plugin ;)
     
  18. Offline

    edocsyl

    Can u make a MySql DB example as .db file ?
     
  19. Offline

    MaMaxGER

    cool thanks I use it

    Can you made a detail tut, because I do not realy undestand the tutorial how I add Players to Mysql
     
  20. Offline

    Paah

    Added PHP example to first post. You can use this PHP script to test the functionality of the plugin, and see how to insert the data into MySQL.
     
  21. Offline

    endofzero

    You need to reconsider how you work with the database. Creating a column for every user is a very bad idea and not the way databases work. This isn't Excel.... Running an alter on a database that many times is hard on the database and they aren't meant to have a bunch of columns.

    A great idea, but it fails in the way it works with sql.

    You should just need a 'user' and 'item' column. Php would just do an insert into those rows, one for each item like it is now. a 'select item from $dbname where user = '$player' would get you your results and you just need to parse the items just like you are now. When it's finished, you would only need to do a 'delete from $dbname where user = '$player'

    This would also prevent any errors that are received when players don't have anything to redeem as opposed to it throwing an error because it can't find the column name, it would just return zero rows.
     
  22. Offline

    heifinator

    Thats how I'd do it too.
     
  23. Offline

    Paah

    Actually some nice person had PM'd me about that and it is already changed in next version.
    But thanks for you too.
     
  24. Offline

    heifinator

    Any idea on when that release may be? =) Just curious. Love the potential of this plugin.
     
  25. Offline

    Paah

    Updated to 1.4
    Use "/redeem convert" to convert your old database.
    Ton of bugfixes and effiency improvements, no new features, updating highly recommended.
    Please check example scripts to see how database was updated.
     
  26. Offline

    Threezool

    getting this error:

    I get it from typing /redeem

    Code:
    2011-07-20 11:44:15 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'redeem' in plugin Redeem v1.4
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:129)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:298)
        at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:711)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:676)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:669)
        at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:84)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
        at paah.Redeem.Redeem.onCommand(Redeem.java:62)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
        ... 12 more

    mysql table:

    idredeem - player - item
    1 - threezool - 1 1

    UPDATE:

    Using version 1.4

    UPDATE 2:

    Seems to be working with /redeem command
    why not just make players get the redeemed items directly from /redeem?
     
  27. Offline

    Paah

    Sorry that was just a stupid slip from my part, fixed now.
    Had it checking for the "convert" argument without first checking if there are any arguments.
    >_>
     
  28. Offline

    Threezool

    Works perfect now, thanks =D

    been looking for this kind of plugin for ages with mysql support =)

    EDIT:

    On a side note, would it be possible to add a config file for the message from receiving items and money? We use Coins on our server so would appreciate if at least that could be altered in the config. =)
     
  29. Offline

    Paah

    Now it shows server's currency name instead of blatant "money".
    Configurable messages in next version.
     
  30. Offline

    Threezool

    Thanks for the fast updates! =)
     

Share This Page