Fretta: Can't spawn with desired weapon

So I’m making a Fretta gamemode, my first gamemode of all. So no not going in the contest.

Anyway, I’m trying to make the players spawn with RPGs… But I can’t get it to work.

I’m doing this gamemode by editing Garry’s Laser Dance Fretta Gamemode. So in gamemode_name/gamemode/player_class/class_default.lua there was from line 12 to 16:


function CLASS:Loadout( pl )

	pl:Give( "weapon_laserdance" )
	
end

And I changed to:


function CLASS:Loadout( pl )

	pl:Give( "weapon_rpg" )
	
end

But I’m spawning with no weapon. How do I fix this? Everything else is working…

Oh yeah, I also got a trigger_hurt in my map and looks like Fretta ignores it? >.>

Really what you should do is create a totally new folder with your gamemode name and stuff then just copy the gamemode folder in Laser dance over and try it again. I fixed it by doing that.

Ok, I just realised the problem is not my gamemode. I tried playing the original Garry’s Laser Dance gamemode and I didn’t get the “weapon_laserdance” too. So it’s the gamemode’s problem… How to ensure players will get a weapon? I’m very new to this Lua thing… This gamemode is like an experiment… All I know from Lua is from the tutorial series in the Gmod Wiki… And that’s nothing compared to those professional Lua scripters…

Do you have the fretta gamemode in your folder? If so, it could conflict with the fretta included with gmod by default.

No, Fretta is not in my gamemodes folder, it’s only on Garry’s Mod GCF’s gamemode folder. Basicly it’s on Gmod’s GCF.

[editline]06:56PM[/editline]

I think I spoted the problem, after some search thru the Wiki, I think it’s:


ply:Give( "weapon_rpg" )

and NOT:


pl:Give( "weapon_rpg" )

Looks like Garry forgot the “y” on “ply:Give”.

[editline]07:12PM[/editline]

I’m getting another problem now. I’m getting:



LuaGetfile: Not Loading RPG Fights/gamemode/cl_init.lua
Couldn't include file 'RPG Fights/gamemode/cl_init.lua' (File not found)
**********************************************
**********************************************
********** COULDN'T LOAD GAMEMODE!! **********
**********************************************
**********************************************

There was a problem opening the gamemode file 'RPG Fights/gamemode/cl_init.lua'


Registering gamemode 'RPG Fights' derived from 'base'
Couldn't include file 'weapons/gmod_tool/object.lua' (File not found)
Couldn't include file 'weapons/gmod_tool/ghostentity.lua' (File not found)
Couldn't include file 'weapons/gmod_tool/object.lua' (File not found)
Couldn't include file 'weapons/gmod_tool/ghostentity.lua' (File not found)

And because of that the gamemode ain’t working, it’s just base gamemode, and the cl_init.lua file IS there. (gamemodes\RPG Fights\gamemode\cl_init.lua)

I’m also getting something about the map having no spawnpoints. But I do have them. On the gamemode Teams there is:


function GM:CreateTeams()

	if ( !GAMEMODE.TeamBased ) then return end
	
	team.SetUp( TEAM_LEETS, "RPG Leets", Color( 255, 128, 0 ), true )
	team.SetSpawnPoint( TEAM_LEETS, { "info_player_rpg_leet" } )
	
	team.SetUp( TEAM_WARRIORS, "RPG Warriors", Color( 255, 0, 0 ) )
	team.SetSpawnPoint( TEAM_WARRIORS, { "info_player_rpg_warrior" }, true )
	
	
	team.SetUp( TEAM_SPECTATOR, "Spectators", Color( 200, 200, 200 ), true )
	team.SetSpawnPoint( TEAM_SPECTATOR, { "info_player_start", "info_player_terrorist", "info_player_counterterrorist", "info_player_rpg_leet", "info_player_rpg_warrior" } ) 

end

And in the map I DID place info_player_rpg_leet and info_player_rpg_warrior. What’s wrong? =\

You have a space in your gamemode folders name.

Change it to

RPGFights/gamemode/…

Thanks that fixed it!

But now I still have some remaining problems. Like the player spawning on the center of the map instead of in the placed spawns and I’m still spawning without any weapon.

[editline]09:52PM[/editline]

I still get:



[PlayerSelectSpawn] Error! No spawn points!
ERROR: GAMEMODE:'PlayerLoadout' Failed: RPGFights/gamemode/player_class/class_default.lua:14: attempt to index global 'ply' (a nil value)


And what I have there is:


function CLASS:Loadout( pl )

	ply:Give( "weapon_rpg" )
	
end


function CLASS:Loadout( pl )

	pl:Give( "weapon_rpg" )
	
end

That didn’t work.

And I still get in console:



[PlayerSelectSpawn] Error! No spawn points!


Damn I’ll post my whole code so maybe someone can help me with it.

gamemode/shared.lua
[lua]
GM.Name = “RPG Fights”
GM.Author = “Dj Night”
GM.Email = “dj_n1ght@hotmail.com
GM.Website = “http://www.djnight.netne.net

DeriveGamemode( “fretta” )
IncludePlayerClasses()

