1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
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!

Need Code Fix

Discussion in 'Requests' started by Savvyge Investments, Jul 5, 2019.

  1. Savvyge Investments

    Savvyge Investments Clockwork Customer

    I want to make an item that

    OnUse
    Take the Characters name and display a text in the chatbox.

    OnUse say in chatbox 'lights a cigarette and proceeds to smoke on it.'

    Player Uses Cigarette and on use the below text is displayed in chat box replicating a /me on use.
    Tetsuo Shima lights a cigarette and proceeds to smoke on it.

    This is what I have but I don't know how to string it correctly.

    Code:
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
            player:TakeDamage(1, player, player);
            player:GiveItem(Clockwork.item:CreateInstance("Mild Seven Cigarette Butt"), true);
            Clockwork.chatBox:AddInRadius(player, "has smoked a cigarette."
              player:GetPos(), Clockwork.config:Get("talk_radius"):Get() * 2);
    end;
    
    [ERROR] gamemodes/cwhl2rp/plugins/cwmultiuseitems/plugin/items/sh_mildsevencigarette.lua:27: ')' expected (to close '(' at line 26) near 'player'

    [ERROR] gamemodes/cwhl2rp/plugins/cwmultiuseitems/plugin/items/sh_mildsevencigarette.lua:27: unexpected symbol near ','
     
  2. Savvyge Investments

    Savvyge Investments Clockwork Customer

    bump I think it got lost
     
  3. Viz

    Viz Legend Clockwork Customer

    Untested.
    Code:
    function ITEM:OnUse(player, itemEntity)
       player:TakeDamage(1, player, player);
       player:GiveItem(Clockwork.item:CreateInstance("Mild Seven Cigarette Butt"), true);
       Clockwork.chatBox:AddInTargetRadius(player, "me", "has smoked a cigarette.", player:GetPos(), Clockwork.config:Get("talk_radius"):Get() * 2);
    end;
    
     
    • Like Like x 1
    • Agree Agree x 1
    • Good Coder Good Coder x 1
  4. Savvyge Investments

    Savvyge Investments Clockwork Customer

    I'll plug it in and let you know thank you so much!
     
    • Good Coder Good Coder x 1
  5. Savvyge Investments

    Savvyge Investments Clockwork Customer

    Confirmed working. Thanks alot! This adds even more depth to the items I am make.

    [​IMG]
     
  6. Sloth_

    Sloth_ Runs a shitty Hl2rp community Legend Clockwork Customer

    Is this for multi use by any chance? :3
     
    • Good Coder Good Coder x 1
  7. Savvyge Investments

    Savvyge Investments Clockwork Customer

    It is! You can add the code Viz provided. I will update my plugin soon for any new downloaders.

    You really only need this line. However you may add any other ONUSE's you have in the FunctionOnUse field.

    Code:
    function ITEM:OnUse(player, itemEntity)
    Clockwork.chatBox:AddInTargetRadius(player, "me", "has smoked a cigarette.", player:GetPos(), Clockwork.config:Get("talk_radius"):Get() * 2);
    
    end;
    
    
     
    • Good Coder Good Coder x 1
  8. Sloth_

    Sloth_ Runs a shitty Hl2rp community Legend Clockwork Customer

    I know this is a little off topic, but for some reason even with your content pack linked, the cigarette butts are errors for everyone, any idea how to resolve this?
     
  9. Savvyge Investments

    Savvyge Investments Clockwork Customer

    Yeah so

    Code:
    --[[
    RETCONNED
    So the cigarette butt will use whatever model you attach to it. So say you want the model of the cigarette to be a soda can, you'd put the soda can model string in place of my
    models/phycitnew.mdl

    models/props_junk/popcan01a.mdl

    So you'll just need the Addon Pack from the Garry's Mod Workshop. The cigarettes are from UU BRANDED FOOD items addon.
    .
    Right click on any prop model and hit COPY TO CLIPBOARD and you will have the model string in your paste.
     
    Last edited: Jul 9, 2019
  10. Sloth_

    Sloth_ Runs a shitty Hl2rp community Legend Clockwork Customer

    Oh so there's no cig butt models at all?!
    Exposed!
     
    • Good Coder Good Coder x 1
  11. Savvyge Investments

    Savvyge Investments Clockwork Customer

    My bad the model was from NeoTokyo props.

    [​IMG]
     
    • Good Coder Good Coder x 1
  12. Sloth_

    Sloth_ Runs a shitty Hl2rp community Legend Clockwork Customer

    It's cool, I'm gonna do it myself but I recommend you just gmad the butt and add it to the server
     
    • Agree Agree x 1
    • Good Coder Good Coder x 1
  13. Sloth_

    Sloth_ Runs a shitty Hl2rp community Legend Clockwork Customer

    Sorry, add it to the plugin
     
    • Good Coder Good Coder x 1
  14. Savvyge Investments

    Savvyge Investments Clockwork Customer

    I'm ghetto and have little to no idea what I am doing.
    I have GMAD and use it but don't know how to 'add it to the plugin/server' like do they download the model or sumn idk whatcha mean
     
    • Like Like x 1
    • Good Coder Good Coder x 1
  15. Sloth_

    Sloth_ Runs a shitty Hl2rp community Legend Clockwork Customer

    So you'd make a new folder for materials and/or models. You'd put that in the folder before plugins, so it should be
    /Plugin name/Content
    > Materials folder
    > Models folder
    > plugin folder
    The materials and models go /Garrysmod/ respective folder

    When people join the server it's force downloaded through the fastdl :)
     
    • Good Coder Good Coder x 2
  16. Aspect

    Aspect =) Legend Clockwork Customer

    You shouldn't use fastdl tbh
    Just make your own addon and add the models you want to use in it. That way people do not download models which they will not even see.
    Though you shouldn't do this if you are using more than half of the models in said pack or if the pack is popular (that way you run the risk of certain users downloading the models twice).
     
    • Good Coder Good Coder x 1
  17. svensis_

    svensis_ Clockwork Customer

    https://wiki.garrysmod.com/page/resource/AddWorkshop

    You get the ID from the URL of the workshop addon.
    For example, here's the URL of the Achievement Viewer addon's page:
    http://steamcommunity.com/sharedfiles/filedetails/?id=104606562
    The ID is 104606562.
    Code:
    resource.AddWorkshop( "104606562" )
    Put this in any sv_ (serverside) file and it should work

    If you want to do this with a whole collection, go here.

    https://csite.io/tools/gmod-universal-workshop
     
    • Good Coder Good Coder x 2
    • Disagree Disagree x 1
    Last edited: Jul 9, 2019
  18. Aspect

    Aspect =) Legend Clockwork Customer

    You know how to set up fastdl, good job :clap:
    Tho that is actually slower than downloading the addon itself through the workshop.
     
    • Good Coder Good Coder x 1

Previous Readers (Total: 0)