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!

Command to show specific points in attribute

Discussion in 'Requests' started by BurningMadness, Mar 14, 2018.

  1. BurningMadness

    BurningMadness Clockwork Customer

    Hello, i'm currently blocked by my bad knowledge, what i'm trying to accomplish is a command that allow the player to show how many points he got in one of his attribute
    Here is what i have done so far
    Code:
    local COMMAND = Clockwork.command:New("strength");
    COMMAND.tip = "Montre sa force afin d'influencer une action demandant de la force.";
    
    -- Called when the command has been run.
    function COMMAND:OnRun(player, arguments)
    local atb = Clockwork.attributes:Get(player, ATB_MEDICAL)
        Clockwork.chatBox:AddInRadius(player, "strength", "A une force de "..atb.." offrant",    player:GetPos(), Clockwork.config:Get("talk_radius"):Get());
    end;
     
  2. RJ

    RJ no pay Legend Clockwork Customer

    Clockwork's code on attributes is a bit weird, there's 2 libraries for attributes. One is called "Attribute" and the other is "Attributes". It looks like attributes are made with the "Attribute" library, and I suppose the "Attributes" library is for interacting with attributes. Have I confused you yet? Haha.

    The Clockwork.attributes:Get(...) function actually returns two values: amount (actual value), and progress (experience points let's say). I'll talk more about that later depending on what value is returned in the code I mention below.

    First things first, are there any errors in the console and does the command work at all? E.g. does the player see anything in chat when the command is used, and what do they see if anything?

    Next add this code somewhere in OnRun and tell me what is printed in the console after using the command:
    Code:
    print(ATB_MEDICAL);
     
  3. BurningMadness

    BurningMadness Clockwork Customer

    First, thanks you for trying to help !

    Well, no error before and now i get this:
    "
    ServerLog: Jordan Adyson a utilisé '/strength'.
    med"

    I think i'm just not doing this right, the point is i want peoples to be able to type a command showing how many points they got on a specific attribute.
     
  4. RJ

    RJ no pay Legend Clockwork Customer

    Alright, I just wanted to see if ATB_MEDICAL was returning any value and looks like it does which is good.

    Next can you add this and tell me what shows up? Make sure it's placed after the 'atb' variable.

    Code:
    print(atb);
     
  5. BurningMadness

    BurningMadness Clockwork Customer

    Now i get:

    "
    med
    2
    ServerLog: Jordan Adyson a utilisé '/strength'.
    med
    2
    ServerLog: Jordan Adyson a utilisé '/strength df'."
     
  6. RJ

    RJ no pay Legend Clockwork Customer

    And if you open your Attributes menu it shows "2" for your medical attribute? I just want to make sure things are working as intended.
     
    • Agree Agree x 1
  7. RJ

    RJ no pay Legend Clockwork Customer

    Actually I found the issue, you should've used "ic" instead of "strength" for this line of code:
    Code:
    Clockwork.chatBox:AddInRadius(player, "strength", "A une force de "..atb.." offrant",    player:GetPos(), Clockwork.config:Get("talk_radius"):Get());
    edit: Try using "Clockwork.chatBox:AddInTargetRadius" instead of "Clockwork.chatBox:AddInRadius".

    Also you should replace "ATB_MEDICAL" with "ATB_STRENGTH" because I'm assuming you want your strength attribute instead of the medical attribute given how your command is /strength. From this line:

    Code:
    local atb = Clockwork.attributes:Get(player, ATB_MEDICAL)
    Let me know if that works.
     
    • Winner Winner x 1
    • Informative Informative x 1
  8. BurningMadness

    BurningMadness Clockwork Customer

    Yep that's the way ! Thanks you, it was a stupid mistake, but i learned the print ! Also i remplaced ic by me so it look more legit, thanks !
     
    • Like Like x 2

Previous Readers (Total: 0)