Monthly Target: $400 Donations: $23
 5% 

[TF2] Metal Calculator


Post New Thread Reply   
 
Thread Tools Display Modes
Author
gameguysz
Member
Join Date: Aug 2011
Location: USA
Plugin ID:
2683
Plugin Version:
1.0.2
Plugin Category:
General Purpose
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Approver:
    Plugin Description:
    A simple chat based calculater that allows the user to calculate simple math problems to figure out an exact price.
    Servers with this Plugin:
     
    Old 11-23-2011 , 14:24   [TF2] Metal Calculator
    Reply With Quote #1

    sm_metalcalc
    v.1.0.1


    This isn't the final version. The final version will be much neater in code and in looks/use.

    Description:
    Only real use is tf2 but i guess it should work for all..

    A simple plugin that allows the users to solve simple math problems to find out the exact amount of metal they should pay or retrieve by calculating the exact Refine, Reclaim, and Scrap.

    Concept:The idea was created when i found out people who are in my server trade a vast amount of items at a time and sometimes leave to go grab a calculator and or phone to help with there problems.

    Installation:
    Put sm_metalcalc.smx into /addons/sourcemod/plugins and reboot your server or type "sm plugins load sm_metalcalc" into your console or rcon.

    ConVars:
    (See how it works for details)
    • sm_add
    • sm_mult
    • sm_sub
    • sm_div
    • sm_metalcalc_version (Checks plugins version)

    Commands:
    !add
    <input float amount here Ex: 1.0> <Insert Metal Type: ref, rec, scrap or scraps(Caps don't matter)> <add amount here>
    !mult <input float amount here Ex: 1.0> <Insert Metal Type: ref, rec, scrap or scraps(Caps don't matter)> <multiply amount here>
    !sub <input float amount here Ex: 1.0> <Insert Metal Type: ref, rec, scrap or scraps(Caps don't matter)> <subtract amount here>
    !div <input float amount here Ex: 1.0> <Insert Metal Type: ref, rec, scrap or scraps(Caps don't matter)> <divide amount here>



    How it works?:
    Simple! Let me show you a example:
    !mult 1.33 ref 2
    This will come up as
    Code:
     [SMMC] Your total is: 2.66 ref or 8 rec or 24 scrap(s)
    The layout of this is rather simple:
    Code:
    !add(or !mult) <input float amount here Ex: 1.0> <Insert Metal Type: ref, rec, scrap or scraps(Caps don't matter)> <muliply/add amount here>
    More expressions will be added in future updates

    Metals:
    List of metals references allowed by plugin.
    Code:
    ref refine refined | rec reclaim reclaimed | scrap scraps
    The script is not case sensitive so don't worry about capitalizing anything!


    Changelog:
    v.1.0.2
    • Added Subtraction
    • Added Division
    • Added new commands and Cvars
    v.1.0.1
    • Added Addition
    • Added/Changed Commands (!add/!mult)
    • Added plugin version check (sm_metalcalc_version)
    v.1.0:
    • Float are now rounded to INTs for a better look appeal! (No more rounding up for sub values)
    • Added more commands
    v.0.5:
    • Fixed Colors showing up for ref values
    • Added Ceil Round for some floats (Still trying to round to whole number. You can see experiments in the source file)
    • added command sm_count
    Future Updates:
    I will be changing the format to a simpler and more pleasant way of working with:
    Code:
    !count 1.33 ref + 1.33 rec
    I will also be adding the ability to see how much you will make by adding, multiplying, and dividing different amounts like you can see above.

    Will also be making the code a bit tidier when i do this as well.


    Side Note: Now i wasn't sure whether i should release this at all, i know its popular on my server but i don't know if there is a better version of this else where or not. I did do a search and came up with nothing so i thought why not!


    This plugin isn't supposed to change the world! I know it could be written better and what not but i will be updating it soon with more features and better to look at code. Also if you guys have any ideas on some addon's or anything of the sort feel free to PM me about it, or just post it here.

    There is also most likely a better way to write this but i am a beginner and im still learning so i will be updating this script as i move along.

    Please leave a review/comment if your using this plugin! I would love to hear

    Attached Files
    File Type: sp Get Plugin or Get Source (sm_metalcalc.sp - 421 views - 10.1 KB)

    Last edited by Dr. McKay; 10-06-2012 at 19:27. Reason: Feedback given
    gameguysz is offline
    Thrawn2
    Veteran Member
    Join Date: Apr 2009
    Old 11-23-2011 , 16:17   Re: [TF2] Metal Calculator
    Reply With Quote #2

    Quote:
    Originally Posted by gameguysz View Post
    Need to figure out how to round to the nearest whole number otherwise the users have to round up every once in a while in the sub category.
    http://docs.sourcemod.net/api/index....d=show&id=714&


    PHP Code:
    /**
     * Rounds a float to the closest integer to zero.
     *
     * @param value            Input value to be rounded.
     * @return                Rounded value.
     */
    native RoundToZero(Float:value);

    /**
     * Rounds a float to the next highest integer value.
     *
     * @param value            Input value to be rounded.
     * @return                Rounded value.
     */
    native RoundToCeil(Float:value);

    /**
     * Rounds a float to the next lowest integer value.
     *
     * @param value            Input value to be rounded.
     * @return                Rounded value.
     */
    native RoundToFloor(Float:value);

    /**
     * Standard IEEE rounding.
     *
     * @param value            Input value to be rounded.
     * @return                Rounded value.
     */
    native RoundToNearest(Float:value); 
    __________________
    einmal mit profis arbeiten. einmal.
    Thrawn2 is offline
    gameguysz
    Member
    Join Date: Aug 2011
    Location: USA
    Old 11-23-2011 , 17:52   Re: [TF2] Metal Calculator
    Reply With Quote #3

    Quote:
    Originally Posted by Thrawn2 View Post
    http://docs.sourcemod.net/api/index....d=show&id=714&


    PHP Code:
    /**
     * Rounds a float to the closest integer to zero.
     *
     * @param value            Input value to be rounded.
     * @return                Rounded value.
     */
    native RoundToZero(Float:value);

    /**
     * Rounds a float to the next highest integer value.
     *
     * @param value            Input value to be rounded.
     * @return                Rounded value.
     */
    native RoundToCeil(Float:value);

    /**
     * Rounds a float to the next lowest integer value.
     *
     * @param value            Input value to be rounded.
     * @return                Rounded value.
     */
    native RoundToFloor(Float:value);

    /**
     * Standard IEEE rounding.
     *
     * @param value            Input value to be rounded.
     * @return                Rounded value.
     */
    native RoundToNearest(Float:value); 
    Just noticed i had them in the wrong spot Plugin updated to newer version
    gameguysz is offline
    gameguysz
    Member
    Join Date: Aug 2011
    Location: USA
    Old 11-24-2011 , 00:47   Re: [TF2] Metal Calculator
    Reply With Quote #4

    Plugin is up and fully working :] tell me what you guys think
    gameguysz is offline
    gameguysz
    Member
    Join Date: Aug 2011
    Location: USA
    Old 11-25-2011 , 02:51   Re: [TF2] Metal Calculator
    Reply With Quote #5

    ANOTHER UPDATE!

    Changelog:
    v.1.0.1
    • Added Addition
    • Added/Changed Commands (!add/!mult)
    • Added plugin version check (sm_metalcalc_version)

    Last edited by gameguysz; 11-25-2011 at 02:52.
    gameguysz is offline
    gameguysz
    Member
    Join Date: Aug 2011
    Location: USA
    Old 11-25-2011 , 23:25   Re: [TF2] Metal Calculator
    Reply With Quote #6

    UPDATE:
    Changelog:
    v.1.0.2
    • Added Subtraction
    • Added Division
    • Added new commands and Cvars
    gameguysz is offline
    Snaggle
    SourceMod Donor
    Join Date: Jul 2010
    Location: England
    Old 11-26-2011 , 01:37   Re: [TF2] Metal Calculator
    Reply With Quote #7

    So... in what situation would I use this for? Forgive me, trading is something i've managed to avoid while playing TF2 x.x
    __________________
    - Ach Factory
    - Bot Killing
    Snaggle is offline
    gameguysz
    Member
    Join Date: Aug 2011
    Location: USA
    Old 11-26-2011 , 02:07   Re: [TF2] Metal Calculator
    Reply With Quote #8

    Quote:
    Originally Posted by Snaggle View Post
    So... in what situation would I use this for? Forgive me, trading is something i've managed to avoid while playing TF2 x.x
    No problem.
    People in my server who scrap bank use it since they mass buy amounts of stuff. people also use it to calculate how much profit they might make or loose in a trade and so forth. I personally only use it every once in a while but quite a bit of people use it on my server once i put it on my announcements.

    Also i would say this plugin is made for a little more serious types of trading servers. Considering it takes people who know what there really doing (Trading wise) since they use normal calculators and or phones to do that math. This approach is just much simpler and more effective

    Last edited by gameguysz; 11-26-2011 at 02:51.
    gameguysz is offline
    Dr. McKay
    Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
    Join Date: Aug 2011
    Location: Atlantis
    Old 10-06-2012 , 19:26   Re: [TF2] Metal Calculator
    Reply With Quote #9

    Usages are incorrect in your RegConsoleCmds.
    __________________
    Dr. McKay is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 12:23.


    Powered by vBulletin®
    Copyright ©2000 - 2015, vBulletin Solutions, Inc.
    Theme made by Freecode