/admins not working properly
#1

Код:
CMD:admins(playerid, params[])
{
	new online, astring[256],string[50];
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
	{
		if(PlayerInfo[i][pAdmin]) online ++;
	}
	if(online == 0) return SendClientMessage(playerid, COLOR_GREY, "- Theres no admins online -");
	format(string, sizeof(string), "- NY:RP Admins (%d Online) -", online);
	SendClientMessage(playerid, COLOR_LIGHTRED, string);
	for(new x = 0, j = GetPlayerPoolSize(); x <= j; x++)
	{
		if(PlayerInfo[x][pAdmin])
		{
			format(astring, sizeof(astring), "{A35346}Name: {FFFFFF}%s{FFFFFF} | {A35346}Admin Level: {FFFFFF}%s (%d){FFFFFF} | {A35346}Admin Duty:{FFFFFF} %s |", RPN(x), RPALN(x), PlayerInfo[x][pAdmin], ADSTAT(x));
			SendClientMessage(playerid, COLOR_WHITE, astring);
		}
	}
	SendClientMessage(playerid, COLOR_YELLOW, "Do not PM admins! Use /report & before reporting use /rules.");
	return 1;
}
I see 1 online admin but astring is not showing. If other admins connect, its showing only them..
Why this is happening? Help..
Reply
#2

This string is of excessive length
pawn Код:
format(astring, sizeof(astring), "{A35346}Name: {FFFFFF}%s{FFFFFF} | {A35346}Admin Level: {FFFFFF}%s (%d){FFFFFF} | {A35346}Admin Duty:{FFFFFF} %s |", RPN(x), RPALN(x), PlayerInfo[x][pAdmin], ADSTAT(x));
It would be better to use string concatenation.
Reply
#3

Quote:
Originally Posted by Dokins
Посмотреть сообщение
This string is of excessive length
pawn Код:
format(astring, sizeof(astring), "{A35346}Name: {FFFFFF}%s{FFFFFF} | {A35346}Admin Level: {FFFFFF}%s (%d){FFFFFF} | {A35346}Admin Duty:{FFFFFF} %s |", RPN(x), RPALN(x), PlayerInfo[x][pAdmin], ADSTAT(x));
It would be better to use string concatenation.
what do you mean? can you show me? it will help me on future strings.
Reply
#4

I think he says that you shouldn't have strings that long.
PS:The maximum client message is 128 characters. Measure them with http://www.lettercount.com/. (add some _random_ data to the strings, so you would know how long it need to be)
For example a string like: %s have joined the server! would be transformed to: A_LONG_PLAYER_NAME_12345 have joined the server! before counting the characters.
Reply
#5

Bro, Try this, Rep+ if it works please
PHP код:
CMD:admins(playeridparams[]) {
     new 
Str[200], Name[MAX_PLAYER_NAME];
     
SendClientMessage(playeridCOLOR_GREEN"-------Online Admins-------");
     for(new 
0<= GetPlayerPoolSize(); i++) {
          if(
IsPlayerAdmin(i)) { //Of course, Change IsPlayerAdmin to detect custom admin level.
               
GetPlayerName(playeridNamesizeof(Name));
               
format(Strsizeof(Str), "%s - ID:%i"Nameplayerid);
               
SendClientMessage(playeridCOLOR_GREYStr);
          }
     }
     return 
1;

Reply
#6

Quote:
Originally Posted by Arbico
Посмотреть сообщение
Bro, Try this, Rep+ if it works please
PHP код:
CMD:admins(playeridparams[]) {
     new 
Str[200], Name[MAX_PLAYER_NAME];
     
SendClientMessage(playeridCOLOR_GREEN"-------Online Admins-------");
     for(new 
0<= GetPlayerPoolSize(); i++) {
          if(
IsPlayerAdmin(i)) { //Of course, Change IsPlayerAdmin to detect custom admin level.
               
GetPlayerName(playeridNamesizeof(Name));
               
format(Strsizeof(Str), "%s - ID:%i"Nameplayerid);
               
SendClientMessage(playeridCOLOR_GREYStr);
          }
     }
     return 
1;

not working.
Reply
#7

PHP код:
CMD:admins(playeridparams[])
{
    new 
onlineastring[256],string[50];
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(
IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0)
        {
            
online ++;
            
format(stringsizeof(string), "- NY:RP Admins (%d Online) -"online);
            
format(astringsizeof(astring), "{A35346}Name: {FFFFFF}%s{FFFFFF} | {A35346}Admin Level: {FFFFFF}%s (%d){FFFFFF} | {A35346}Admin Duty:{FFFFFF} %s |\n\r"RPN(i), RPALN(i), PlayerInfo[i][pAdmin], ADSTAT(i));
        }
    }
    if(
online)
    {
        
SendClientMessage(playeridCOLOR_LIGHTREDstring);
        
SendClientMessage(playeridCOLOR_WHITEastring);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GREY"- Theres no admins online -");
        
SendClientMessage(playeridCOLOR_YELLOW"Do not PM admins! Use /report & before reporting use /rules.");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)