Why are you so obsessed with regex?
PHP Code:
public Action Command_EnterRGBA(int client, int args)
{
if (args != 4)
{
ReplyToCommand(client, "[SM] Usage: sm_rgba <0-255> <0-255> <0-255> <0-255>");
return Plugin_Handled;
}
if (client == 0 || !IsClientInGame(client))
{
ReplyToCommand(client, "[SM] You must be in-game to use this command!");
return Plugin_Handled;
}
char str1[4], str2[4], str3[4], str4[4];
GetCmdArg(1, str1, sizeof(str1));
GetCmdArg(2, str2, sizeof(str2));
GetCmdArg(3, str3, sizeof(str3));
GetCmdArg(4, str4, sizeof(str4));
int r = StringToInt(str1);
if (!(0 <= r <= 255))
{
ReplyToCommand(client, "[SM] Red value is outside the valid range of 0-255.");
return Plugin_Handled;
}
int g = StringToInt(str2);
if (!(0 <= g <= 255))
{
ReplyToCommand(client, "[SM] Green value is outside the valid range of 0-255.");
return Plugin_Handled;
}
int b = StringToInt(str3);
if (!(0 <= b <= 255))
{
ReplyToCommand(client, "[SM] Blue value is outside the valid range of 0-255.");
return Plugin_Handled;
}
int a = StringToInt(str4);
if (!(0 <= a <= 255))
{
ReplyToCommand(client, "[SM] Alpha value is outside the valid range of 0-255.");
return Plugin_Handled;
}
// use RGBA how you want
return Plugin_Handled;
}