SA-MP Forums Archive
/admins not working properly - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /admins not working properly (/showthread.php?tid=640210)



/admins not working properly - maximthepain - 29.08.2017

Код:
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..


Re: /admins not working properly - Dokins - 29.08.2017

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.


Re: /admins not working properly - maximthepain - 29.08.2017

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.


Re: /admins not working properly - 10MIN - 29.08.2017

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.


Re: /admins not working properly - Arbico - 29.08.2017

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;




Re: /admins not working properly - maximthepain - 29.08.2017

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.


Re: /admins not working properly - DarkBr - 29.08.2017

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;