if pronouns_loaded then -- avoid double-loading return end rawset(_G, "pronouns_loaded", true) rawset(_G, "pronouns_showinscoreboard", true) local cv_compactscoreboard = CV_FindVar("compactscoreboard") local cv_seenames = CV_FindVar("seenames") addHook("PlayerJoin", function (playernum) if consoleplayer and #consoleplayer ~= playernum then return end -- save it since we can't access player from the callback local f = io.openlocal("client/pronouns.txt", "r") if f ~= nil then local pronouns = f:read() f:close() if pronouns then COM_BufAddText(nil, "pronouns " + pronouns) end end end) COM_AddCommand("pronouns", function (player, pronouns) if not pronouns then if not player.pronouns then CONS_Printf(player, "You have not set any pronouns!") else CONS_Printf(player, "Your pronouns is " .. player.pronouns) end return end if pronouns == "-" then player.pronouns = nil if consoleplayer and #player == #consoleplayer then local f = io.openlocal("client/pronouns.txt", "w") f:close() end CONS_Printf(player, "Your pronouns is now cleared") return end if #pronouns > 16 then CONS_Printf(player, "Only a maximum of 16 characters are allowed") return end if pronouns:find("[^%a/]") then CONS_Printf(player, "Only letters and forward slash is allowed") return end player.pronouns = pronouns if consoleplayer and #player == #consoleplayer then local f = io.openlocal("client/pronouns.txt", "w") f:write(pronouns) f:close() end CONS_Printf(player, "Your pronouns is now " .. player.pronouns) end) local facingplayer = nil addHook("SeenPlayer", function (player, seenplayer) facingplayer = seenplayer end) local function DrawPronouns(v) if not (facingplayer and facingplayer.valid) then facingplayer = nil return end if not cv_seenames.value or #consoleplayer ~= #displayplayer or not facingplayer.pronouns then return end local c = 0 if cv_seenames.value == 2 then if G_GametypeHasTeams() then if facingplayer.ctfteam == 1 then c = V_REDMAP else c = V_BLUEMAP end end elseif cv_seenames.value == 3 then if G_GametypeHasTeams() then if facingplayer.ctfteam == consoleplayer.ctfteam then c = V_GREENMAP else c = V_REDMAP end elseif G_RingSlingerGametype() then c = V_REDMAP else c = V_GREENMAP end end v.drawString(160, 100+15+10, "(" .. facingplayer.pronouns .. ")", c|V_HUDTRANSHALF, "small-center") if leveltime % 7 == 0 then facingplayer = nil end end local function DrawTeamPronouns(v, tab) local redplayers = 0 local blueplayers = 0 for i = 1,#tab do if tab[i].ctfteam == 1 then redplayers = redplayers + 1 if redplayers > 8 then -- not enough room return end elseif tab[i].ctfteam == 2 then blueplayers = blueplayers + 1 if blueplayers > 8 then -- not enough room return end end end redplayers = 0 blueplayers = 0 for i = 1,#tab do if not tab[i].spectator then local x = 52 local y if tab[i].ctfteam == 1 then redplayers = redplayers + 1 x = x + 160 y = (redplayers * 16) + 16 elseif tab[i].ctfteam == 2 then blueplayers = blueplayers + 1 y = (blueplayers * 16) + 16 end if tab[i].pronouns and not tab[i].quittime or (leveltime / (TICRATE/2) & 1) then local f = V_ALLOWLOWERCASE if #tab[i] == #consoleplayer then f = f | V_YELLOWMAP end if tab[i].spectator or tab[i].playerstate == PST_DEAD or (G_IsSpecialStage(gamemap) and player.exiting) then f = f | V_60TRANS end v.drawString(x, y+9, "(" .. tab[i].pronouns .. ")", f, "small"); end end end end hud.add(DrawPronouns, "game") hud.add(function (v) DrawPronouns(v) if not pronouns_showinscoreboard or not netgame then return end if not G_GametypeHasTeams() and cv_compactscoreboard and cv_compactscoreboard.value then -- not enough room to draw player's pronouns :/ return end local tab = {} for player in players.iterate do if player and player.valid and (G_PlatformGametype() or not player.spectator) then local inserted = false for i = 1,#tab do if gametype == GT_RACE then if circuitmap then if player.laps >= tab[i].laps then table.insert(tab, i, player) inserted = true break end else if player.realtime <= tab[i].realtime then table.insert(tab, i, player) inserted = true break end end else if player.score >= tab[i].score then table.insert(tab, i, player) inserted = true break end end end if not inserted then table.insert(tab, player) end end end local x = 32 local y = 32 if G_GametypeHasTeams() then DrawTeamPronouns(v, tab) return elseif #tab <= 9 then x = 40 y = 32 end if #tab <= 18 then for i, player in ipairs(tab) do if not player.quittime or (leveltime / (TICRATE/2) & 1) then if player.pronouns then local f = V_ALLOWLOWERCASE if #tab[i] == #consoleplayer then f = f | V_YELLOWMAP end if player.spectator or player.playerstate == PST_DEAD or (G_IsSpecialStage(gamemap) and player.exiting) then f = f | V_60TRANS end v.drawString(x+20, y+9, "(" .. player.pronouns .. ")", f, "small"); end end y = y + 16 if y > 160 then y = 32 x = x + 160 end end end end, "scores") if not isdedicatedserver then -- load it now, so the host/existing players gets their pronouns properly local f = io.openlocal("client/pronouns.txt", "r") if f ~= nil then local pronouns = f:read() f:close() if pronouns then COM_BufAddText(nil, "pronouns " + pronouns) end end end