There’s quite a lot of problems, so I tried to add comments to each of the issues:
opensteampage = true -- This should be local
local function OpenSteamProfile(ply, text, team)
player.GetAll() -- This returns a table of players. You can't just put it there. You have to do something with it, for example, loop through it.
if (opensteampage == Player:IsConnected() ) then -- 'Player' does not exist.
Player:ShowProfile() -- 'Player' does not exist.
else
opensteampage = false
player:ChatPrint("Player has either not connected yet or joined the server!") -- 'player' does not exist.
end
if text == "/profile .. player.Nick()" then -- This will always be true as it is just a string. It doesn't do what you expect it to because you didn't join it with the variable properly.
opensteampage = true
end
end
hook.Add("PlayerSay", "OpenSteamProfile", OpenSteamProfile) -- This won't work because PlayerSay is serverside and ShowProfile is clientside
It seems that you don’t have much idea of how Lua works to be honest.
It might be worth looking at examples or doing more research.
This should do what you were trying to do, but as you can see it’s completely different:
local function OpenSteamProfile( ply, text )
if ply ~= LocalPlayer() then return end -- OnPlayerChat is called for every single player that chats, so only show the profile if you requested it.
if string.sub( text, 1, 8 ) == "/profile" then -- If the first 8 characters of what the player said are '/profile'
local name = string.sub( text, 10 ) -- The name will be anything past 10 characters
local ply -- This makes a nil variable to be set as whatever player is found below:
for _, v in ipairs( player.GetAll() ) do -- For each player in all the players, find the one with the right name
if v:Nick() == name then ply = v end -- If the name is equal to the player's nickname then set it
end
if ply then ply:ShowProfile() end -- If it found a player then show their profile
return true -- Stops the message from displaying in the chat
end
end
hook.Add( "OnPlayerChat", "OpenSteamProfile", OpenSteamProfile )
I tried to explain how it works with some comments, but it probably still makes no sense.
The only real help I can give is to say that you need to research into the way Lua works.
It’s the only way any of this will make sense.