Only the people with there steam ID on the table should be able to do function, but everyone can.
Any help?
[lua]
function shit( p )
local id_table= {
"STEAM_0:0:14776474",-- 1
"STEAM_0:1:17190550", -- 2
"STEAM_0:1:17123456" -- 3
}
if table.HasValue(id_table, p:SteamID()) then -- Chargin mah lazors.
print( "on table" ) -- Shoopdawoop.
else
print( "not on table" ) -- Arr ya got meh.
end
end
[/lua]
Try do it like this instead:
[lua]
function Check( ply )
local ids = { "STEAM_0:0:14776474", "STEAM_0:1:17190550", "STEAM_0:1:17123456 }
for k, v in pairs( ids ) do
if( v == ply:SteamID() ) then
print( "yo" );
end
end
end
[/lua]
[QUOTE=H0rsey;21545127]Try do it like this instead:
[lua]
function Check( ply )
local ids = { "STEAM_0:0:14776474", "STEAM_0:1:17190550", "STEAM_0:1:17123456" }
for k, v in pairs( ids ) do
if( v == ply:SteamID() ) then
print( "yo" );
end
end
end
[/lua][/QUOTE]
Fixed
[QUOTE=H0rsey;21545127]Try do it like this instead:
[lua]
function Check( ply )
local ids = { "STEAM_0:0:14776474", "STEAM_0:1:17190550", "STEAM_0:1:17123456 }
for k, v in pairs( ids ) do
if( v == ply:SteamID() ) then
print( "yo" );
end
end
end
[/lua][/QUOTE]
What's wrong with table.HasValue?
[editline]12:05PM[/editline]
That is basically what table.HasValue does.
[QUOTE=MakeR;21545163]What's wrong with table.HasValue?
[editline]12:05PM[/editline]
That is basically what table.HasValue does.[/QUOTE]
You tell me, it should work.
Then why'd you post a for loop that does it? I guess it does have it's uses, table.HasValue doesn't report back the index the thing corresponds to. Works exactly like what he has in his code.
[b][url=http://wiki.garrysmod.com/?title=Table.HasValue]Table.HasValue [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Then why wont it work for me...
Post the errors your getting here, we'll work from that.
No error, just the people who are not on the list are able to do the function as-well.
[QUOTE=101kl;21585882]No error, just the people who are not on the list are able to do the function as-well.[/QUOTE]
[lua]local AuthCheck = {"STEAMID","STEAMID","STEAMID"}
function authnid(ply, steamid)
if table.HasValue(AuthCheck, steamid) then
print("Player "..ply:Name().." ("..steamid..") is authed")
else
ply:Kick("Your not allowed here")
end
end
hook.Add( "PlayerAuthed", "authid", authnid )
[/lua]
Output:
On List:
Player Cubar (STEAMID) is authed
Not on list
Dropped Cubar from server (Kicked by Console : Your not allowed here)
Sorry, you need to Log In to post a reply to this thread.