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!

Other Clothing Item not working

Discussion in 'Development' started by NoahtheBoah36™, Dec 7, 2017.

  1. NoahtheBoah36™

    NoahtheBoah36™ Clockwork Retard Clockwork Customer Active Member

    So, I'm getting an error.

    Error:
    Code:
    [ERROR] gamemodes/cwhl2rp/schema/items/sh_combat_armor.lua:16: attempt to index global 'character' (a nil value)
      1. GetReplacement - gamemodes/cwhl2rp/schema/items/sh_combat_armor.lua:16
       2. GetClientSideModel - gamemodes/clockwork/framework/items/sh_clothes_base.lua:61
        3. GetIconInfo - gamemodes/clockwork/framework/libraries/sh_item.lua:749
         4. Init - gamemodes/clockwork/framework/derma/cl_inventory.lua:364
          5. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:37
           6. Rebuild - gamemodes/clockwork/framework/derma/cl_inventory.lua:233
            7. OnSelected - gamemodes/clockwork/framework/derma/cl_inventory.lua:254
             8. unknown - gamemodes/clockwork/framework/derma/cl_menu.lua:242
    
    Timer Failed! [Simple][@gamemodes/clockwork/framework/derma/cl_menu.lua (line 239)]
    
    
    Also, the following appears in my (clientside) console whenever I open the inventory tab.
    Code:
    [Clockwork:Kernel]
    The 'MenuOpened' clockwork hook has failed to run.
    gamemodes/cwhl2rp/schema/items/sh_combat_armor.lua:16: attempt to index global 'character' (a nil value)
    
    This is the item script I'm having trouble with itself.
    Code:
    -- Created by Noah Engelmann AKA NoahtheBoah36.
    -- Permission to Redistribute/Reuse/Edit is granted, provided credit is given.
    
    local ITEM = Clockwork.item:New("clothes_base");
    ITEM.name = "Combat Armor";
    ITEM.group = "fallout_3";
    ITEM.cost = 5000;
    ITEM.weight = 5;
    ITEM.access = "A";
    ITEM.business = true;
    ITEM.protection = 0.0;
    ITEM.description = "A suit of combat armor, colored white as suprlus Anchorage equipment.";
    
    -- Setting the player model.
    function ITEM:GetReplacement(player)
        if (character.gender == GENDER_MALE) then
            return "models/nikout/fallout/wintercombatarmormale.mdl";
        elseif (character.gender == GENDER_FEMALE) then
            return "models/nikout/fallout/wintercombatarmorfemale.mdl";
        end;
    end;
    
    ITEM:Register();
    
    And a quick screenshot of what my inventory tab looks like.
    http://steamcommunity.com/sharedfiles/filedetails/?id=1224392981

    It appears like the error is with the model itself, but I'm 115% sure that the model is part of a content pack on the server.

    Also, I'll level: I have a suspicion that the error has to do with the character.gender part of the if statement, but I'm not sure why that's a problem, and how to fix it.
     
  2. wowmod

    wowmod Clockwork Customer

    replace character.gender with player:GetGender()
     
  3. Viz

    Viz Legend Clockwork Customer Active Member

    Also, unless you've added extra genders into your schema, you can replace the elseif statement with simply 'else'.
    Either way this shouldn't cause issues, but just so you know.
    Code:
    -- Setting the player model.
    function ITEM:GetReplacement(player)
      if (player:GetGender() == GENDER_MALE) then
         return "models/nikout/fallout/wintercombatarmormale.mdl";
      else
         return "models/nikout/fallout/wintercombatarmorfemale.mdl";
      end;
    end;
    
     
  4. NoahtheBoah36™

    NoahtheBoah36™ Clockwork Retard Clockwork Customer Active Member

    I'm aware, but nevertheless I prefer to have it reference the female gender as its' own thing, in part for that reason, but also in case some #equality nutjob comes my way.
     
    • Funny Funny x 1
  5. duck

    duck Phant0m Legend Crusader

    The else should be removed entirely.
    Code:
    if (player:GetGender() == GENDER_MALE) then
       return "models/nikout/fallout/wintercombatarmormale.mdl";
    end;
    
    return "models/nikout/fallout/wintercombatarmorfemale.mdl";
     
    • Agree Agree x 1

Previous Readers (Total: 0)