Resource icon

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

This content may be freely modified and/or maintained by anyone.

Kaysakado

Member
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.
 

Attachments

  • srb20233.gif
    srb20233.gif
    1.3 MB · Views: 13,180
  • srb20234.gif
    srb20234.gif
    1.4 MB · Views: 14,477
  • sendcolor-v7.lua
    15.1 KB · Views: 572
Last edited:
It can go into releases, but I would very much like to have a GIF of another player adding their color and it appearing for you. Its strange not having any visual example of the functionality, like other releases.
 
This is technically a lua file, but with the new skincolor sub-forum I think it makes more sense for this to be in there. So I'll just go ahead and move this over.
 
Good timing, I was gonna ask if it should be moved here! Anyways, v3 v4 is out:
  • 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.
 
Last edited:
Incredible work - despite some minor errors, this works perfectly. Honestly invalidates this entire releases category, sans the animated stuff.
 
Would it be possible to have the player automatically send their colour to the server upon joining?
 
Version 5! Check OP for changelog. Attachments still broken, so have a mirror for now: Attachment is up.
 
Last edited:
Would there be a way to increase the number of colors each player could send while still keeping it a relatively low number? I was thinking about four or five colors per player would be useful to help showcase one's roster of colors.
 
v6 is up! This has various bug-fixes, and adds options for saving the author and uploader of a color. This will probably be the last update, aside from some small adjustments that need to be made when .2.7 drops.
 
So it seems that it is possible to freeze the game(SRB2 stopped responding) with this mod with incorrectly formated file(which seems correct).


The cause from it seems to have been found : Actually if the first character of the name is a digit SRB2 stop responding.
 
Last edited:
So it seems that it is possible to freeze the game(SRB2 stopped responding) with this mod with incorrectly formated file(which seems correct).


The cause from it seems to have been found : Actually if the first character of the name is a digit SRB2 stop responding.
Huh, super weird. Thanks for bringing this to my attention. When I get some free time I'll see if I can sort this out, but for now I'll just make a note not to use special characters as the first character in the OP.
 
I keep getting this error message "Invalid value for field ramp" when trying to make a .txt file to send a color to servers. Does anyone know a fix for this?
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top