/admins cmd not working properly
#1

I am not able to place each admin on new line (\n)
PHP код:
CMD:admins(playerid)
{
    new 
tmp[64], str[144];
    
SCM(playerid, -1""COL_RED"|__________________[On-Duty Admins]_________________|");
    foreach(
Playeri)
    {
        if(
PlayerInfo[i][Team] == TEAM_ADMIN)
        {
            switch(
PlayerInfo[i][Admin])
            {
                case 
1format(tmpsizeof(tmp), " "COL_YELLOW"[%d]%s - Level 1 - Trial Admin"iGetName(i));
                 case 
2format(tmpsizeof(tmp), " "COL_YELLOW"[%d]%s - Level 2 - Server Admin"iGetName(i));
                 case 
3format(tmpsizeof(tmp), " "COL_YELLOW"[%d]%s - Level 3 - Senior Admin"iGetName(i));
                 case 
4format(tmpsizeof(tmp), " "COL_YELLOW"[%d]%s - Level 4 - Lead Admin"iGetName(i));
                 case 
5format(tmpsizeof(tmp), " "COL_YELLOW"[%d]%s - Level 5 - Head Admin"iGetName(i));
                 case 
6format(tmpsizeof(tmp), " "COL_DRED"[%d]%s - Level 6 - Server Owner"iGetName(i));
            }
            
strcat(tmp"\n"sizeof(tmp));
            
strcat(strtmpsizeof(str));
        }
    }
    if(!
strlen(str)) SCM(playerid, -1""COL_YELLOW" No admins on-duty");
    else 
SCM(playerid, -1str);
    
SCM(playerid, -1""COL_RED"|___________________________________________________|");
    return 
1;

Here screenshot:
Reply
#2

I don't use strcat that much but instead of concatenating the string for only the ' \n ' why don't you you add it under the format function?

For example:
pawn Код:
case 1: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 1 - Trial Admin\n", i, GetName(i));
                 case 2: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 2 - Server Admin\n", i, GetName(i));
                 case 3: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 3 - Senior Admin\n", i, GetName(i));
                 case 4: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 4 - Lead Admin\n", i, GetName(i));
                 case 5: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 5 - Head Admin\n", i, GetName(i));
                 case 6: format(tmp, sizeof(tmp), " "COL_DRED"[%d]%s - Level 6 - Server Owner\n", i, GetName(i));
However, this is only my opinion, you can wait for others if you insist on using strcat. You can make it simpler like this:
Код:
CMD:admins(playerid,params[])
{
	new str[70],acount;
	SCM(playerid, -1, ""COL_RED"|__________________[On-Duty Admins]_________________|");
	foreach(Player, i)
    {
		if(PlayerInfo[i][Team] == TEAM_ADMIN)
		{
		    acount++;
		    format(str,sizeof(str), " "COL_YELLOW"[%d]%s - Level %d - Admin", i, GetName(i), PlayerInfo[i][Admin]);
		    SCM(playerid,-1,str);
		}
		if(acount <= 0) return SCM(playerid, -1, ""COL_YELLOW" No admins on-duty");
	}
	SCM(playerid, -1, ""COL_RED"|___________________________________________________|");
	return 1;
}
For custom admin names, you can create a some sort of stock like AdminName(playerid) and formats a string to a desired named according to the player rank, it should be easier too while scripting/adding future features if needed.
Reply
#3

Quote:
Originally Posted by MattTucker
Посмотреть сообщение
I don't use strcat that much but instead of concatenating the string for only the ' \n ' why don't you you add it under the format function?

For example:
pawn Код:
case 1: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 1 - Trial Admin\n", i, GetName(i));
                 case 2: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 2 - Server Admin\n", i, GetName(i));
                 case 3: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 3 - Senior Admin\n", i, GetName(i));
                 case 4: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 4 - Lead Admin\n", i, GetName(i));
                 case 5: format(tmp, sizeof(tmp), " "COL_YELLOW"[%d]%s - Level 5 - Head Admin\n", i, GetName(i));
                 case 6: format(tmp, sizeof(tmp), " "COL_DRED"[%d]%s - Level 6 - Server Owner\n", i, GetName(i));
However, this is only my opinion, you can wait for others if you insist on using strcat.
I removed strcat
problem solved thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)