I am making a deathmatch game that has a couple new things and guns that shoot lasers instead of bullets and am using Fretta to code it. I followed several guides on the Fretta gmod wiki but i cant seem to get classes to work. whenever i launch the gamemode i constantly get an error and the gamemode is broken. I am also trying to change the vote gamemode in Fretta and make it a vote for maps but once again everytime i code it, it breaks. Sorry if this seems kinda nooby but i cant figure it out. =/
fretta by default votes for the map after the game mode selection so just have your game mode then in the info.txt file under fretta maps you can change ^gm_ and ^ld_ to what you want your gamemodes maps prefix to be fro example using ^td_ would show maps like "td_test" and "td_map".
if you could post one of your classes and the shared.lua file i could be more help with the game mode being broken because i had similar problems with fretta.
heres the class
[code]
local CLASS = {} // This defines the class's table. We need it to enter the following values
CLASS.DisplayName = "Soldier" // This is the name of the class, for display purposes
CLASS.WalkSpeed = 400 // This is the walk speed of the class (without shift)
CLASS.CrouchedWalkSpeed = 0.2 // This is the amount that the walk speed is multiplied by while crouching
CLASS.RunSpeed = 400 // This is the sprinting speed of the class (with shift)
CLASS.DuckSpeed = 0.2 // This is the speed that the class moves from standing to crouching (in seconds)
CLASS.JumpPower = 200 // This is the jump power of the class (default: 160)
CLASS.PlayerModel = "models/player.mdl" // This is the player model that is set for this class
CLASS.DrawTeamRing = true // Whether or not colored team rings are displayed under players with this class
CLASS.DrawViewModel = true // Whether or not a player's weapon appears in the first person view using this class
CLASS.MaxHealth = 100 // This is the maximum health of a player with this class
CLASS.StartHealth = 100 // This is how much health the player spawns with
CLASS.StartArmor = 0 // This is the amount of armor a player spawns with
CLASS.DropWeaponOnDie = true // Whether or not a player's weapon gets dropped upon death
CLASS.TeammateNoCollide = true // Whether or not a player should be able to walk through his teammates
CLASS.AvoidPlayers = true // Push players that are able to walk through this player away?
CLASS.Selectable = true // When false, this class cannot be chosen from the select class menu
CLASS.FullRotation = false // Allow the player's model to rotate completely with their view (i.e. looking 90 degrees up will rotate your player model 90 degrees)
function CLASS:Loadout( pl ) // This is called when the player is given their equipment
pl:GiveAmmo( 255, "Pistol", true )
pl:Give( "weapon_pistol" )
end
function CLASS:OnSpawn( pl ) //
end
function CLASS:Move( pl, mv ) //
end
function CLASS:OnKeyPress( pl, key ) //
end
function CLASS:OnKeyRelease( pl, key ) //
end
player_class.Register( "Soldier", CLASS ) //
[/code]
just the first class i came up with.
heres the shared.lua
[code]
/*
shared.lua - Shared Component
-----------------------------------------------------
This is the shared component of your gamemode, a lot of the game variables
can be changed from here.
*/
include( "player_class.lua" )
include( "player_extension.lua" )
include( "class_default.lua" )
include( "player_colours.lua" )
IncludePlayerClasses()
fretta_voting = CreateConVar( "fretta_voting", "1", { FCVAR_REPLICATED, FCVAR_NOTIFY, FCVAR_ARCHIVE } )
GM.Name = "Future Wars"
GM.Author = "EvilElmo and Agent Weenis"
GM.Email = "skeletonsrfail@hotmail.com"
GM.Website = "none"
GM.Help = "No Help Available"
GM.TeamBased = true // Team based game or a Free For All game?
GM.AllowAutoTeam = true // Allow auto-assign?
GM.AllowSpectating = true // Allow people to spectate during the game?
GM.SecondsBetweenTeamSwitches = 10 // The minimum time between each team change?
GM.GameLength = 60 // The overall length of the game
GM.RoundLimit = 4 // Maximum amount of rounds to be played in round based games
GM.VotingDelay = 5 // Delay between end of game, and vote. if you want to display any extra screens before the vote pops up
GM.NoPlayerSuicide = true // Set to true if players should not be allowed to commit suicide.
GM.NoPlayerDamage = false // Set to true if players should not be able to damage each other.
GM.NoPlayerSelfDamage = false // Allow players to hurt themselves?
GM.NoPlayerTeamDamage = true // Allow team-members to hurt each other?
GM.NoPlayerPlayerDamage = false // Allow players to hurt each other?
GM.NoNonPlayerPlayerDamage = false // Allow damage from non players (physics, fire etc)
GM.NoPlayerFootsteps = false // When true, all players have silent footsteps
GM.PlayerCanNoClip = false // When true, players can use noclip without sv_cheats
GM.TakeFragOnSuicide = true // -1 frag on suicide
GM.MaximumDeathLength = 0 // Player will repspawn if death length > this (can be 0 to disable)
GM.MinimumDeathLength = 30 // Player has to be dead for at least this long
GM.AutomaticTeamBalance = true // Teams will be periodically balanced
GM.ForceJoinBalancedTeams = true // Players won't be allowed to join a team if it has more players than another team
GM.RealisticFallDamage = false // Set to true if you want realistic fall damage instead of the fix 10 damage.
GM.AddFragsToTeamScore = true // Adds player's individual kills to team score (must be team based)
GM.NoAutomaticSpawning = true // Players don't spawn automatically when they die, some other system spawns them
GM.RoundBased = true // Round based, like CS
GM.RoundLength = 300 // Round length, in seconds
GM.RoundPreStartTime = 5 // Preperation time before a round starts
GM.RoundPostLength = 8 // Seconds to show the 'x team won!' screen at the end of a round
GM.RoundEndsWhenOneTeamAlive = true // CS Style rules
GM.SelectClass = true // Allow players to select classes
GM.EnableFreezeCam = true // TF2 Style Freezecam
GM.DeathLingerTime = 4 // The time between you dying and it going into spectator mode, 0 disables
GM.SelectModel = true // Can players use the playermodel picker in the F1 menu?
GM.SelectColor = false // Can players modify the colour of their name? (ie.. no teams)
GM.PlayerRingSize = 48 // How big are the colored rings under the player's feet (if they are enabled) ?
GM.HudSkin = "SimpleSkin" // The Derma skin to use for the HUD components
GM.SuicideString = "died" // The string to append to the player's name when they commit suicide.
GM.DeathNoticeDefaultColor = Color( 255, 128, 0 ); // Default colour for entity kills
GM.DeathNoticeTextColor = color_white; // colour for text ie. "died", "killed"
GM.ValidSpectatorModes = { OBS_MODE_CHASE, OBS_MODE_IN_EYE, OBS_MODE_ROAMING } // The spectator modes that are allowed
GM.ValidSpectatorEntities = { "player" } // Entities we can spectate, players being the obvious default choice.
GM.CanOnlySpectateOwnTeam = true; // you can only spectate players on your own team
DeriveGamemode( "fretta" )
TEAM_BLUE = 1
TEAM_RED = 2
/*---------------------------------------------------------
Name: gamemode:CreateTeams()
Desc: Set up all your teams here. Note - HAS to be shared.
---------------------------------------------------------*/
function GM:CreateTeams()
if ( !GAMEMODE.TeamBased ) then return end
team.SetUp( TEAM_BLUE, "Blue Team", Color( 80, 150, 255 ) )
team.SetSpawnPoint( TEAM_BLUE, { "info_player_start", "info_player_terrorist", "info_player_rebel", "info_player_deathmatch" } )
team.SetClass( TEAM_BLUE, { "Soldier" } ) //
team.SetUp( TEAM_RED, "Red Team", Color( 255, 80, 80 ) )
team.SetSpawnPoint( TEAM_RED, { "info_player_start", "info_player_terrorist", "info_player_rebel", "info_player_deathmatch" } )
team.SetClass( TEAM_RED, { "Soldier" } ) //
team.SetUp( TEAM_SPECTATOR, "Spectators", Color( 200, 200, 200 ), true )
team.SetSpawnPoint( TEAM_SPECTATOR, "info_player_start" )
team.SetClass( TEAM_SPECTATOR, { "Spectator" } )
end
function GM:InGamemodeVote()
return GetGlobalBool( "InGamemodeVote", false )
end
/*---------------------------------------------------------
Name: gamemode:TeamHasEnoughPlayers( Number teamid )
Desc: Return true if the team has too many players.
Useful for when forced auto-assign is on.
---------------------------------------------------------*/
function GM:TeamHasEnoughPlayers( teamid )
local PlayerCount = team.NumPlayers( teamid )
// Don't let them join a team if it has more players than another team
if ( GAMEMODE.ForceJoinBalancedTeams ) then
for id, tm in pairs( team.GetAllTeams() ) do
if ( id > 0 && id < 1000 && team.NumPlayers( id ) < PlayerCount && team.Joinable(id) ) t
You have DeriveGamemode( "fretta" ) in the middle try to put it at the top and make a second class so that you can test the select a class since you only have one, I don't know for sure though. Here's my shared for my gamemode with classes that works maybe compare it if you want.[code]
GM.Name = "Laser Dance"
GM.Author = "garry"
GM.Email = ""
GM.Website = ""
DeriveGamemode( "fretta" )
IncludePlayerClasses()
GM.Help = "Shoot the other team!\n\nShoot downwards to launch yourself into the sky."
GM.TeamBased = true
GM.AllowAutoTeam = true
GM.AllowSpectating = true
GM.SelectClass = true
GM.SecondsBetweenTeamSwitches = 10
GM.GameLength = 10
GM.NoPlayerDamage = false
GM.NoPlayerSelfDamage = false
GM.NoPlayerTeamDamage = true
GM.NoPlayerPlayerDamage = false
GM.NoNonPlayerPlayerDamage = false
GM.TakeFragOnSuicide = false
GM.AddFragsToTeamScore = true
TEAM_ORANGE = 1
TEAM_GREEN = 2
function GM:CreateTeams()
if ( !GAMEMODE.TeamBased ) then return end
team.SetUp( TEAM_ORANGE, "Team Orange", Color( 255, 200, 50 ), true )
team.SetSpawnPoint( TEAM_ORANGE, {"info_player_terrorist"} )
team.SetClass( TEAM_ORANGE, { "Assault", "Demo", "Sniper", "Medic", "Scout" } )
team.SetUp( TEAM_GREEN, "Team Green", Color( 70, 230, 70 ) )
team.SetSpawnPoint( TEAM_GREEN, { "info_player_counterterrorist" }, true )
team.SetClass( TEAM_GREEN, { "Assault", "Demo", "Sniper", "Medic", "Scout" } )
team.SetUp( TEAM_SPECTATOR, "Spectators", Color( 200, 200, 200 ), true )
team.SetSpawnPoint( TEAM_SPECTATOR, { "info_player_start", "info_player_terrorist", "info_player_counterterrorist" } )
end
[/code]
thanks man. ill test it right now =D
[editline]10:38PM[/editline]
ok, i tried it and i didnt get any errors but i cant select them. i have the select classes on but it wont select
do you have in this line [code]team.SetClass( TEAM_RED, { "Soldier" } )[/code] more classes like this [code]team.SetClass( TEAM_RED, { "Soldier", "Sniper"} )[/code]
ok i got it to work but now i got this.
ERROR: GAMEMODE:'PlayerRequestClass' Failed: Futurewars/gamemode/init.lua:264: attempt to concatenate a nil value
this happened when i opened change team/class and clicked a diff class. also i dont spawn with weapons
ah ok can you post your init.lua for me?
[QUOTE=??????;18895556]ah ok can you post your init.lua for me?[/QUOTE]
yea. sorry im taking so long to respond. i was playing games.
[code]
/*
init.lua - Server Component
-----------------------------------------------------
The entire server side bit of Fretta starts here.
*/
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( 'skin.lua' )
AddCSLuaFile( 'player_class.lua' )
AddCSLuaFile( 'class_default.lua' )
AddCSLuaFile( 'cl_splashscreen.lua' )
AddCSLuaFile( 'cl_selectscreen.lua' )
AddCSLuaFile( 'cl_gmchanger.lua' )
AddCSLuaFile( 'cl_help.lua' )
AddCSLuaFile( 'player_extension.lua' )
AddCSLuaFile( 'vgui/vgui_hudlayout.lua' )
AddCSLuaFile( 'vgui/vgui_hudelement.lua' )
AddCSLuaFile( 'vgui/vgui_hudbase.lua' )
AddCSLuaFile( 'vgui/vgui_hudcommon.lua' )
AddCSLuaFile( 'vgui/vgui_gamenotice.lua' )
AddCSLuaFile( 'vgui/vgui_scoreboard.lua' )
AddCSLuaFile( 'vgui/vgui_scoreboard_team.lua' )
AddCSLuaFile( 'vgui/vgui_scoreboard_small.lua' )
AddCSLuaFile( 'vgui/vgui_vote.lua' )
AddCSLuaFile( 'cl_hud.lua' )
AddCSLuaFile( 'cl_deathnotice.lua' )
AddCSLuaFile( 'cl_scores.lua' )
AddCSLuaFile( 'cl_notify.lua' )
AddCSLuaFile( 'player_colours.lua' )
include( "shared.lua" )
include( "sv_gmchanger.lua" )
include( "sv_spectator.lua" )
include( "round_controller.lua" )
include( "utility.lua" )
GM.ReconnectedPlayers = {}
function GM:Initialize()
if ( GAMEMODE.GameLength > 0 ) then
timer.Simple( GAMEMODE.GameLength * 60, function() GAMEMODE:EndOfGame( true ) end )
SetGlobalFloat( "GameEndTime", CurTime() + GAMEMODE.GameLength * 60 )
end
// If we're round based, wait 5 seconds before the first round starts
if ( GAMEMODE.RoundBased ) then
timer.Simple( 10, function() GAMEMODE:StartRoundBasedGame() end )
end
if ( GAMEMODE.AutomaticTeamBalance ) then
timer.Create( "CheckTeamBalance", 30, 0, function() GAMEMODE:CheckTeamBalance() end )
end
end
function GM:Think()
self.BaseClass:Think()
for k,v in pairs( player.GetAll() ) do
local Class = v:GetPlayerClass()
if ( !Class ) then return end
v:CallClassFunction( "Think" )
end
// Game time related
if( !GAMEMODE.IsEndOfGame && ( !GAMEMODE.RoundBased || ( GAMEMODE.RoundBased && GAMEMODE:CanEndRoundBasedGame() ) ) && CurTime() >= GAMEMODE.GetTimeLimit() ) then
GAMEMODE:EndOfGame( true )
end
end
/*---------------------------------------------------------
Name: gamemode:CanPlayerSuicide( Player ply )
Desc: Is the player allowed to commit suicide?
---------------------------------------------------------*/
function GM:CanPlayerSuicide( ply )
if( ply:Team() == TEAM_UNASSIGNED || ply:Team() == TEAM_SPECTATOR ) then
return false // no suicide in spectator mode
end
return !GAMEMODE.NoPlayerSuicide
end
/*---------------------------------------------------------
Name: gamemode:PlayerSwitchFlashlight( Player ply, Bool on )
Desc: Can we turn our flashlight on or off?
---------------------------------------------------------*/
function GM:PlayerSwitchFlashlight( ply, on )
if ( ply:Team() == TEAM_SPECTATOR || ply:Team() == TEAM_UNASSIGNED || ply:Team() == TEAM_CONNECTING ) then
return not on
end
return ply:CanUseFlashlight()
end
/*---------------------------------------------------------
Name: gamemode:PlayerInitialSpawn( Player ply )
Desc: Our very first spawn in the game.
---------------------------------------------------------*/
function GM:PlayerInitialSpawn( pl )
pl:SetTeam( TEAM_UNASSIGNED )
pl:SetPlayerClass( "Spectator" )
pl.m_bFirstSpawn = true
pl:UpdateNameColor()
GAMEMODE:CheckPlayerReconnected( pl )
end
function GM:CheckPlayerReconnected( pl )
if table.HasValue( GAMEMODE.ReconnectedPlayers, pl:UniqueID() ) then
GAMEMODE:PlayerReconnected( pl )
end
end
/*---------------------------------------------------------
Name: gamemode:PlayerReconnected( Player ply )
Desc: Called if the player has appeared to have reconnected.
---------------------------------------------------------*/
function GM:PlayerReconnected( pl )
// Use this hook to do stuff when a player rejoins and has been in the server previously
end
function GM:PlayerDisconnected( pl )
table.insert( GAMEMODE.ReconnectedPlayers, pl:UniqueID() )
self.BaseClass:PlayerDisconnected( pl )
end
function GM:ShowHelp( pl )
pl:SendLua( "GAMEMODE:ShowHelp()" )
end
function GM:PlayerSpawn( pl )
pl:UpdateNameColor()
// The player never spawns straight into the game in Fretta
// They spawn as a spectator first (during the splash screen and team picking screens)
if ( pl.m_bFirstSpawn ) then
pl.m_bFirstSpawn = nil
if ( pl:IsBot() ) then
GAMEMODE:AutoTeam( pl )
// The bot doesn't send back the 'seen splash' command, so fake it.
if ( !GAMEMODE.TeamBased && !GAMEMODE.NoAutomaticSpawning ) then
pl:Spawn()
end
else
pl:StripWeapons()
GAMEMODE:PlayerSpawnAsSpectator( pl )
// Follow a random player until we join a team
if ( #player.GetAll() > 1 ) then
pl:Spectate( OBS_MODE_CHASE )
pl:SpectateEntity( table.Random( player.GetAll() ) )
end
end
return
end
pl:CheckPlayerClassOnSpawn()
if ( GAMEMODE.TeamBased && ( pl:Team() == TEAM_SPECTATOR || pl:Team() == TEAM_UNASSIGNED ) ) then
GAMEMODE:PlayerSpawnAsSpectator( pl )
return
end
// Stop observer mode
pl:UnSpectate()
// Call item loadout function
hook.Call( "PlayerLoadout", GAMEMODE, pl )
// Set player model
hook.Call( "PlayerSetModel", GAMEMODE, pl )
// Call class function
pl:OnSpawn()
end
function GM:PlayerLoadout( pl )
pl:CheckPlayerClassOnSpawn()
pl:OnLoadout()
// Switch to prefered weapon if they have it
local cl_defaultweapon = pl:GetInfo( "cl_defaultweapon" )
if ( pl:HasWeapon( cl_defaultweapon ) ) then
pl:SelectWeapon( cl_defaultweapon )
end
end
function GM:PlayerSetModel( pl )
pl:OnPlayerModel()
end
function GM:AutoTeam( pl )
if ( !GAMEMODE.AllowAutoTeam ) then return end
if ( !GAMEMODE.TeamBased ) then return end
GAMEMODE:PlayerRequestTeam( pl, team.BestAutoJoinTeam() )
end
concommand.Add( "autoteam", function( pl, cmd, args ) hook.Call( "AutoTeam", GAMEMODE, pl ) end )
function GM:PlayerRequestClass( ply, class, disablemessage )
local Classes = team.GetClass( ply:Team() )
if (!Classes) then return end
local RequestedClass = Classes[ class ]
if (!RequestedClass) then return end
if ( ply:Alive() && SERVER ) then
if ( ply.m_SpawnAsClass && ply.m_SpawnAsClass == RequestedClass ) then return end
ply.m_SpawnAsClass = RequestedClass
if ( !disablemessage ) then
ply:ChatPrint( "Your class will change to '".. player_class.GetClassName( RequestedClass ) .. "' when you respawn" )
end
else
self:PlayerJoinClass( ply, RequestedClass )
ply.m_SpawnAsClass = nil
end
end
concommand.Add( "changeclass", function( pl, cmd, args ) hook.Call( "PlayerRequestClass", GAMEMODE, pl, tonumber(args[1]) ) end )
local function SeenSplash( ply )
if ( ply.m_bSeenSplashScreen ) then return end
ply.m_bSeenSplashScreen = true
if ( !GAMEMODE.TeamBased && !GAMEMODE.NoAutomaticSpawning ) then
ply:KillSilent()
end
end
concommand.Add( "seensplash", SeenSplash )
function GM:PlayerJoinTeam( ply, teamid )
local iOldTeam = ply:Team()
if ( ply:Alive() ) then
if ( iOldTeam == TEAM_SPECTATOR || (iOldTeam == TEAM_UNASSIGNED && GAMEMODE.TeamBased) ) then
ply:KillSilent()
else
ply:Kill()
end
end
ply:SetTeam( teamid )
ply.LastTeamSwitch = RealTime()
local Classes = team.GetClass( teamid )
// Needs to choose class
if ( Classes && #Classes > 1 ) then
if ( ply:IsBot() || !GAMEMODE.SelectClass ) then
GAMEMODE:PlayerRequestClass( ply, math.random( 1, #Classes ) )
else
ply.m_fnCallAfterClassChoose = function()
ply.DeathTime = CurTime()
GAME
Ok you said you were wanting a deathmatch gamemode and with fretta that is insanely easy and im seeing a ton of code in you init.lua that im betting is useless because fretta already has most of that for you. I am uploading a base of a team deathmatch game that works cause i think somewhere your code was messed up. I uploaded a simple team deathmatch for fretta with classes that you can use if you want. here's the link [url]http://www.garrysmod.org/downloads/?a=view&id=85647[/url]
thanks a lot. ill mess with this and test it.
np take a look at the soldier classes gun it might be similiar to what you want in your gamemode
Sorry, you need to Log In to post a reply to this thread.