-- Skincolor Randomizer v1.2 -- wow!! the REAL 1.1!! -- i was arguing with myself if i should name this either 1.1.1 or 1.2 -- Give randocolor to each player in the game local function scr_Main(unused) for p in players.iterate do -- Behaviour for non-team gts if !gametyperules & GTR_TEAMS then p.randocolor = P_RandomRange(1, #skincolors-1) else -- behaviour for team gts skincolor_redteam = P_RandomRange(1, #skincolors-1) skincolor_blueteam = P_RandomRange(1, #skincolors-1) skincolor_redring = skincolor_redteam skincolor_blueteam = skincolor_blueteam print("Red team's color was randomized to "..skincolors[skincolor_redteam].name.."!") print("Blue team's color was randomized to "..skincolors[skincolor_blueteam].name.."!") S_StopSoundByID(nil, sfx_addfil) -- i have to stop the sound first so that when you're in a netgame you dont get your eardrums robo blasted S_StartSound(nil, sfx_addfil) end end end -- Usual print statement local function scr_Print(p) if p.bot == 1 or p.bot == 3 then return end -- return if bot print(p.name.."'s skincolor was randomized to "..skincolors[p.mo.color].name.."!") S_StopSoundByID(nil, sfx_addfil) S_StartSound(nil, sfx_addfil) end -- Set colors in non team GTs local function scr_Set(p) if !gametyperules & GTR_TEAMS and p.mo.color != p.randocolor then while skincolors[p.randocolor].accessible == false do p.randocolor = P_RandomRange(1, #skincolors-1) end p.mo.color = p.randocolor scr_Print(p) end end -- Alternative function: no accessible check local function scr_SetAny(p) if !gametyperules & GTR_TEAMS and p.mo.color != p.randocolor then p.mo.color = p.randocolor scr_Print(p) end end -- Change color upon respawn local function scr_Reset(p) if gametyperules & GTR_TEAMS then return end p.randocolor = P_RandomRange(1, #skincolors-1) scr_Set(p) end -- Alternative function: uses SetAny local function scr_ResetAny(p) if gametyperules & GTR_TEAMS then return end p.randocolor = P_RandomRange(1, #skincolors-1) scr_SetAny(p) end -- Admin only print local function scr_AdminPrint(p) CONS_Printf(p, "\x85".."ERROR: ".."\x80".."This is an admin only command! You aren't promoted. (If you're the host, then use the promote command on yourself. I'm not sure how to fix this as of now.)") S_StartSound(nil, sfx_adderr, p) end -- Red team rando local function scr_RedRando() skincolor_redteam = P_RandomRange(1, #skincolors-1) skincolor_redring = skincolor_redteam print("Red team's color was randomized to "..skincolors[skincolor_redteam].name.."!") S_StopSoundByID(nil, sfx_addfil) S_StartSound(nil, sfx_addfil) end -- Blue team rando local function scr_BlueRando() skincolor_blueteam = P_RandomRange(1, #skincolors-1) skincolor_blueteam = skincolor_blueteam print("Blue team's color was randomized to "..skincolors[skincolor_blueteam].name.."!") S_StopSoundByID(nil, sfx_addfil) S_StartSound(nil, sfx_addfil) end -- The function for scr_randocolor local function scr_Command(p, arg, arg2) -- arg2 will be for the vanilla color toggle -- teams if netgame and gametyperules & GTR_TEAMS then -- admin only if (not IsPlayerAdmin(p) or server != p) and netgame then scr_AdminPrint(p) return end if arg == nil then -- Default: randomize all teams scr_Main(arg) elseif arg == "red" then -- red: randomize red team scr_RedRando() elseif arg == "blue" then -- blue: randomize blue team scr_BlueRando() else -- Invalid argument CONS_Printf(p, "\x85".."ERROR: ".."\x80".."This is an invalid argument! Use either no argument, red or blue.") S_StartSound(nil, sfx_adderr, p) end end -- non team gts -- im genuinely not sure if this is good code formatting or not (it probably isnt) -- edit from the future: holy hell this is UNREADABLE :sob: if arg == nil then -- Default: sets the executor's color scr_Reset(p) elseif arg == "everyone" then -- everyone: set everyone's color if (not IsPlayerAdmin(p) or server != p) and netgame then scr_AdminPrint(p) return end for pl in players.iterate() do scr_Reset(pl) end elseif arg == "any_everyone" then -- any_everyone: set everyone's color using ResetAny if (not IsPlayerAdmin(p) or server != p) and netgame then scr_AdminPrint(p) return end for pl in players.iterate() do scr_ResetAny(pl) end elseif arg == "any" then -- any: use ResetAny if (not IsPlayerAdmin(p) or server != p) and netgame then scr_AdminPrint(p) return end scr_ResetAny(p) else -- Invalid argument CONS_Printf(p, "\x85".."ERROR: ".."\x80".."This is an invalid argument! Use either no argument, everyone, any or any_everyone.") S_StartSound(nil, sfx_adderr, p) end end -- SKINCOLOR FREESLOTTING -- so i wanna freeslot 32 colors, for each player, the name of whiches will start with SCRRAMP. how do we do that? for loop! -- hi this is me from the future, im sorry this was the only way freeslot("SKINCOLOR_SCRRAMP1", "SKINCOLOR_SCRRAMP2", "SKINCOLOR_SCRRAMP3", "SKINCOLOR_SCRRAMP4", "SKINCOLOR_SCRRAMP5", "SKINCOLOR_SCRRAMP6", "SKINCOLOR_SCRRAMP7", "SKINCOLOR_SCRRAMP8", "SKINCOLOR_SCRRAMP9", "SKINCOLOR_SCRRAMP10", "SKINCOLOR_SCRRAMP11", "SKINCOLOR_SCRRAMP12", "SKINCOLOR_SCRRAMP13", "SKINCOLOR_SCRRAMP14", "SKINCOLOR_SCRRAMP15", "SKINCOLOR_SCRRAMP16", "SKINCOLOR_SCRRAMP17", "SKINCOLOR_SCRRAMP18", "SKINCOLOR_SCRRAMP19", "SKINCOLOR_SCRRAMP20", "SKINCOLOR_SCRRAMP21", "SKINCOLOR_SCRRAMP22", "SKINCOLOR_SCRRAMP23", "SKINCOLOR_SCRRAMP24", "SKINCOLOR_SCRRAMP25", "SKINCOLOR_SCRRAMP26", "SKINCOLOR_SCRRAMP27", "SKINCOLOR_SCRRAMP28", "SKINCOLOR_SCRRAMP29", "SKINCOLOR_SCRRAMP30", "SKINCOLOR_SCRRAMP31", "SKINCOLOR_SCRRAMP32") local startrampcolor = #skincolors-32 local endrampcolor = #skincolors-1 -- now, we define them all -- they'll be randomized later in the code local invshade2 = P_RandomRange(0, 15) local chatcolortable = {4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440} local chatcolor2 = chatcolortable[P_RandomRange(0, #chatcolortable-1)] for i = 0, 31 do skincolors[startrampcolor+i] = { name = "SCR Ramp "..tostring(i), ramp = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, invcolor = P_RandomRange(1, #skincolors-1), invshade = invshade2, chatcolor = chatcolor2, accessible = false } if i == 32 then return end end -- The function for scr_randoramp local function scr_RampCommand(p, arg) if (not IsPlayerAdmin(p) or server != p) and netgame then scr_AdminPrint(p) return end if gametyperules & GTR_TEAMS then CONS_Printf(p, "\x85".."ERROR: ".."\x80".."This command is unusable in team gametypes!") S_StartSound(nil, sfx_adderr, p) end for i = 0, 32 do if players[i] == nil then print("Everybody's ramps were randomized!") S_StopSoundByID(nil, sfx_addfil) S_StartSound(nil, sfx_addfil) return end skincolors[startrampcolor+i].invcolor = P_RandomRange(1, #skincolors-1) skincolors[startrampcolor+i].invshade = P_RandomRange(0, 15) skincolors[startrampcolor+i].chatcolor = chatcolortable[P_RandomRange(1, #chatcolortable)] -- ramp for i2 = 0, 15 do if i2 == 17 then return end skincolors[startrampcolor+i].ramp[i2] = P_RandomRange(0, 254) end players[i].mo.color = startrampcolor+i players[i].randocolor = startrampcolor+i end end -- Hooks addHook("PlayerSpawn", scr_Main) addHook("PlayerThink", scr_Set) COM_AddCommand("scr_randocolor", scr_Command) COM_AddCommand("scr_randoramp", scr_RampCommand)