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!

Other GetClass Function?

Discussion in 'Development' started by 8bitMafia, Dec 20, 2016.

  1. It seems to be a very needed function that is lacked in the framework. I might be wrong but I can't find a function that gets a class by a player variable? I would have thought at this point it would be included. I need something like player:GetFaction();
     
  2. RJ

    RJ no pay Legend Clockwork Customer

    From what I've found, this is how you'd get a player's class:
    Code:
    local class = Clockwork.class:FindByID(player:Team());
    Change 'player' if needed, and you'd use 'class' however you'd want to use it (e.g. class.limit would give you that particular class' limit). I looked over how CW's classes work and they're stored on a player's team which is built into GMod, see here:
    http://wiki.garrysmod.com/page/Player/SetTeam
    http://wiki.garrysmod.com/page/Player/Team

    edit: "FindById" should've been "FindByID" in my code sample, I've corrected it.
     
    • Agree Agree x 2
    Last edited: Dec 26, 2016
  3. I see. I have tested this on the cl_hooks file in the schema. This error comes up despite it being a shared function in sh_class.lua?

    Code:
    [Clockwork:HL2 RP]
    The 'ScoreboardAdjustPlayerInfo' hook has failed to run.
    gamemodes/cwhl2rp/schema/cl_hooks.lua:350: attempt to call method 'FindById' (a nil value)
    
     
  4. RJ

    RJ no pay Legend Clockwork Customer

    Can you paste the code that you tested?
     
  5. I tested it again on the serverside and it said it was nil again.

    Code:
    -- Called just after a player spawns.
    function Schema:PostPlayerSpawn(player, lightSpawn, changeClass, firstSpawn)
        local class = Clockwork.class:FindById(player:Team());
    
        print(class);
    end;
    Code:
    [Clockwork:HL2 RP]
    The 'PostPlayerSpawn' hook has failed to run.
    gamemodes/cwhl2rp/schema/sv_hooks.lua:1646: attempt to call method 'FindById' (a nil value)
    
     
  6. duck

    duck Phant0m Legend

    It's FindByID, not FindById
     
    • Like Like x 1
  7. Ah, clever eye. I figured I was wrong as usual but I was lazy and C+P'd lol
     
  8. RJ

    RJ no pay Legend Clockwork Customer

    Thanks for pointing that out, I've corrected my code sample.
     

Previous Readers (Total: 0)