• OnPlayerChat, everyone that can see it gets affected
    2 replies, posted
Hey I want to make it so only the person executing a command in chat gets affected. For some reason everyone that sees it in chat gets affected. Is there a way to fix that? hook.Add("OnPlayerChat", "adminMode" , function(ply , text) ply = LocalPlayer() if table.HasValue(adminmodeUsergroups, ply:GetNWString("usergroup") ) then if string.lower(text) == adminmodeCommand then if adminmode == 0 then AdminMode() adminmode = 1 elseif adminmode == 1 then AdminModeOff() adminmode = 0 end end elseif adminmodeNoAccess == true then chat.AddText( adminmodeChatSymbolColor, adminmodeChatSymbol, adminmodeChatColor, adminmodeNoAccessText) end end)
It's because you're setting ply = LocalPlayer(), when there is no need. ply is already set from the function as the person who sent the message.
hook.Add("OnPlayerChat", "adminMode" , function(ply , text)     if string.lower(text) == adminmodeCommand and ply == LocalPlayer() then         if table.HasValue(adminmodeUsergroups, ply:GetNWString("usergroup") ) then             if adminmode != 1 then                 AdminMode()                 adminmode = 1             elseif adminmode == 1 then                 AdminModeOff()                 adminmode = 0             end         elseif adminmodeNoAccess then             chat.AddText( adminmodeChatSymbolColor, adminmodeChatSymbol, adminmodeChatColor, adminmodeNoAccessText)         end     end end)
Sorry, you need to Log In to post a reply to this thread.