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!

Cannot Call GetCharacterData() Clientside

Discussion in 'Development' started by grafikerror, Jul 5, 2015.

  1. grafikerror

    grafikerror Clockwork Customer

    Hi guys.
    I just want to make a simple plugin/edit that draw an overlay when you have clothes but i cannot make it work for some weird reasons.
    Can someone check it and tell me what's wrong ?

    Code:
    function PLUGIN:RenderScreenspaceEffects()
        local clothes = Clockwork.Client:GetCharacterData("clothes");
        if (clothes) then
              local health = LocalPlayer():Health();
              if ( health <= 20 ) then
                  DrawMaterialOverlay( "effects/gasmask_screen_4.vmt", 0.1 );
              elseif( health <= 30 ) then
                  DrawMaterialOverlay( "effects/gasmask_screen_3.vmt", 0.1 );
              elseif( health <= 60 ) then
                  DrawMaterialOverlay( "effects/gasmask_screen_2.vmt", 0.1 );
              elseif( health <= 90 ) then
                  DrawMaterialOverlay( "effects/gasmask_screen_1.vmt", 0.1 );
              else
                  DrawMaterialOverlay( "effects/gasmask_screen.vmt", 0.1 );
              end;
        end;
    end;
     
  2. vexus

    vexus ej rockwell's worst nightmare Staff Member Manager Legend Clockwork Customer

    Pretty sure this isn't a fix, but make sure in the file that:
    Code:
    local PLUGIN = PLUGIN
    
    is at the top. This is just sort of a thing in CW.
     
  3. The local PLUGIN = PLUGIN is just making a reference to the actual plugin before the variable representing it becomes nil. This lets you use PLUGIN inside hooks or within callbacks for things like console commands. It isn't a magical fix and is only needed if again, you're going to be using the plugin table in a situation where the PLUGIN variable is nil (console commands callbacks, chat command callbacks, hooks, etc...)
     
  4. vexus

    vexus ej rockwell's worst nightmare Staff Member Manager Legend Clockwork Customer

    understood every word...
     
    • Funny Funny x 1
  5. NightAngel

    NightAngel Fuck off Lev

    GetCharacterData is a serverside function, not a clientside function. This is what SharedVars are for.

    edit: OH just take out the reference to clothes in your function, and it should work.
     

Previous Readers (Total: 0)