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!

Atomic NPC Items Drop

Discussion in 'Development' started by Mixed, Oct 6, 2017.

  1. Mixed

    Mixed removed Clockwork Customer

    I'm just trying to make a NPC Item Drop, but at this line I'm lost:
    Code:
    Line 21 - Clockwork.item:Spawn(entity:GetPos() + Vector(0, 0, 8), nil, RandomItem)
    It say this in my console when I kill a npc:
    Code:
    [Clockwork:NPCDrop]
    The 'OnNPCKilled' hook has failed to run.
    gamemodes/cwatomic/plugins/npcdrop/plugin/sh_plugin.lua:21: attempt to call method 'Spawn' (a nil value)
    
     
  2. Mixed

    Mixed removed Clockwork Customer

    Ok, solved, my bad:

    Clockwork.item:CreateInstance(entity:GetPos() + Vector(0, 0, 8), nil, RandomItem)

    Now this problem pop x')
    Code:
    [Clockwork:NPC Item Drop]
    The 'OnNPCKilled' hook has failed to run.
    gamemodes/clockwork/framework/libraries/sh_item.lua:493: bad argument #1 to 'lower' (string expected, got userdata)
    
    @kurozael
     
    • Agree Agree x 1
    Last edited: Oct 6, 2017
  3. grafikerror

    grafikerror Clockwork Customer

    Code:
        local itemTable = Clockwork.item:FindByID("uniqueID_de_ton_objet_ici")
        local position = (self:GetPos() + Vector(0, 0, 32));
      
        if (itemTable and !itemTable.isBaseItem) then
            local itemTable = Clockwork.item:CreateInstance(itemTable("uniqueID"));
            local entity = Clockwork.entity:CreateItem(player, itemTable, position);
            if (IsValid(entity)) then
                entity:SetPos( position );
                Clockwork.entity:MakeFlushToGround(entity, position, position);
            end
        end
     

Previous Readers (Total: 0)