1. Check out the Store if you're looking to Buy HL2RP or other schemas for your server. You can click Buy Schemas on the very top navigation bar to visit the store.
  2. Use the Plugin Center to easily subscribe to and auto-install Clockwork plugins to your server, or submit and share plugins you have developed.
  3. Having trouble setting up or developing with Clockwork? Check out the Wiki or post in the Support Forum for advice from fellow users.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Other Overriding Framework or Schema commands via plugin

Discussion in 'Development' started by ZeMysticalTaco, Sep 5, 2017.

  1. ZeMysticalTaco

    ZeMysticalTaco yo i'm a taco have some lunch Clockwork Customer

    I'm trying to override the roll command.

    Acting as if the roll command in the plugin is a new command doesn't appear to override it and I had gone Here and the solution @NightAngel provided doesn't appear to be working as the following error spits out: [​IMG]
    I guess I'm just a dipstick or something or maybe braindead.
     
  2. robot

    robot Administrator Staff Member Administrator Store Support Clockwork Customer

    You're probably using it wrong, or your code has some issues on it or something, just tried out and it worked.
    I'll provide the code I used as an example
    Code:
    --[[
        © 2013 CloudSixteen.com do not share, re-distribute or modify
        without permission of its author ([email protected]).
    --]]
    
    local COMMAND = Clockwork.command:FindByID("CharFollow")
    COMMAND.tip = "Testing command.";
    
    -- Called when the command has been run.
    function COMMAND:OnRun(player, arguments)
        Clockwork.player:Notify(player, "It worked!");
    end;
    
    COMMAND:Register();
    Feel free to adapt it to your needs or whatever u want to do with it
     
    • Winner Winner x 1
  3. ZeMysticalTaco

    ZeMysticalTaco yo i'm a taco have some lunch Clockwork Customer

    I tried commenting out all the code in OnRun, deleting the line it's erroring on [It errors on COMMAND.tip, not the declaration.]

    This is all the code, I even copypasted yours and replaced 'CharFollow' with 'Roll' or 'roll'.
    [​IMG]
     
    • Friendly Friendly x 1
  4. robot

    robot Administrator Staff Member Administrator Store Support Clockwork Customer

    I guess you're getting the same error, or is it different?
     
  5. ZeMysticalTaco

    ZeMysticalTaco yo i'm a taco have some lunch Clockwork Customer

    The exact same, yeah.

    I'm pretty confused.
     
  6. duck

    duck Phant0m Legend Crusader

    I think schema commands are loaded before plugin commands, and clockwork commands are loaded after plugins have been loaded, which would explain why roll (a clockwork command) errors and charfollow (an hl2rp command) does not.

    Put your command code in a hook in a hook that gets called after everything is loaded.
    Code:
    function PLUGIN:ClockworkInitialized()
        local COMMAND = Clockwork.command:FindByID("Roll")
        COMMAND.tip = "Test"
    
        function COMMAND:OnRun()
            print("hello")
        end
    
        COMMAND:Register()
    end
     
    • Agree Agree x 1
    • Good Coder Good Coder x 1
  7. kurozael

    kurozael Cloud Sixteen Director Staff Member Administrator Investor Crusader Templar

    If there's something in particular you want to modify in the roll command I could always add in a new hook for the new update that allows external forces (plugins) to dictate or influence both the outcome of a roll and the kind of text that it displays. This would allow your plugin to customize it more naturally :)
     
    • Friendly Friendly x 1
  8. ZeMysticalTaco

    ZeMysticalTaco yo i'm a taco have some lunch Clockwork Customer

    I was just making a new roll system all together for attribute based rolling and such.

    IE -- /roll {generic} or /roll strength, it'd roll out of 20, similar to DnD, but I think that hook might be useful to have, being able to influence by your faction rank .etc

    Your method appears to have worked, thanks ducko!
     
    Last edited: Sep 6, 2017

Previous Readers (Total: 0)