Need Help In This Command
#1

#define FILE_ADMINSS "adminss"
CMDetacolor(playerid, params[])
{
new name[64], color[64], level, string[200], giveplayerss[256], giveplayersss[256], string2[128];
if(adlvl[playerid] < 5) return 0;
if(sscanf(params, "ds[64]s[64]", level, color, name)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /setacolor [level] [color] [name]");
if(level > 6 || level < 1) return SendClientMessage(playerid, COLOR_RED, "Error: The level must be above 1 and below 6.");
format(string,sizeof(string), "You've changed Admin level: %d's color to {%s}%s {FFFFFF}and name to {%s}%s.", level, color, color, color,name);
SendClientMessage(playerid, COLOR_WHITE, string);
format(giveplayerss, 50, "Admin COLOR_LEVEL_%d", level);
format(giveplayersss, 50, "Admin NAME_LEVEL_%d", level);
dini_Set(AddDirFile(dir_datafiles, FILE_ADMINSS), giveplayerss, color);
dini_Set(AddDirFile(dir_datafiles, FILE_ADMINSS), giveplayersss, name);
if(adminuc[playerid] == 0)
{
format(string2, sizeof(string2), "Admin Log: %s has set admin level %d's color to {%s}%s and name to {%s}%s.", GetName(playerid), level, color, color, color, name);
SendMessageToAdmins(COLOR_LIGHTBLUE2, string2);
}
return 1;
}

after using the command it shows me that it changed color but it not changes help me

please help me
Reply
#2

I'd recommend changing the way you name your variables and how you organize your code.

It's very difficult to understand what you have going on.

Instantly off the bat I can see in the "sscanf" portion, you don't need the array values. It correlates the variable type with the variable itself and all the information provided along with it.

Change it to: (params, "dss")

In the part where you format "giveplayerss", change it to:

format(giveplayerss, sizeof(giveplayerss), ..fill in..);

Regarding your files for each admin level and color, etc. why are you adding more files when you should just be editing the pre-existing one?

Maybe I'm just not understanding what you're attempting to do.
Reply
#3

Quote:
Originally Posted by Daymen
Посмотреть сообщение
Change it to: (params, "dss")
?

That would just return a sscanf warning:
Код:
sscanf warning: Strings without a length are deprecated, please add a destination size.
Silver, put your code in [PHP] please.
Reply
#4

I want that pls fix this command.and give me full pls
Reply
#5

What?
Reply
#6

This is the correct way

PHP код:
#define FILE_ADMINSS "adminss"
CMDetacolor(playeridparams[])
{
new 
name[64], color[64], levelstring[200], giveplayerss[256], giveplayersss[256], string2[128];
if(
adlvl[playerid] < 5) return 0;
if(
sscanf(params"ds[64]s[64]"levelcolorname)) return SendClientMessage2(playeridCOLOR_WHITE"Usage: /setacolor [level] [color] [name]");
if(
level || level 1) return SendClientMessage(playeridCOLOR_RED"Error: The level must be above 1 and below 6.");
format(string,sizeof(string), "You've changed Admin level: %d's color to {%s}%s {FFFFFF}and name to {%s}%s."levelcolorcolorcolor,name);
SendClientMessage(playeridCOLOR_WHITEstring);
format(giveplayerss50"ADLC_%d"level);//ADLC means Admin Level Color
format(giveplayersss50"ADLN_%d"level);//ADLN means Admin Level Name
dini_Set(AddDirFile(dir_datafilesFILE_ADMINSS), giveplayersscolor);
dini_Set(AddDirFile(dir_datafilesFILE_ADMINSS), giveplayersssname);
if(
adminuc[playerid] == 0)
{
format(string2sizeof(string2), "Admin Log: %s has set admin level %d's color to {%s}%s and name to {%s}%s."GetName(playerid), levelcolorcolorcolorname);
SendMessageToAdmins(COLOR_LIGHTBLUE2string2);
}
return 
1;

I hope this will work
Reply
#7

Here this is the problem occuring and the problem he want to explain



When we does /setacoloraname, it set's the name and color but in /admins, its same.
this is the problem he wants to explain

Give /setacoloraname command which changes admin color and admin name and also changes /asay color according to that admin color we put.
Reply
#8

It depends how you're getting the information in the /admins command. You probably haven't updated the data you're using to get the color/name. Post the /admins code and we might be able to be a bit more helpful.

In order to make sure the command, /setacoloraname is working properly as is. Use that command and then relog, or restart the server and see if it changes. If it does then you aren't updating data if it doesn't, something else is going on.
Reply
#9

/** Admins Command Is Here **/
/* Admin Level Names */
#define ADMIN_LEVEL_1 "Trial Moderator"
#define ADMIN_LEVEL_2 "Moderator"
#define ADMIN_LEVEL_3 "Administrator"
#define ADMIN_LEVEL_4 "Senior Administrator"
#define ADMIN_LEVEL_5 "Lead Administrator"
#define ADMIN_LEVEL_6 "Community Manager"


/* Admin Level Colors */
#define COLOR_ADMIN_1 0x7CFC00
#define COLOR_ADMIN_2 0xFF0000
#define COLOR_ADMIN_3 0xFFFF00
#define LEVEL_1_COLOR "{FF8C00}"
#define LEVEL_2_COLOR "{0000CD}"
#define LEVEL_3_COLOR "{FF0000}"
#define LEVEL_4_COLOR "{FF0000}"
#define LEVEL_5_COLOR "{7CFC00}"
#define LEVEL_6_COLOR "{7CFC00}"

stock ALVLCN(lvl)
{
new string[128];
switch(lvl)
{
case 1:
{
format(string, 128, "%s %s", LEVEL_1_COLOR, ADMIN_LEVEL_1);
}
case 2:
{
format(string, 128, "%s %s", LEVEL_2_COLOR, ADMIN_LEVEL_2);
}
case 3:
{
format(string, 128, "%s %s", LEVEL_3_COLOR, ADMIN_LEVEL_3);
}
case 4:
{
format(string, 128, "%s %s", LEVEL_4_COLOR, ADMIN_LEVEL_4);
}
case 5:
{
format(string, 128, "%s %s", LEVEL_5_COLOR, ADMIN_LEVEL_5);
}
case 6:
{
format(string, 128, "%s %s", LEVEL_6_COLOR, ADMIN_LEVEL_6);
}
}
return string;
}

CMD:admins(playerid, params[])
{
new moneys1, string[128];
for (new i = 0; i < PLAYERS; i++)
{
if (IsPlayerConnected2(i))
{
if (adlvl[playerid] > 0 && adminuc[i] == 0)
{
moneys1++;
}
else if(adlvl[playerid] == 6)
{
if(adlvl[playerid] > 0 && adminuc[i] == 1)
{
moneys1++;
}
}
}
}
if (moneys1 != 0)
{
SendClientMessage(playerid, COLOR_ADMIN, "• • Online Administration • •");
new p=6;
while (p > 0)
{
for (new i = 0; i < PLAYERS; i++)
{
if (adlvl[i] == p && adminuc[i] == 0)
{
format(string, 128, "{FFFFFF}%s - (%s{FFFFFF} ) [Level - %d]", RPN(i), ALVLCN(p),p);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else if(adlvl[i] == p && adminuc[i] == 1)
{
if(adlvl[playerid] == 6)
{
format(string, 128, "{FFFFFF}%s - (%s{FFFFFF} ) [Level - %d] {UNDERCOVER}", RPN(i), ALVLCN(p),p);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
}
p--;
}
}
else SendClientMessage(playerid, COLOR_RED, "There are currently no admins online.");
return 1;
}
Reply
#10

You need to edit your last post and put the code inside

[ php ]
and
[ / php ]

It makes our life alot easier. Also the reason that your /admins command isn't working is because you aren't reading from the file of where you're saving your /setacoloraname and that's why it isn't working. You need to read from the file what the color, and name is before you display it. I personally don't have much knowledge with dini but here's what should hopefully work. This is untested.

I redid your /admins command because it was a bit all over the place and there are alot simplier ways of doing it.

PHP код:
AdminLevelColor(level)
{
    new 
string[128], color[256];
    
format(string,sizeof(string),"ADLC_%d"level);
    
color dini_Get(AddDirFile(dir_datafilesFILE_ADMINSS), string);
    
format(string,sizeof(string),"%s"color);
    return 
string;
}
AdminLevelName(level)
{
    new 
string[128], name[256];
    
format(string,sizeof(string),"ADLN_%s"level);
    
name dini_Get(AddDirFile(dir_datafilesFILE_ADMINSS), string);
    
format(string,sizeof(string),"%s"name);
    return 
string;
}
CMD:admins(playerid)
{
    new 
count=0string[65];
    for(new 
players 0players MAX_PLAYERSplayers++)
    {
        if(!
IsPlayerConnected(players)) continue;
        if((
adminuc[players] == 1) && (adlvl[playerid]!= 6))
        {
            
SendClientMessage(playeridCOLOR_GREEN" ");
            
SendClientMessage(playeridCOLOR_GREEN"___________ |- Online Admins -| ___________");
            
SendClientMessage(playeridCOLOR_GREEN" ");
            
format(stringsizeof(string), "{FFFFFF}%s - ({%06x}%s) {FFFFFF}[Level - %d]"RPN(players), AdminLevelColor(adlvl[players] >>> 8), AdminLevelName(adlvl[players]),adlvl[players]);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
count++;
        }
        if((
adminuc[players] == 1) && (adlvl[playerid]== 6))
        {
            
format(stringsizeof(string), "{FFFFFF}%s - ({%06x}%s) {FFFFFF}[Level - %d] {UNDERCOVER}"RPN(players), AdminLevelColor(adlvl[players] >>> 8), AdminLevelName(adlvl[players]),adlvl[players]);
            
SendClientMessage(playeridCOLOR_WHITEstring);
        }
    }
    if(!
count) return SendClientMessage(playeridCOLOR_ADMIN"There are currently no administrators online.");
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)