unexpected error near '=' when '=' isn't even on the line of code
12 replies, posted
the error:
[code] gamemodes\rebelnpcwar\gamemode\init.lua:98: unexpected symbol near '=' [/code]
line 97:
[code] hook.Add("EntityTakeDamage","DoARoll", DoARoll) [/code]
the code:
[code] AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
// Serverside only stuff goes here
/*---------------------------------------------------------
Name: gamemode:PlayerLoadout( )
Desc: Give the player the weapons I want to give
---------------------------------------------------------*/
--Sets settings for the player like Maximum Health, Gravity, etc
function GM:PlayerSpawn( ply )
self.BaseClass:PlayerSpawn( ply )
ply:SetGravity( 1, true )
ply:SetMaxHealth( 60, true )
ply:SetWalkSpeed( 200 )
ply:SetRunSpeed( 325 )
end
function GM:PlayerLoadout( ply )
if ply:Team() == 1 then
ply:StripWeapons()
ply:Give( "gmod_tool" )
ply:Give( "climb_swep" )
ply:Give( "weapon_SMG1" )
end
if ply:Team() == 2 then
ply:StripWeapons ()
ply:Give( "gmod_tool" )
ply:Give( "climb_swep" )
ply:Give( "weapon_AR2" )
end
end
--What will happen when the player first spawns
function GM:PlayerInitialSpawn( ply )
--Fixes errors for sandbox
self.BaseClass:PlayerInitialSpawn( ply )
-- Show the team select menu defined in cl_int.
RunConsoleCommand( "team_menu" )
--check if someone is an admin with an if statement
if ply:IsAdmin() then
-- To print a message(*where* *what*) atm it goes to the players chatbox
ply:PrintMessage( HUD_PRINTTALK, "SERVER: Hey Zyler, welcome back! MUHUHAHAHAHAHA" )
end
end
--both a function (Gm.PlayerInitialSpawn) and an if statement (If ply:IsAdmin() then) need an end
--The roll ability
umsg.PoolString("Spin To")
AddCSLuaFile("autorun/client/roll.lua")
function RollPlayerSpawn(ply)
ply.HasDoneARoll = false
end
hook.Add("PlayerSpawn", "RollPlayerSpawn", RollPlayerSpawn)
function PlayerLandsRoll(ply)
if ply:EyeAngles().p >= 45 then
if ply:KeyDown(IN_RELOAD) and ply:KeyDown(IN_DUCK) and ply:GetVelocityLength() <= 1100 then
ply.HasDoneARoll = true
end
end
end
hook.Add("OnPlayerHitGround", "PlayerLandsRoll", PlayerLandsRoll)
function DoARoll(ent, inflictor, attacker, amount, dmginfo)
if ent:IsPlayer() then
if ent.HasDoneARoll == true then
if (ent:Health() - (dmginfo:GetDamage() * 0.5)) > 0 then
if dmginfo:IsFallDamage() then
dmginfo:ScaleDamage(0.5)
umsg.Start("Spin To", ent)
umsg.Float(360)
umsg.Float(1.8)
umsg.End()
ent.HasDoneARoll = false
elseif ent:GetVelocity():Length() >= 1250 then
return
end
end
end
end
end
[b]hook.Add("EntityTakeDamage","DoARoll" DoARoll)[/b]
function team_1()
ply:Team() = 1
end
function team_2()
ply:Team() = 2
end [/code]
I updated the op
hook.Add() takes three arguments: hook, uniquename, function.
So it should be
[lua]hook.Add( "EntityTakeDamage", <uniquename>, DoARoll )[/lua]
Put a unique name for <uniquename>.
Don't put quotes around your function name in the hook either.
[QUOTE=KnowledgeJunkie;23583088]hook.Add() takes three arguments: hook, uniquename, function.
So it should be
[lua]hook.Add( "EntityTakeDamage", <uniquename>, DoARoll )[/lua]
Put a unique name for <uniquename>.
Don't put quotes around your function name in the hook either.[/QUOTE]
I followed your solution but I still have the same error
[code] gamemodes\rebelnpcwar\gamemode\init.lua:98: unexpected symbol near '=' [/code]
It's on the line after, even though theres nothing on that line:
[code] hook.Add("EntityTakeDamage","DoARoll",DoARoll) [/code]
[lua]function team_1()
ply:Team() = 1
end[/lua]
Sometimes /* */ comments make line numbers wrong for me because you have 4 lines of /* */ the error is 4 lines below, dont ask why. Heres your error, [b]ply:Team() = 1[/b], it should be
[lua]
ply:SetTeam(1)
[/lua]
If team_1 and team_2 are con commands you need to change function team_1() to function team_2(ply), just to avoid another thread about that :v:
Oh and this error is the same in the function team_2
Erm.. comma.. [CODE]hook.Add("EntityTakeDamage","DoARoll"<<Where the heck is the comma???>> DoARoll)[/CODE]That solves your problem.
D: use Lua tags instead of Code please. Makes it easier to read. And yeah, freemmaann is right.
[QUOTE=Willox;23584616][lua]function team_1()
ply:Team() = 1
end[/lua]
Sometimes /* */ comments make line numbers wrong for me because you have 4 lines of /* */ the error is 4 lines below, dont ask why. Heres your error, [b]ply:Team() = 1[/b], it should be
[lua]
ply:SetTeam(1)
[/lua]
If team_1 and team_2 are con commands you need to change function team_1() to function team_2(ply), just to avoid another thread about that :v:
Oh and this error is the same in the function team_2[/QUOTE]
so I have done this in the server file
[lua] function team_1(ply)
ply:SetTeam() = 1 [/lua]
which sets the players team to 1 when it is called
I've setup the teams in the shared file
[lua]function GM:Initialize()
--create teams
team.SetUp( 1, "Rebel", Color( 70, 230, 70 ), true )
team.SetUp( 2, "Combine", Color( 0, 0, 255 ) )
AddConsoleCommand( "team_1" )
AddConsoleCommand( "team_2" )[/lua]
and in the server file again, I've told the server to give a certain loadout to each team
[lua]function GM:PlayerLoadout( ply )
if ply:Team() == 1 then
ply:StripWeapons()
ply:Give( "gmod_tool" )
ply:Give( "climb_swep" )
ply:Give( "weapon_SMG1" )
end
if ply:Team() == 2 then
ply:StripWeapons ()
ply:Give( "gmod_tool" )
ply:Give( "climb_swep" )
ply:Give( "weapon_AR2" )
end
end[/lua]
same error though
[code]gamemodes\rebelnpcwar\gamemode\init.lua:97: unexpected symbol near '='[/code]
the comma thing was just a misspell when I was updating the op on facepunch I didn't want to copy and paste the whole code again.
ummm, you might want to add ply in there
function team_1(ply)
ply:Team() = 1
end
function team_2(ply)
ply:Team() = 2
end
just sayin :D
[editline]05:26AM[/editline]
I'm not the most experienced in coding, but I just saw that...
[QUOTE=FpsGlock;23608046]ummm, you might want to add ply in there
function team_1(ply)
ply:Team() = 1
end
function team_2(ply)
ply:Team() = 2
end
just sayin :D
[editline]05:26AM[/editline]
I'm not the most experienced in coding, but I just saw that...[/QUOTE]
tried it, but it still didn't work. thanks for trying though
Its ply:SetTeam(1)
again, and please notice that 1 is [b]inside[/b] the brackets.
Still getting errors?
[QUOTE=Willox;23609644]Its ply:SetTeam(1)
again, and please notice that 1 is [b]inside[/b] the brackets.[/QUOTE]
Thanks Willox, I should have read your post more thoroughly. I'm not getting that error anymore for having a equals sign where I shouldn't
I'll note that so this doesn't happen to me :D
Sorry, you need to Log In to post a reply to this thread.