this is about strings


function givepermission( ply )
	if ply:SteamID() == ply:GetNWString( "leader1" ) then
		ply:SetNWInt( "leader", 1 )
	else
	if ply:SteamID() == ply:GetNWString( "leader2" ) then
		ply:SetNWInt( "leader", 2 )
	else
	if ply:SteamID() == ply:GetNWString( "leader3" ) then
		ply:SetNWInt( "leader", 3 )
	else
	if ply:SteamID() == ply:GetNWString( "leader4" ) then
		ply:SetNWInt( "leader", 4 )
	else
	end
end




gamemodes\interstellarbuild\gamemode\leader.lua:62: function arguments expected near 'else'


can some one tell me what is wrong with this code its for a leader system that i have been making for my gamemode and mite make it in to an addon later

Which line is 62? Also you have an else next to an end on (numlines(doc) - 3).

i cant remeber now i am trying to fix as i go i think it was this
if ply:SteamID() == ply:GetNWString( “leader1” ) then
ply:SetNWInt( “leader”, 1 )
line 62 else

There’s a bigger problem: your if’s and else’s are all messed up. You’d need four ends rather than one if that was the case. Rather, try something like this:

[lua]function givepermission( pl )
for i=1,4 do
if pl:SteamID() == pl:GetNWString( “leader” … i ) then
pl:SetNWInt( “leader”, i );
break;
end
end
end[/lua]

i have a new problem and thanks for the ip entoros now sandbox is fucked up and prints this error every time
ERROR: GAMEMODE:‘HUDPaint’ Failed: gamemodes\sandbox\gamemode\cl_init.lua:69: attempt to call method ‘PaintWorldTips’ (a nil value)
self:PaintWorldTips()

Do people realize that these error messages mean something?

Please post line 69 of cl_init.lua and all the variable declarations used in that line.

i have right here

That error code isn’t from his file (unless he’s directly editing sandbox which I do not recommend) and it’s a weird one.
http://www.luabin.foszor.com/code/gamemodes/sandbox/gamemode/cl_init.lua#69

I don’t see what could cause this error unless the gamemode table was tampered with. Are you sure you have no other error showing up in the console, in the initialization sequence of the map?

Additionally what gamemode do you derive of?

sandbox and every time i try to fix my gamemode another sandbox error pops up

[editline]02:17PM[/editline]

i think i have found out what is wrong but still no idea one of my coders thinks that garry maybe removed some functions now sure this is a new error when i try to open the spawnmenu
ERROR: GAMEMODE:‘SpawnMenuOpen’ Failed: …amemodes\interstellarbuild\gamemode\cl_spawnmenu.lua:21: attempt to call method ‘SuppressHint’ (a nil value)

yes i just made the sandbox spawn menu in to mine atm to see what was the problem and this is the line of code



 function GM:SpawnMenuOpen()

	GAMEMODE:SuppressHint( "OpeningMenu" )
	GAMEMODE:AddHint( "OpeningContext", 20 )
	return true	
	
end


Why not just derive from sandbox instead

Worldtips fuck up when you override a HUDPaint hook of a sandbox derived gamemode without calling Sandbox’s hook. Simply do
[lua]
self.BaseClass:HUDPaint( )
[/lua]

Sandbox fucks up when you edit it.

Hilarity will ensue when he updates and some of his files get overwritten.

ty guys i have this code here


   function CheckPlayer(Nick) 
  	for k, v in pairs(player.GetAll()) do 
  		if(string.find(string.lower(v:Nick()), string.lower(Nick)) == 1) then 
  			return v 
  		end 
  	end 
  	return false 
  end 


and was wondering what is wrong with it is used for checking somethign to do with the player was coded by another coder for me and he ant online and was wondering how to fix it

It checks if a certain player is on the server (by username / nickname).

but its broken this is the error just knotist i didnt include that
gamemodes\interstellarbuild\gamemode\leadermark2.lua:7: bad argument #2 to ‘find’ (string expected, got boolean)

Let me explain how string.find works.
string.find(“Hello Lua user”, “Lua”)
7 9

It finds that the 2nd argument (“Lua”) is contained at the starting of the 7th character and at the end of the 9th character in the first argument (“Hello Lua user”).

So you could maybe write it like:
local startOfSecondString, endOfSecondString = string.find(“Hello Lua user”, “Lua”)
startOfSecondString would yield 7
endOfSecondString would yield 9

does any one know how to fix it for me plz

[editline]05:41PM[/editline]

or can some one recomend a page in the wiki for this

Okay, nobody help him yet.

What do you THINK the error means?

The error in the console tells you everything you need to know man.

Error in file: Leadermark2.lua, line 7: bad argument #2 to ‘find’ (string expected, got boolean)