User Tag List

Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 15 to 21 of 26

Thread: Comunity input for a Premium System

  1. #15
    Original Poster
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,532
    XP
    20,135,343
    Level
    500
    Thanks
    1,100
    Thanked 337 Times in 217 Posts
    Quote Originally Posted by Grandelf View Post
    First of all, I must say I really like the idea of making a script with the community.
    Makes me wonder if going to Lua would increase the user input..

    I checked your script and noticed that it could use some clean up.
    I see a lot of methods which look like this:
    Code:
    bool PREM::IsPremiumTimed()
    {
        bool return_type;
     
        if (PREMIUM_TIMER_ENABLE == 0)
        {
            return_type = false;
        }
        else
        {
            return_type = true;
        }
     
        return return_type;
    }
    This could easily be rewritten to:
    Code:
    bool PREM::IsPremiumTimed()
    {
        return PREMIUM_TIMER_ENABLE != 0;
    }
    I honestly never knew how this works above but threw the edits in and it seems everything that calls the bool return gets a true return when player is premium or item is premium or false when 0.

    tnx :D

    Quote Originally Posted by Grandelf View Post
    I also noticed that this script has a lot of commands of which every single command has
    to check whether the player is premium or not.
    I am not sure if there's a way to deal with this, using the existing
    command system (you'd think there has to be..).
    However, as an alternative solution I wrote some code which will reduce
    the need to check if a player is a premium player.

    Basically what does code does is creating individual handlers for every command.
    Before any of the command handlers is executed, it will go through a main
    command handler, which will check for things that are common for each
    individual command handler.

    Script: http://paste2.org/nGaxhNDO

    Of course you can do it your way and use the original command system.
    It's just that I don't like to repeat code, in this case the check
    if a player is premium =P.

    Hope this was helpful,

    Grandelf.
    0.o i'm such a noob lol don't delete that , I may even copy it over to my gihub for referencing. yea i'm still playing around with how to add custom commands and limit them to selected players or staff members.

    I did convert all the bool functions over to the more simple returns as you posted :D
    I've seen stuff kinda like that before but didn't know how it returns or what it would return so I never tried it.


    Quote Originally Posted by Grandelf View Post
    First of all, I must say I really like the idea of making a script with the community.
    Makes me wonder if going to Lua would increase the user input...
    I did try to do that will my Eluna VIP Engine to allow others to post there custom scripts that would use it but no real work but some input.
    this is actualy the most input I have gotten on an open forum project, but I could use some examples for some of the ideas like nil fall damage ...
    or anything I listed with a `hmmm` lol
    Last edited by slp13at420; 05-01-2016 at 04:36 AM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  2. The Following User Says Thank You to slp13at420 For This Useful Post:


  3. #16
    Esteemed Member <span style='color: #4169E1'>Grandelf</span>'s Avatar
    Join Date
    Oct 2014
    Posts
    104
    XP
    64,547
    Level
    78
    Thanks
    18
    Thanked 110 Times in 45 Posts
    I can explain this a bit more, it's not that hard once you get the hang of it.
    Code:
    bool PREM::IsPremiumTimed()
    {
        return PREMIUM_TIMER_ENABLE != 0;
    }
    This code does exactly the same thing as your code, it's just shorter.
    PREMIUM_TIMER_ENABLE equals to a number value, most likely this will
    only be 0 or 1.

    So let's say that PREMIUM_TIMER_ENABLE = 0.
    According to your original code, 0 means false.
    Code:
    if (PREMIUM_TIMER_ENABLE == 0)
    {
        return_type = false;
    }
    This is also exactly what 'PREMIUM_TIMER_ENABLE != 0' does.

    The expression, in this case is: 0 isn't equal to 0 (0 != 0),
    which obviously is false because 0 is equal to 0, so it will return false.

    Now, if PREMIUM_TIMER_ENABLE = 1, the expression is 1 isn't equal to 0 (1 != 0).
    This expression is true because 1 isn't equal to 0, and so it returns true.

    So basically, whenever PREMIUM_TIMER_ENABLE is 0, it will return false.
    Because 0 is equal to 0. With any other value, it will return true,
    because 1, 2, 3, 4, 5, 6 etc. isn't equal to 0, which is what we asked for.

  4. The Following 2 Users Say Thank You to Grandelf For This Useful Post:


  5. #17
    Original Poster
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,532
    XP
    20,135,343
    Level
    500
    Thanks
    1,100
    Thanked 337 Times in 217 Posts
    ok I gotcha tnx :D gonna be pretty slick for future use.
    lol my work still does have a noobish look to it ;P
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  6. #18
    Esteemed Member <span style='color: #4169E1'>Grandelf</span>'s Avatar
    Join Date
    Oct 2014
    Posts
    104
    XP
    64,547
    Level
    78
    Thanks
    18
    Thanked 110 Times in 45 Posts
    The look of a script doesn't matter =P, as long as it works correctly
    and is written properly.

    I will give you a hint though, all the code in this class basically does the exact same thing:
    Code:
    class Unit_Premium_Engine : public UnitScript
    As a general rule you shouldn't repeat code.
    I'm sure you can make it look better, by taking out all the repetive
    code and put it inside a method. Then you can call that method from
    the OnHeal, OnDamage etc..

  7. The Following User Says Thank You to Grandelf For This Useful Post:


  8. #19
    Original Poster
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,532
    XP
    20,135,343
    Level
    500
    Thanks
    1,100
    Thanked 337 Times in 217 Posts
    Quote Originally Posted by Grandelf View Post
    The look of a script doesn't matter =P, as long as it works correctly
    and is written properly.

    I will give you a hint though, all the code in this class basically does the exact same thing:
    Code:
    class Unit_Premium_Engine : public UnitScript
    As a general rule you shouldn't repeat code.
    I'm sure you can make it look better, by taking out all the repetive
    code and put it inside a method. Then you can call that method from
    the OnHeal, OnDamage etc..
    are you talking that the melee damage, spell damage will also go thru the OnDamage event and I should just use it? was woundering bout htat but never did follow thru on testing the idea..
    Last edited by slp13at420; 05-03-2016 at 12:16 PM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  9. #20
    Esteemed Member <span style='color: #4169E1'>Grandelf</span>'s Avatar
    Join Date
    Oct 2014
    Posts
    104
    XP
    64,547
    Level
    78
    Thanks
    18
    Thanked 110 Times in 45 Posts
    No, what I meant was that you could make a 5th method called something like 'HandlePremiumModifier',
    and call that method from the other methods. You can do this because those methods do the exact same
    thing. So basically one generic method, which is called from the OnDamage, ModifyMeleeDamage and
    ModifySpellDamageTaken methods.

    By doing this, you will get rid of code that does the exact same thing.

  10. The Following User Says Thank You to Grandelf For This Useful Post:


  11. #21
    Original Poster
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,532
    XP
    20,135,343
    Level
    500
    Thanks
    1,100
    Thanked 337 Times in 217 Posts
    Quote Originally Posted by Grandelf View Post
    No, what I meant was that you could make a 5th method called something like 'HandlePremiumModifier',
    and call that method from the other methods. You can do this because those methods do the exact same
    thing. So basically one generic method, which is called from the OnDamage, ModifyMeleeDamage and
    ModifySpellDamageTaken methods.

    By doing this, you will get rid of code that does the exact same thing.
    oooohhh ok lol duh k gotcha

    x = PREM::IncreaseValueWithOffset(Player* player, uint32 val)

    n just use that rather than same code each event. lol
    n updated a couple to use them too in player events
    and a couple misc that can use it too.
    added 1 method for increase and 1 for decrease.

    tnx
    Last edited by slp13at420; 05-04-2016 at 12:21 PM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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