• Team setup bug?
    3 replies, posted
Hello guys. I'm having problems with team.Setup Here's my code: [CODE] include("player_class/humans.lua") function GM:CreateTeams() HUMANS = 2 team.SetUp(HUMANS, "Humans", Color(150, 205, 255)) team.SetSpawnPoint(HUMANS, PlayerSpawns) team.SetClass(HUMANS, {"Humans"}) end [/CODE] But when I change Humans.lua. It seems to not affect player's health/Speed/MaxHealth or player can turn on his flashlight Here's my humans.lua [CODE] -- Create new class local PLAYER = {} -- Some settings for the class PLAYER.DisplayName = "Humans" PLAYER.CrouchedWalkSpeed = 0.3 -- 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.WalkSpeed = 240 PLAYER.RunSpeed = 240 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 = true -- Do we drop our weapon when we die PLAYER.TeammateNoCollide = false -- Do we collide with teammates or run straight through them PLAYER.AvoidPlayers = false -- Automatically swerves around other players PLAYER.UseVMHands = true -- Uses viewmodel hands function GM:PlayerLoadout(ply) end player_manager.RegisterClass( "Humans", PLAYER, "player_default") [/CODE] and my spawn code [CODE] for k, v in pairs(player.GetAll()) do v:UnSpectate() SetHuman(v) v:Spawn() end [/CODE]
Most likely an error... Replace SetHuman( v ) with v:SetTeam( HUMAN ); Additionally you may have your spectate system not quite right; take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/spectating_players_system.lua.html[/url] For the player class to work you need to set it up and call it in PlayerSpawn ( player_manager ); see base game-mode for code on using classes ( not many use them, they're poorly integrated ).
[QUOTE=Acecool;46866169]Most likely an error... Replace SetHuman( v ) with v:SetTeam( HUMAN ); Additionally you may have your spectate system not quite right; take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/spectating_players_system.lua.html[/url] For the player class to work you need to set it up and call it in PlayerSpawn ( player_manager ); see base game-mode for code on using classes ( not many use them, they're poorly integrated ).[/QUOTE] Is no a error, set human is a function that i created, there's a team called HUMANS, but they are different things. What do you Sugest to create classes? Create my own system? (I'm already doing this). The only thing that I'm having problems is with team setup. Another question: Can You help me with spectator system? The system that you send me don't give the player the option to set spectator mod, and also, I want to make a spectator mod showing spectated player
The spectator thing I sent you is an old example I wrote up which shows the absolute minimum ( with a few helper functions ) required to have the client join the server as a spectator ... ie prevent spawning on enter to allow the game-mode to setup custom actions before spawning player. I need some more information.. What game-mode are you modifying, or are you creating a new one? If you're creating one: What base are you using? You'd create GM functions to replace functionality of the base ( you can alter behavior by calling the base-class in the GM functions you overwrite ); You'd use hook.Add to alter behavior. You have a lot of flexibility! But, when Overwriting GM functions, some GM functions use hook.Call for sequential behavior ( Example: GM:PlayerSpawn gets run, and it hook.Calls PlayerSetModel [ which handles setting the player model ], and it also hook.Calls PlayerLoadout [ which handles the "loadout".. ie armor, weapons, etc.. ] ). Make sure you read your base game-mode code to understand what is happening. You may be better off copying your base game-mode function over. If you're modifying one: What game-mode is it? Don't overwrite GM functions; use hook.Add... If you need to edit core files, create an addon and overwrite the file via addon ( the same way darkrpmodification does it ) that way core files stay the same, and edits don't get lost in updates. Now. For player classes. They're redundant because we already have the base functions and we have hooks for modifying behavior. A lot of people don't use them and a lot find them annoying... You'd probably be quicker to set up your own system. Examples of handling things the "class" system does: Setting up specific player options based on "class" but code being implemented where the action is happening: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/player_classes/table_of_data_alternative_to_player_classes.lua.html[/url] That is a decent example showing a "class" system where instead of setting player_default class, or whatever, we use the team the player is on. Additionally you won't need to repeat code; with player classes there's a lot that gets repeated. Giving guns based on usergroup ( "Pay2Win" is never good ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_gamemode_logic/give_weapons_based_on_group.lua.html[/url] Using the class system: [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/player.lua#lines-270-271[/url] [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/player.lua#lines-287[/url] [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/base/gamemode/player.lua#lines-317[/url] etc... It works exactly like the hook system, except instead of calling up to many of the same hooks, you call one function if it exists; it could be useful given certain circumstances... Default class: [url]https://github.com/garrynewman/garrysmod/blob/28b7be5cda7fdde1a19c59d43408dcb2df357fd8/garrysmod/gamemodes/base/gamemode/player_class/player_default.lua[/url]
Sorry, you need to Log In to post a reply to this thread.