[FilterScript] RGB_Color_CMDS
#1

RGB_Color_CMDS
Hello everybody,
This is just a very simple script with some ingame commands perfect for Stunt/Fun/FreeRoam

Код:
/color <0-255> <0-255> <0-255>
ok so what this does is, it set's your color into the RGB value that u have chosen...
I have only seen this system in 2 servers, Awesome Stuntages and Impulse99, sadly enough both servers closed, so I think that this system is unique...
also other big stunt servers haven't got this system I guess... (don't be mad if i'm incorrect)

if u are not familiar with RGB, it's a way of color notation that gives u the ability to make
16581375 colors, just go ingame type /color <values> , change the values to whatever color suits you : )

more commands:
Код:
/setcolor <playerid/name> <0-255> <0-255> <0-255>
this will set an other player color, and force him to not be able to use /color again (only for administrators)
so that the player cannot just change their color again after their color has been set by an administrator...

Код:
/setallcolor <0-255> <0-255> <0-255
some as setcolor, but will just set it for all...
NOTE: all the players can just use /color again, so it's not exactly like setcolor...

Код:
/unforce <playerid/name>
this command is for admins only, and will set that the player will be free to use /color again after their color has been set...

I hope that was all very clear...

Screenshots:

I see no need for screenshots...

Code:
pawn Код:
// 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;
}
IMPORTANT
In order to use those commands in game make sure u have installed sscanf
if u do not have sscanf installed yet, search it in the search function on the forums, download and install properly...

If you use ZCMD in ur server as command processor, the commands won't work, to fix this change every dcmd command in this script into ZCMD commands...

I know that I did use sscanf sometimes when it was not nescesairy, i could aswell do it with strok or something like that, but I do not know how to do that...
This is when only 1 parameter is needed I think...
If u know how to use that, please teach me


Permissions:
You may remove credits
You may sell
but just don't claim it as yours...

Please report any problems/bugs
thank you : )

How to install:
open up a new pawn file, and paste the code that I posted above...
save it with a name u want to chose.
Go to your server.cfg and add the name that u have just chosen after the filterscripts.

converting to your GM:
open your gamemode
inluced sscanf
add the define line for dcmd, if not included in ur GM already
go under all your defines and add this:
pawn Код:
new cForced[MAX_PLAYERS];
go to ur OnPLayerConnect callback in your GM
and add this under it:
pawn Код:
cForced[playerid] = 0;
go to your OnPlayerCommandText callback in ur GM and add this:
pawn Код:
dcmd(color,5,cmdtext);
    dcmd(setcolor,8,cmdtext);
    dcmd(setallcolor,11,cmdtext);
    dcmd(unforce,7,cmdtext);
go to some place in ur GM after a callback (not in a callback!)
and add this:
pawn Код:
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;
}
and u shud be good to go : )

if u are going to use this in your server, or u are going to edit this, please give me a rep : )
thank you.
Reply
#2

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?
Reply
#3

Quote:
Originally Posted by Kostas'
Посмотреть сообщение
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
Reply
#4

Gj Man !
Reply
#5

Quote:
Originally Posted by knackworst
Посмотреть сообщение
I don't think it will cause problems : )
but I'm not sure, I'm not familiar with zcmd
Yep, it works fine with ZCMD.
Thank you
Reply
#6

worked...
but when the player changed his color, his markers on radar is gone....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)