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!

HL2RP Problem OnPickup GiveItem

Discussion in 'Development' started by K.N.G., Jun 22, 2019.

  1. Hello Cloud sixteen's community,
    I try when i take this item, it give me an another item
    Code:
    local ITEM = Clockwork.item:New();
    ITEM.name = "Ration";
    ITEM.uniqueID = "uu_definration";
    ITEM.model = "models/weapons/w_package.mdl";
    ITEM.category = "Consumables";
    ITEM.weight = 0.8;
    ITEM.description = "Une ration";
    
    function ITEM:OnPickup(player, position)
        player:GiveItem("uu_ration_biotic",true);
        player:TakeItem(player:FindItemByID("uu_definration"));
    end;
    
    function ITEM:OnDrop(player, position) end;
    
    ITEM:Register();
    for a obscure reason it does not work,
    I have this strange error:
    Code:
    Trace:
    1: Line 32    "Trace"    lua/includes/extensions/debug.lua
    2: Line 909    "GiveItem"    gamemodes/clockwork/framework/meta/sv_player.lua
    3: Line 10    "OnPickup"    gamemodes/cwhl2rp/plugins/rationdispensertwo/plugin/items/sh_rationdefin.lua
    4: Line 3681    "nil"    gamemodes/clockwork/framework/sv_kernel.lua
    5: C function    "pcall"
    6: Line 658    "Call"    gamemodes/clockwork/framework/libraries/sh_plugin.lua
    7: Line 5411    "nil"    gamemodes/clockwork/framework/sv_kernel.lua
    8: Line 127    "func"    gamemodes/clockwork/framework/libraries/sh_datastream.lua
    9: Line 32    "nil"    lua/includes/extensions/net.lua
    
    If you have an idea ?
     
  2. D.K !

    D.K ! Clockwork Customer

    Hello K.N.G, the solution is the following

    Code:
    local ITEM = Clockwork.item:New();
    ITEM.name = "Ration";
    ITEM.uniqueID = "uu_definration";
    ITEM.model = "models/weapons/w_package.mdl";
    ITEM.category = "Consumables";
    ITEM.weight = 0.8;
    ITEM.description = "Une ration";
    
    function ITEM:OnPickup(player, position)
        player:GiveItem(Clockwork.item:CreateInstance("UU Ration Biotic"), true);
        player:TakeItemByID("uu_definration");
    end;
    
    function ITEM:OnDrop(player, position) end;
    
    ITEM:Register();
    
    On the other hand, be careful to put the name of the item with capitals and spaces in Clockwork.item: CreateInstance (do not put the unique id)
    Have a good evening !
     
  3. I have already try this, but the problem persists.
     
  4. I have found a solution
    Code:
    local Clockwork=Clockwork;
    
    local ITEM = Clockwork.item:New();
    ITEM.name = "Ration";
    ITEM.uniqueID = "uu_definration";
    ITEM.model = "models/weapons/w_package.mdl";
    ITEM.category = "Consumables";
    ITEM.weight = 0.8;
    ITEM.description = "Une rations";
    
    function ITEM:OnPickup(player, position)
        player:GiveItem(Clockwork.item:CreateInstance("Ration de grade biotic"),true);
        player:TakeItem(player:FindItemByID("uu_definration"));
    end;
    
    function ITEM:OnDrop(player, position) end;
    
    ITEM:Register();
    Just add local Clockwork = Clockwork;
     
  5. D.K !

    D.K ! Clockwork Customer

    Noice.
     

Previous Readers (Total: 0)