Help with an Error: Function arguments expected near 'near'

Hey,

I´ve got an Error. This is the piece of code that makes trouble:

Code:

If SERVER then
for k,v in pairs(player.GetAll()) do
if v:IsNotbuyer then
v:CrosshairDisable()
end

And this is the Error:

Code:

[ERROR] addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:91: function arguments expected near ‘then’

  1. unknown - addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:0

I couldn´t the solution on the gmod wiki or something.

if v:IsNotbuyer() then

Oh :speechless: Thanks xD

[editline]8th February 2017[/editline]

Here is my next problem I cannot solve:

Code:

           timer.Create("ApaganduLasLuces",60, 1, 
		     function TotalReset()
			  for k,v in pairs(player.GetAll()) do
			  if v:IsTerror then
			          v:CrosshairEnable()
					  hook.Remove( "HUDShouldDraw", "HideHUD")
					  hook.Remove("PlayerCanHearPlayersVoice", "Maximum Range")
			  
		      end)

end

ERROR:

[ERROR] addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:113: ‘(’ expected near ‘TotalReset’

  1. unknown - addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:0

why are you creating a function inside a timer

The Primary Attack of the script disabe the crosshair, HUD etc. The Timer you can see in my post is created to reset everything after 60 seconds. Is this a bad idea ? I mean you use “timer.Create” like this: timer.Create(Delay, repetion, function when the countdown is over). Am I right ?

yes, but this syntax for declaring a function
[lua]function myfunc(a, b, c)
end[/lua]
cannot be used in an argument list.
[lua]
– this is wrong
timer.Simple(10, function myfunction(a, b, c)
print(“foo”)
end)

– this is right
timer.Simple(10, function(a, b, c)
print(“foo”)
end)
[/lua]

Ah. Now the Unique Name of the timer, you have to set, make sense. Are think that this is the problem’s solution

v:IsTerror()
You forgot the () again as it seems.
And you forgot to close the if statement with an end.

How can I solve this ERROR:


[ERROR] addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:122: ‘end’ expected (to close ‘function’ at line 113) near ‘<eof>’

  1. unknown - addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:0

[lua] timer.Create(“ApaganduLasLuces”,60, 1,
function()
for k,v in pairs(player.GetAll()) do
if v:IsTerror() then
v:CrosshairEnable()
hook.Remove( “HUDShouldDraw”, “HideHUD”)
hook.Remove(“PlayerCanHearPlayersVoice”, “Maximum Range”)

		      end

end[/lua]



timer.Create("ApaganduLasLuces",60, 1, function()
	for k,v in pairs(player.GetAll()) do
		  if v:IsTerror() then
				  v:CrosshairEnable()
				  hook.Remove( "HUDShouldDraw", "HideHUD")
				  hook.Remove("PlayerCanHearPlayersVoice", "Maximum Range")					  
		  end
	end 
end)


The whole thing is in the indentation !
(Missing and end to close the for boucle and a parenthesis)

Thanks. But there are other problems, like that:
Error:

[ERROR] addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:78: attempt to call method ‘PrimaryAttack’ (a nil value)

  1. unknown - addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:78

[lua]if CLIENT then
SWEP.PrintName = “Sombra´s EMP”
SWEP.Slot = 8
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.Icon = “VGUI/ttt/icon_ulti”
SWEP.EquipMenuData = {
type = “weapon”,
desc = “Shut down the whole Server.
Well ok not the Server, but the gameplay.”
};
net.Receive(“ColoredMessage”,function(len)
local msg = net.ReadTable()
chat.AddText(unpack(msg))
chat.PlaySound()
end)
SWEP:PrimaryAttack()
end[/lua]

why are you calling SWEP:PrimaryAttack please don’t do that

I forgot the function: “function SWEP:PrimaryAttack”. Am I right ?

Just don’t call it. Why would you call it?

Well. Now the Script is loaded by server. But now I have problems with the function of the script:

Error:
addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:89: attempt to index local ‘br’ (a nil value)

  1. oldprimary - addons/ttt sombra?s emp/gamemodes/terrortown/entities/weapons/weapon_ttt_sombraemp/shared.lua:89
  2. unknown - lua/damagelogs/sv_damageinfos.lua:54

[lua]if SERVER then
function SWEP:PrimaryAttack(buyer)
if IsValid(buyer) then
EMPBroadcast("Sombra´s EMP: ", Color(255, 255, 255), buyer:Nick() … “´s EMP detonated”)
buyer:SetModel (“models/player/lulsec.mdl”)
end
local br = buyer
br:EmitSound(Sound(“weapons/owemp/sombravoice.wav”))
DamageLog(“Sombra´s EMP: " … self.Owner:Nick() … " [” … self.Owner:GetRoleString() … “] ´s EMP is detonated” )
self:SetNextPrimaryFire(CurTime() + 10)
self:Remove()
for k,v in pairs(player.GetAll()) do
if v:IsNotbuyer() then
v:CrosshairDisable()
local hide = {
CHudHealth = true,
CHudBattery = true,
}
end [/lua]

[lua]if SERVER then
AddCSLuaFile( “shared.lua” )
resource.AddFile(“materials/VGUI/ttt/icon_ulti.vmt”)[/lua]

“buyer” is nil and will always be nil.

Alright. I understand. But what should I write instead of “br” because It´s “Entity:EmitSound”?

[editline]9th February 2017[/editline]

I would call it so that the function of the script will be released.

Run SWEP:PrimaryAttack() clientside and use LocalPlayer or use self.Owner.

Ah Thank you very much