For scripting examples for learning how to use AMXX.
Archive-Poster
Posts: 1249
Gender:
Archive-Poster
Profile
Joined: Tue Aug 04, 2026 2:18 am
Gender:
Post
by Archive-Poster » Tue Aug 18, 2026 5:55 am
This is a simple plugin mod to optionally change your imessages from the boring same old colors, to random colors each new map. Any one or all colors can be made to randomize. To accomplish this, edit the stock imessage.sma setMessage() routine as so:
Original:
Code: Select all
read_argv(2, mycol, 11) // RRRGGGBBB
g_Values[g_MessagesNum][2] = str_to_num(mycol[6])
mycol[6] = 0
g_Values[g_MessagesNum][1] = str_to_num(mycol[3])
mycol[3] = 0
g_Values[g_MessagesNum][0] = str_to_num(mycol[0])
Modified (added code):
Code: Select all
read_argv(2, mycol, 11) // RRRGGGBBB
g_Values[g_MessagesNum][2] = str_to_num(mycol[6])
if (g_Values[g_MessagesNum][2] == 256)
g_Values[g_MessagesNum][2] = random(200) + 25
mycol[6] = 0
g_Values[g_MessagesNum][1] = str_to_num(mycol[3])
if (g_Values[g_MessagesNum][1] == 256)
g_Values[g_MessagesNum][1] = random(200) + 25
mycol[3] = 0
g_Values[g_MessagesNum][0] = str_to_num(mycol[0])
if (g_Values[g_MessagesNum][0] == 256)
g_Values[g_MessagesNum][0] = random(200) + 25
}
Then, for a random color(s) in your imessage(s), edit your amxx.cfg amx_imessage statements by replacing any RRR/GGG/BBB color with the value 256.
Example:
Code: Select all
amx_imessage "Welcome to %hostname%" "256256256"
Archive-Poster
Posts: 1249
Gender:
Archive-Poster
Profile
Joined: Tue Aug 04, 2026 2:18 am
Gender:
Post
by Archive-Poster » Tue Aug 18, 2026 5:56 am
Small differences in AMX MOD X v1.8.1
Original:
Code: Select all
read_argv(2, mycol, 11) // RRRGGGBBB
vals[2] = str_to_num(mycol[6])
mycol[6] = 0
vals[1] = str_to_num(mycol[3])
mycol[3] = 0
vals[0] = str_to_num(mycol[0])
Modified (added code):
Code: Select all
read_argv(2, mycol, 11) // RRRGGGBBB
vals[2] = str_to_num(mycol[6])
if (vals[2] == 256)
vals[2] = random(200) + 25
mycol[6] = 0
vals[1] = str_to_num(mycol[3])
if (vals[1] == 256)
vals[1] = random(200) + 25
mycol[3] = 0
vals[0] = str_to_num(mycol[0])
if (vals[0] == 256)
vals[0] = random(200) + 25
Archive-Poster
Posts: 1249
Gender:
Archive-Poster
Profile
Joined: Tue Aug 04, 2026 2:18 am
Gender:
Post
by Archive-Poster » Tue Aug 18, 2026 6:07 am
this only works map by map?...
1) i change to de_dust2, random color
2) i change to de_inferno, another color
it's possible to change when the messages appears every time?
All the imessages (thus color values) are read at the map start via amxx.cfg. If you want random colors each time, you'd need a different plugin. I'd be suprised if one wasn't already been written to do that. This thread just demonstrates a simple modification to a stock plugin.
Users browsing this forum: No registered users and 0 guests