/color <0-255> <0-255> <0-255>
/setcolor <playerid/name> <0-255> <0-255> <0-255>
/setallcolor <0-255> <0-255> <0-255
/unforce <playerid/name>
// RGB Color commands FS, by knackworst
//==============================================================================
//Includes
//==============================================================================
#include <a_samp>
#include <sscanf>
//==============================================================================
//Defines
//==============================================================================
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 //Don't touch this, it's for the dcmd stuff
//==============================================================================
//Variables
//==============================================================================
new cForced[MAX_PLAYERS];
//------------------------------------------------------------------------------
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Color Commands Loaded");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
cForced[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(color,5,cmdtext);
dcmd(setcolor,8,cmdtext);
dcmd(setallcolor,11,cmdtext);
dcmd(unforce,7,cmdtext);
return 0;
}
dcmd_color(playerid,params[]) // Set ur own color
{
if(cForced[playerid] == 0)
{
static R, G, B;
if (sscanf(params, "iii", R,G,B)) return SendClientMessage(playerid, 0xff0000aa, "*Usage: /color <0-255> <0-255> <0-255>");
SendClientMessage(playerid,(R * 16777216) + (G * 65536) + (B*256), "New color");
SetPlayerColor(playerid, (R * 16777216) + (G * 65536) + (B*256));
}
else return SendClientMessage(playerid, 0xff0000aa, "*This command has been disabled for u");
return 1;
}
dcmd_setcolor(playerid,params[]) // Set another player's color
{
static ID, R, G, B, name[MAX_PLAYER_NAME], string[128];
if (sscanf(params, "uiii", ID, R,G,B)) return SendClientMessage(playerid, 0xff0000aa, "*Usage: /setcolor <playerid/name> <0-255> <0-255> <0-255>");
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "this is your new color, set by %s", name);
SendClientMessage(ID,(R * 16777216) + (G * 65536) + (B*256), string);
GetPlayerName(ID, name, sizeof(name));
format(string, sizeof(string), "this is the new color, u gave to %s, use /unforce to let him change their color again.", name);
SendClientMessage(playerid,(R * 16777216) + (G * 65536) + (B*256), string);
cForced[ID] = 1; //This sets that the player cannot just use /color again after his color has been set
SetPlayerColor(ID, (R * 16777216) + (G * 65536) + (B*256));
return 1;
}
dcmd_setallcolor(playerid,params[]) // Set all the players color
{
static R, G, B, name[MAX_PLAYER_NAME], string[128];
if(!IsPlayerAdmin(playerid)) return 1;
if (sscanf(params, "iii", R,G,B)) return SendClientMessage(playerid, 0xff0000aa, "*Usage: /setallcolor <0-255> <0-255> <0-255>");
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) // Let's not overflood the variables...
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "This is your new color, set by %s", name);
SendClientMessage(i,(R * 16777216) + (G * 65536) + (B*256), string);
SendClientMessage(playerid,(R * 16777216) + (G * 65536) + (B*256), "This is the new color u gave to everyone");
SetPlayerColor(i, (R * 16777216) + (G * 65536) + (B*256));
}
}
return 1;
}
dcmd_unforce(playerid,params[])
{
static ID, name[MAX_PLAYER_NAME], string[128];
if(!IsPlayerAdmin(playerid)) return 1;
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xff0000aa, "*Usage: /unforce <playerid/name>");
if(cForced[ID] != 1) return SendClientMessage(playerid, 0xff0000aa, "*This player is already unforced!");
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has unforced u and u can now use /color again", name);
SendClientMessage(ID, 0x00ff00aa, string);
GetPlayerName(ID, name, sizeof(name));
format(string, sizeof(string), "You have unforced %s, and he's now free to use /color again", name);
SendClientMessage(playerid,0x00ff00aa, string);
cForced[ID] = 0;
return 1;
}
new cForced[MAX_PLAYERS];
cForced[playerid] = 0;
dcmd(color,5,cmdtext);
dcmd(setcolor,8,cmdtext);
dcmd(setallcolor,11,cmdtext);
dcmd(unforce,7,cmdtext);
dcmd_color(playerid,params[]) // Set ur own color
{
if(cForced[playerid] == 0)
{
static R, G, B;
if (sscanf(params, "iii", R,G,B)) return SendClientMessage(playerid, 0xff0000aa, "*Usage: /color <0-255> <0-255> <0-255>");
SendClientMessage(playerid,(R * 16777216) + (G * 65536) + (B*256), "New color");
SetPlayerColor(playerid, (R * 16777216) + (G * 65536) + (B*256));
}
else return SendClientMessage(playerid, 0xff0000aa, "*This command has been disabled for u");
return 1;
}
dcmd_setcolor(playerid,params[]) // Set another player's color
{
static ID, R, G, B, name[MAX_PLAYER_NAME], string[128];
if (sscanf(params, "uiii", ID, R,G,B)) return SendClientMessage(playerid, 0xff0000aa, "*Usage: /setcolor <playerid/name> <0-255> <0-255> <0-255>");
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "this is your new color, set by %s", name);
SendClientMessage(ID,(R * 16777216) + (G * 65536) + (B*256), string);
GetPlayerName(ID, name, sizeof(name));
format(string, sizeof(string), "this is the new color, u gave to %s, use /unforce to let him change their color again.", name);
SendClientMessage(playerid,(R * 16777216) + (G * 65536) + (B*256), string);
cForced[ID] = 1; //This sets that the player cannot just use /color again after his color has been set
SetPlayerColor(ID, (R * 16777216) + (G * 65536) + (B*256));
return 1;
}
dcmd_setallcolor(playerid,params[]) // Set all the players color
{
static R, G, B, name[MAX_PLAYER_NAME], string[128];
if(!IsPlayerAdmin(playerid)) return 1;
if (sscanf(params, "iii", R,G,B)) return SendClientMessage(playerid, 0xff0000aa, "*Usage: /setallcolor <0-255> <0-255> <0-255>");
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) // Let's not overflood the variables...
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "This is your new color, set by %s", name);
SendClientMessage(i,(R * 16777216) + (G * 65536) + (B*256), string);
SendClientMessage(playerid,(R * 16777216) + (G * 65536) + (B*256), "This is the new color u gave to everyone");
SetPlayerColor(i, (R * 16777216) + (G * 65536) + (B*256));
}
}
return 1;
}
dcmd_unforce(playerid,params[])
{
static ID, name[MAX_PLAYER_NAME], string[128];
if(!IsPlayerAdmin(playerid)) return 1;
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xff0000aa, "*Usage: /unforce <playerid/name>");
if(cForced[ID] != 1) return SendClientMessage(playerid, 0xff0000aa, "*This player is already unforced!");
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has unforced u and u can now use /color again", name);
SendClientMessage(ID, 0x00ff00aa, string);
GetPlayerName(ID, name, sizeof(name));
format(string, sizeof(string), "You have unforced %s, and he's now free to use /color again", name);
SendClientMessage(playerid,0x00ff00aa, string);
cForced[ID] = 0;
return 1;
}
I was searching for this for months. Good Job!
I use ZCMD, when I will try to convert them, the specifiers will be the same or they change? |
I don't think it will cause problems : )
but I'm not sure, I'm not familiar with zcmd |