Resource icon

[Reusable] Sendcolor: Players pick their own skincolors! (v7) 7

attachment.php


This script lets any player send a custom skincolor to the server by using the SENDCOLOR command in the console. You can also download the skincolors uploaded by other players! You can define this color in a text file: sendcolor.txt, placed in the luafiles/client folder in your SRB2 folder. At the bare minimum, the file could be just five lines like this:
Code:
City
48,218,51,221,33,203,203,185,185,185,186,186,186,186,187,187
SKINCOLOR_AZURE
6
V_ORANGEMAP
In order, that's equivalent to name, ramp, invcolor, invshade, and chatcolor, but without the additional syntax you'd use for a Lua or SOC definition. However, you can use those definitions as well, and even pack multiple colors into one file! Check under the spoiler for more detailed formatting information:

Known issue: using a number (possibly other special characters?) as the first character of your color name will cause SRB2 to hang. Until this is sorted out, best to stick to alphabetical characters only
The sendcolor format boils down to nine lines in your text file:

-autosend
-metadata name
-metadata author
-metadata uploader
-color name
-color ramp
-color invcolor
-color invshade
-color chatcolor

These lines must be in this order, without extra lines in between, or any missing lines - aside from the autosend and metadata, which are optional. Anything after these nine lines (for example, ACCESSIBLE) is not read. You can include multiple colors in one file.

Including #AUTOSEND at the beginning of your definition serves two purposes. When you first join a game, the script will check to see if you have an autosend color in sendcolor.txt. If you do, it will be automatically sent. In addition, when you use the SENDCOLOR command without any arguments, or with the argument -auto, it will search for an autosend color.

Metadata is optional and consists of three lines. If metadata is used, all three lines must be present. All three lines are prepended with the #, used to indicate a SOC comment. The first line simply identifies the color:
Code:
#METADATA = City
You can use a different name than the actual color name, in which case you would use the metadata name rather than the actual name when you SENDCOLOR.

The second line is the author of the color. This will be broadcast when this color is uploaded and saved if another player SAVECOLORs that color. Spaces are allowed, but quotes should be used:
Code:
#AUTHOR = "Big Chungus"
Remember that this line must be accounted for when using metadata, even if there's no author - simply use an empty string:
Code:
#AUTHOR = ""

The third line is the uploader of the color - this is saved automatically when you use SAVECOLOR to save a color someone else uploaded. If you're writing your own metadata, you should leave this blank:
Code:
#UPLOADER = ""

The next five lines are the actual color data. You can generally just copy/paste a SOC or Lua definition in, but there are a few key differences. Most importantly, these five lines must be in the exact order shown in the examples below. For the invcolor and chatcolor fields, you can use either their respective constants, or actual numbers.

Full example, "SOC" style:
Code:
#AUTOSEND
#METADATA = City
#AUTHOR = "kays"
#UPLOADER = ""
NAME = City
RAMP = 48,218,51,221,33,203,203,185,185,185,186,186,186,186,187,187
INVCOLOR = SKINCOLOR_AZURE
INVSHADE = 6
CHATCOLOR = V_ORANGEMAP
ACCESSIBLE = TRUE

Bare bones definition:
Code:
City
48,218,51,221,33,203,203,185,185,185,186,186,186,186,187,187
SKINCOLOR_AZURE
6
V_ORANGEMAP

Using #AUTOSEND without metadata, "Lua" style:
Code:
#AUTOSEND
name = "City",
ramp = {48,218,51,221,33,203,203,185,185,185,186,186,186,186,187,187},
invcolor = SKINCOLOR_AZURE,
invshade = 6,
chatcolor = V_ORANGEMAP,
accessible = true

Check the info under the commands spoiler tag below for details on how to read from different files, choose specific colors, automatically send a color on join, etc.

Commands:
Code:
********************************
SENDCOLOR [<colorname> [<file>]]
********************************
	Sends a color to the server for use. If used without arguments,
it will look in sendcolor.txt for a color marked with the line #AUTOSEND
above it. Failing that, it will attempt to read a color from the first line
of the file. Otherwise, it will look for the colorname you specify.

	You can specify a file to look in other than sendcolor.txt, but
it must still be in the luafiles/client folder. You can use
"SENDCOLOR -auto <file>" to use the #AUTOSEND behavior
with a specific filename.

	If the color is successfully sent, the script will attempt to
change your color - but only if you're allowed (e.g., not while
moving or in a team game).

******************************
SAVECOLOR <colorname> [<file>]
******************************
	Appends a SOC definition for color <colorname> into your
sendcolor.txt or other specified file. You can use this on any color,
even standard colors or custom colors not loaded through this script.

****************************
SETAUTO <colorname> [<file>]
****************************
	Modifies sendcolor.txt or other specified file to set color <colorname>
as your AUTOSEND. This color should already exist in this file.

Admin commands/variables:
Code:
*****************************
ALLOWRESEND <-1, 0, or 1-300>
*****************************
	-1: Each player can only send a color once, until ALLOWRESENDPLAYER
or CLEARCOLORS is used. Set by default.

	0: Each player can send a color once per map, unless ALLOWRESENDPLAYER
or CLEARCOLORS is used.

	1-300: Cooldown in seconds between a player sending a color and being
able to send another.

	Note that the server and admins are unaffected by this setting, and
can always send a new color.

******************************
ALLOWRESENDPLAYER <playername>
******************************
	Removes any ban or cooldown on this player, allowing them to send
another color (unless COLORLOCK is enabled).

******************
COLORLOCK <on/off>
******************
	When on, players cannot send colors. The server and admins are
unaffected.

**********************
COLORBAN <player name>
**********************
	Removes the color sent by this player, and prevents them from
sending colors until access is regranted through ALLOWRESENDPLAYER

*******************************
REMOVEPLAYERCOLOR <player name>
*******************************
	Removes the color sent by this player, without explicitly
banning them from sending. Note that depending on your ALLOWRESEND
setting they may still be unable to send another color.

***********
CLEARCOLORS
***********
	Removes all sent colors from the server, and resets all
players' cooldowns, except for those who have been COLORBAN'd.

attachment.php


You are welcome to modify this, pack into other addons, etc.

v7:
  • Tiny update for 2.2.8

v6:
  • Bug fixes
  • Add metadata for author/uploader

v5:
  • Store multiple colors in one file
  • Specify choice of file
  • Basic SOC/Lua parsing
  • Autosend colors
  • Save colors to text
  • Refactor admin tools
  • Various error catching and optimizations

v4:
  • Sorted out bug where dummy colors would become accessible
  • Added COLORCOOLDOWN
  • "Player added color Color!" message now shows the chatcolor.
  • Freeslot names are more descriptive (SKINCOLOR_SEND0 through SKINCOLOR_SEND31)
  • Better accounting for color name conflicts
  • Removed 0-15 restriction on invshade, since Lua already does modulo on this internally.
  • Accounted for script being loaded multiple times.
  • srb20233.gif
    srb20233.gif
    1.3 MB · Views: 15
  • srb20234.gif
    srb20234.gif
    1.4 MB · Views: 16
Author
Kaysakado
Downloads
56
Views
538
Extention type
lua
File size
15.1 KB
MD5 Hash
c1e9524a82fc5688878a4c8c4728e9e4
First release
Last update
Rating
4.00 star(s) 2 ratings

Share this resource

Latest reviews

Shouldn't be used as it literally allow crash on-demand but outside of that it's an interesting mod
Upvote 0
I'll be honest; without this, I doubt color addons could get much use. With this on a server, its super easy to let players use whatever they want, without needing to grab anything else! A must-have for servers.
Upvote 0
Top