I am getting an error:
[gamemodes\jailbreak\gamemode\init.lua:85] 'then' expected near '='
I am making a Jail Break gamemode. I tried to create a system, where if there already was a warden, you couldn't be the warden.
Here is my code:
[lua]
----------Adding Client Side Lua Files
AddCSLuaFile("cl_init.lua") --The client downloads "cl_init.lua"
AddCSLuaFile("shared.lua") --The client downloads "shared.lua"
----------Including----------
include('shared.lua') --The server loads "shared.lua"
----------Initial Spawn----------
function GM:PlayerInitialSpawn(ply) --When the player first joins and spawns
ply:SetTeam(1) --Set the player's team to "Prisoners"
end
----------Loadouts----------
function GM:PlayerLoadout(ply) --When the player spawns and the gamemode wants us to define his loadout
if ply:Team() == 1 then --If the player's team is "Prisoners" then
ply:Give("weapon_mad_fists") --Give them fists
ply:SetModel("models/player/group01/male_01.mdl") --Set their model to Male 1
ply:SetWalkSpeed(250) --Set their walk speed to 250 units
ply:SetRunSpeed(500) --Set their run speed to 500 units
ply:SetGravity(1.00) --Set their gravity to 1
ply:SetMaxHealth(100) --Set their max health to 100
elseif ply:Team() == 2 then --If the player's team is "Guards" then
ply:Give("weapon_mad_knife") --Give them a knife
ply:Give("weapon_mad_glock") --Give them a Glock 18
ply:Give("weapon_mad_m4") --Give them an M4A1
ply:SetModel("models/player/riot.mdl") --Set their model to a counter terrorist model
ply:SetWalkSpeed(225) --Set their walk speed to 225
ply:SetRunSpeed(475) --Set their run speed to 475
ply:SetGravity(1.25) --Set their gravity to 1.25
ply:SetMaxHealth(125) --Set their max health to 125
elseif ply:Team() == 3 then
ply:Give("weapon_mad_knife") --Give them a knife
ply:Give("weapon_mad_glock") --Give them a Glock 18
ply:Give("weapon_mad_m4") --Give them an M4A1
ply:Give("weapon_mad_awp") --Give them an AWP
ply:SetModel("models/player/combine_soldier.mdl") --Set their model to a combine soldier model
ply:SetWalkSpeed(230) --Set their walk speed to 230
ply:SetRunSpeed(480) --Set their run speed to 480
ply:SetGravity(1.20) --Set their gravity to 1.20
ply:SetMaxHealth(150) --Set their max health to 150
end
end
----------Team Switching Functions----------
function team_prisoner(ply) --When this function is run
ply:SetTeam(1) --Set the player's team to "Prisoners"
ply:Kill() --Kill them
end
function team_guard(ply) --When this function is run
ply:SetTeam(2) --Set the player's team to "Guards"
ply:Kill() --Kill them
end
----------Team Switching Console Commands----------
concommand.Add( "team_prisoner", team_prisoner) --When this console command is run, run the function "team_prisoner"
concommand.Add( "team_guard", team_guard) --When this console command is run, run the function "team_guard"
----------Initialize----------
function GM:Initialize() --When the server starts
wardenamount=0 --Set the variable "wardenamount" to 0
timer.simple(10, RoundStart) --Set a timer to run the function "RoundStart" in ten seconds
end
----------Round Start----------
function RoundStart() --When this function is run
wardenamount=0 --Set the variable "wardenamount" to zero
timer.simple(10, RoundStart) --Set a timer to run this function in ten seconds (Obviously the ten second rounds are for testing)
end
function team_warden(ply) --When this function is run
if ply:Team() == 2 then --If the player's team is "Guards" then
if wardenamount=0 then --if the variable "wardenamount" is 0 then
ply:SetTeam(3) --Set the team to "Warden"
ply:Spawn --Spawn the player
ply:ChatPrint("You have become the warden!") --Print "You have become the warden!" in their chatbox
NoMoreWarden() --Run the function "NoMoreWarden"
else --Otherwise (if the variable "wardenamount" is not 0)
ply:ChatPrint("There already is a warden!") --Print "There already is a warden!" in their chatbox
end
elseif ply:Team() == 1 then --Otherwise (If the players team is not "Guards") if the player's team is "Prisoners" then
ply:ChatPrint("You are a prisoner!") --Print "You are a prisoner!" in their chatbox
elseif ply:Team() == 3 then --Otherwise if the players team is "Warden" then
ply:ChatPrint("You are already the warden!") --Print "You are already the warden!" in their chatbox
end
end
concommand.Add( "team_warden", team_warden) --When this console command is run, run the function "team_warden"
function NoMoreWarden() --When this function is run
wardenamount=1 --Set the variable "wardenamount" to 1
for _, v in pairs(player.GetAll()) do --Get all players and
v:ChatPrint("There is now a warden!") --Print "There is now a warden!" in their chat boxes
end
end
----------Fake Warden (This is for singleplayer testing)----------
function FakeWarden() --When this function is run
wardenamount=1 --Set the variable "wardenamount" to 1
NoMoreWarden() --Run the function "NoMoreWarden"
end
concommand.Add("fakewarden", FakeWarden) --When this console command is run, run the function "FakeWarden"
[/lua]
On line 85, "if wardenamount=0 then" needs to be "if wardenamount==0 then"
Learn to read errors, this was a simple fix.
-Snip-
New thread
Sorry, you need to Log In to post a reply to this thread.