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!

HL2RP Trying to make an item spawn an entity (a la stationary radio)

Discussion in 'Development' started by Duspende_, Apr 26, 2018.

  1. Duspende_

    Duspende_ Active Member

    Code:
    function ITEM:OnUse(player, itemEntity)
        local trace = player:GetEyeTraceNoCursor();
     
        if (trace.HitPos:Distance( player:GetShootPos() ) <= 192) then
            local entity = ents.Create("dronesrewrite_ardrone");
         
            Clockwork.player:GiveProperty(player, entity);
         
            entity:SetItemTable(self);
            entity:SetPos(trace.HitPos);
            entity:Spawn();
         
            Clockwork.entity:MakeFlushToGround(entity, trace.HitPos, trace.HitNormal);
         
        else
            Clockwork.player:Notify(player, "You cannot drop a drone that far away!");
         
            return false;
        end;
    end;
    This doesn't seem to work. Any idea why?

    I'm trying to spawn a drone entity from the 'Drones Rewrite' addon, to give players the ability to 'Use' an item that will spawn a specific drone, as opposed to admins having to spawn it for them.

    Addtionally, entering the 'Crafting' tab seems to produce the following error:
    Code:
    [ERROR] gamemodes/clockwork/framework/libraries/sh_crafting.lua:408: attempt to concatenate a nil value
      1. FormatRequirements - gamemodes/clockwork/framework/libraries/sh_crafting.lua:408
       2. GetMarkupToolTip - gamemodes/clockwork/framework/libraries/sh_crafting.lua:639
        3. unknown - gamemodes/clockwork/framework/derma/cl_crafting.lua:147
     
    Last edited: Apr 26, 2018

Previous Readers (Total: 0)