GM.Help = “Blow the other team to hell!”
GM.TeamBased = true
GM.AllowAutoTeam = true
GM.AllowSpectating = true
GM.SelectClass = false
GM.SecondsBetweenTeamSwitches = 10
GM.GameLength = 10
GM.NoPlayerDamage = false
GM.NoPlayerSelfDamage = false
GM.NoPlayerTeamDamage = true
GM.NoPlayerPlayerDamage = false
GM.NoNonPlayerPlayerDamage = true
GM.TakeFragOnSuicide = false
GM.AddFragsToTeamScore = true
GM.RealisticFallDamage = true

GM.PlayerCanNoClip = false // When true, players can use noclip without sv_cheats

GM.SelectModel = false // Can players use the playermodel picker in the F1 menu?

TEAM_LEETS = 1
TEAM_WARRIORS = 2

function GM:CreateTeams()

if ( !GAMEMODE.TeamBased ) then return end

team.SetUp( TEAM_LEETS, "RPG Leets", Color( 255, 128, 0 ), true )
team.SetSpawnPoint( TEAM_LEETS, { "info_player_start_rpg_leet" } )

team.SetUp( TEAM_WARRIORS, "RPG Warriors", Color( 255, 0, 0 ) )
team.SetSpawnPoint( TEAM_WARRIORS, { "info_player_start_rpg_warrior" }, true )


team.SetUp( TEAM_SPECTATOR, "Spectators", Color( 200, 200, 200 ), true )
team.SetSpawnPoint( TEAM_SPECTATOR, { "info_player_start", "info_player_terrorist", "info_player_counterterrorist", "info_player_start_rpg_leet", "info_player_start_rpg_warrior" } ) 

end
[/lua]
I DID place the “info_player_start_rpg_leet” and “info_player_start_rpg_warrior” in my map!

gamemode/init.lua
[lua]
AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )

include( “shared.lua” )
[/lua]

gamemode/cl_init.lua
[lua]include( ‘shared.lua’ )

function GM:PositionScoreboard( ScoreBoard )

ScoreBoard:SetSize( 700, ScrH() - 100 )
ScoreBoard:SetPos( (ScrW() - ScoreBoard:GetWide()) / 2, 50 )

end[/lua]

gamemode/player_class/class_default.lua
[lua]
local CLASS = {}

CLASS.DisplayName = “Default Class”
CLASS.WalkSpeed = 250
CLASS.CrouchedWalkSpeed = 0.2
CLASS.RunSpeed = 450
CLASS.DuckSpeed = 350
CLASS.JumpPower = 250
CLASS.DrawTeamRing = true

function CLASS:Loadout( pl )

pl:Give( "weapon_rpg" )

end

player_class.Register( “Default”, CLASS )[/lua]

I placed a info_player_start in each team spawn in my map and now it works, I get a RPG. But now, how to make custom spawns? I don’t want the teams to be spawning on the oposite team’s spawn.

And also this doesn’t seem to be working:

[lua]function GM:PlayerLoadout( ply )

if ply:Team() == 1 then
ply:SetModel( “models/player/gman_high.mdl” )

elseif ply:Team() == 2 then
ply:SetModel( “models/player/breen.mdl” )

end

end[/lua]

(placed in shared.lua)

EDIT: Instead of Dumb-Rating me someone could help, after all I’m not experienced in lua.

bump for help, please

Use pastebin when posting large amounts of code. I’m not sure about custom spawns, I never made any. There is probably a good example of it in the GMod Beta SVN. I’ll go take a look and see.

[editline]11:47PM[/editline]

You could always use “info_player_terrorist” “info_player_rebel” and “info_player_counterterrorist” “info_player_combine” for 2 teams.

the problem with your “info_player_start_rpg_leet” and “info_player_start_rpg_warrior” spawnpoints is that the entitity dosent exist

ok I get it but what about zombie survival? It uses “info_player_zombie” and"info_player_human"…

[editline]01:43PM[/editline]

at least it used to be like that

The Counter-Strike player spawns worked. But now I have another problem, the gamemode is fully operational in Single Player, but when I run it in my server, the server’s gamemode is Sandbox and I spawn with my physgun. And the most strange is that the ScoreBoard is the fretta one with the RPGFights gamemode teams in it. :S

You have to make a point entity.
[Entity Hooks

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?search=Entity Hooks)

For a spawn point you don’t have to do anything really but create the entity. Here is an example from 9/10 in the Garry’s Mod Beta SVN.

gamemodes/910/entities/entities/info_player_blue/init.lua
[lua]ENT.Type = “point”

function ENT:Initialize()
end

function ENT:KeyValue(key, value)
end
[/lua]

Now the entity info_player_blue exists, so you can place it in a map and have blue team spawn there.

Oh ok, I get it and by the way I also fixed the gamemode not working on my server, but now I have another problem.

I started playing RPGFights alone in my server just to perfectly test it, and then I had to go away for a bit, when I got back to my computer, I was somehow connecting to my server, like joining, and when it finished, I was in RPGFights in gm_construct. What the hell? How do I make so it only plays on my map, and what if I want to make so it never changes gamemode? Is there a way? or only if I do a gamemode from scratch?

[editline]06:13PM[/editline]

It happened again, I’m on RPGFights in gm_flatgrass.

Basicly, is there any possible way of making the gamemode not change without having to do it from scratch? I’ve seen some servers with Deathrun but then change by vote and other servers that are Deathrun 24/7…