• Problem with player classes
    2 replies, posted
I have a player class, player_infantry in gamemodes/vault/gamemode/player_class/. However when the player spawns, I get this error [CODE]SetPlayerClass - attempt to use unknown player class player_infantry[/CODE] I do not understand what I am doing wrong, I followed both the tutorial and the base source exactly vault/gamemode/init.lua [CODE]AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") TEAM_ATTACKERS = 2 TEAM_DEFENDERS = 3 TEAM_SEERS = 1 function GM:PlayerInitialSpawn(ply) ply:SetTeam(TEAM_SEERS) local RDM=math.random(TEAM_ATTACKERS,TEAM_DEFENDERS) ply:SetTeam(RDM) ATT=team.NumPlayers(TEAM_ATTACKERS) DEF=team.NumPlayers(TEAM_DEFENDERS) if ATT>DEF then ply:SetTeam(TEAM_DEFENDERS) elseif DEF>ATT then ply:SetTeam(TEAM_ATTACKERS) end if ply:Team()==TEAM_ATTACKERS then ply:PrintMessage(HUD_PRINTTALK,"You are now a member of the Attackers") elseif ply:Team()==TEAM_DEFENDERS then ply:PrintMessage(HUD_PRINTTALK,"You are now a member of the Defenders") elseif ply:Team()==TEAM_SEERS then ply:PrintMessage(HUD_PRINTTALK,"You are now a seer.") else ply:PrintMessage(HUD_PRINTTALK,"You was switched to an unknown team :(") end end function GM:PlayerShouldTakeDamage(ply,victim) if ply:IsPlayer()&&victim:IsPlayer() then if ply:Team()==victim:Team() then return false end end return true end function GM:PlayerSpawn(ply) player_manager.SetPlayerClass(ply,"player_infantry") end function GM:ShowSpare1(ply) if(ply:IsPlayer()) then local trace = {} trace.start = ply:EyePos() trace.endpos = trace.start + ply:GetAimVector() * 85 trace.filter = ply local tr = util.TraceLine(trace) if ply:GetAmmoCount("Xbowbolt")>=1 then ply:RemoveAmmo(1,"Xbowbolt") if SERVER then local bag=ents.Create("item_ammo_smg1") bag:SetPos(tr.HitPos) bag:SetOwner(ply) bag:Spawn() bag:Activate() end end end end[/CODE] vault/gamemode/shared.lua [CODE]include("player_class/player_infantry.lua") TEAM_ATTACKERS = 2 TEAM_DEFENDERS = 3 TEAM_SEERS = 1 GM.Name = "Vault Invasion" GM.Author = "LemonLake" GM.Email = "lemonplays@gmail.com" GM.Website = "http://www.youtube.com/playfullemon" function GM:Initialize() self.BaseClass.Initialize( self ) end function GM:RoundStart() Msg("Checking for map ammo positions") // Check for, load and check ammo spawn file. Msg("Loading map ammo positions") end team.SetUp(TEAM_ATTACKERS,"Attackers",Color(255,0,0)) team.SetUp(TEAM_DEFENDERS,"Defenders",Color(0,255,0)) team.SetUp(TEAM_SEERS,"Seers",Color(155,155,155)) util.PrecacheModel("models/Humans/Group01/male_07.mdl") // Defenders Infantry util.PrecacheModel("models/Humans/Group03/male_06.mdl") // Attackers Infantry[/CODE] vault/gamemode/player_class/player_infantry.lua (I tried copying the base one instead of from the tutorial, but its pretty much the same) [CODE]AddCSLuaFile() include( 'taunt_camera.lua' ) TEAM_ATTACKERS = 2 TEAM_DEFENDERS = 3 TEAM_SEERS = 1 local PLAYER = {} PLAYER.DisplayName = "Infantry" PLAYER.WalkSpeed = 400 -- How fast to move when not running PLAYER.RunSpeed = 600 -- How fast to move when running PLAYER.CrouchedWalkSpeed = 0.2 -- Multiply move speed by this when crouching PLAYER.DuckSpeed = 0.3 -- How fast to go from not ducking, to ducking PLAYER.UnDuckSpeed = 0.3 -- How fast to go from ducking, to not ducking PLAYER.JumpPower = 200 -- How powerful our jump should be PLAYER.CanUseFlashlight = true -- Can we use the flashlight PLAYER.MaxHealth = 100 -- Max health we can have PLAYER.StartHealth = 100 -- How much health we start with PLAYER.StartArmor = 0 -- How much armour we start with PLAYER.DropWeaponOnDie = false -- Do we drop our weapon when we die PLAYER.TeammateNoCollide = true -- Do we collide with teammates or run straight through them PLAYER.AvoidPlayers = true -- Automatically swerves around other players -- -- Set up the network table accessors -- function PLAYER:SetupDataTables() end -- -- Called when the class object is created (shared) -- function PLAYER:Init() end -- -- Called serverside only when the player spawns -- function PLAYER:Spawn() end -- -- Called on spawn to give the player their default loadout -- function PLAYER:Loadout() self.Player:Give("weapon_real_cs_tmp") self.Player:Give("weapon_real_cs_five-seven") self.Player:RemoveAllAmmo() self.Player:GiveAmmo(32,"pistol",false) self.Player:GiveAmmo(256,"SMG1",false) self.Player:GiveAmmo(3,"grenade",false) self.Player:GiveAmmo(1,"Xbowbolt",false) if self.Player:Team()==2 then self.Player:SetModel("models/player/Group03/male_06.mdl") elseif self.Player:Team()==3 then self.Player:SetModel("models/player/Group01/male_07.mdl") end end -- Clientside only function PLAYER:CalcView( view ) end -- Setup the player's view function PLAYER:CreateMove( cmd ) end -- Creates the user command on the client function PLAYER:ShouldDrawLocal() end -- Return true if we should draw the local player -- Shared function PLAYER:StartMove( cmd, mv ) end -- Copies from the user command to the move function PLAYER:Move( mv ) end -- Runs the move (can run multiple times for the same client) function PLAYER:FinishMove( mv ) end -- Copy the results of the move back to the Player player_manager.RegisterClass( "plyaer_infantry", PLAYER, nil )[/CODE] I'd appreciate any and all help regarding this issue, thank you
At the bottom of your player infantry code you have a typo, change [code]player_manager.RegisterClass( "plyaer_infantry", PLAYER, nil )[/code] to [code]player_manager.RegisterClass( "player_infantry", PLAYER, nil )[/code]
[QUOTE=Brodi816;39278909]At the bottom of your player infantry code you have a typo, change [code]player_manager.RegisterClass( "plyaer_infantry", PLAYER, nil )[/code] to [code]player_manager.RegisterClass( "player_infantry", PLAYER, nil )[/code][/QUOTE] I fixed that, however I still have the same issue. I also tried it with player_default instead of player_infantry - the error never occurred however the script was never called. [B][EDIT][/B] I am going to try placing player_infantry in my /gamemode/ folder. Failed. [B][EDIT 2][/B] I have switched to usage of multiple teams instead. Thanks anyway
Sorry, you need to Log In to post a reply to this thread.