SA-MP Forums Archive
i need help with /admins! - 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: i need help with /admins! (/showthread.php?tid=505689)



i need help with /admins! - JackieJ - 09.04.2014

Script line:
Код HTML:
CMD:admins(playerid, params[])
{
   new sendername[MAX_PLAYER_NAME],string[64 + MAX_PLAYER_NAME];
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
      if(IsPlayerConnected(i))
	  {
		 if(IsPlayerAdmin(i))
                {
		   GetPlayerName(i, sendername, sizeof(sendername));
		   format(string, 100, "Online Admins: %i", IsPlayerAdmin(i));
		   SendClientMessage, COLOR_GREEN, string);
                }
         }
  }
  return 1;
}
Errors:
Код HTML:
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(869) : warning 217: loose indentation
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1017) : warning 204: symbol is assigned a value that is never used: "rand"
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1387) : error 076: syntax error in the expression, or invalid function call
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1387) : error 029: invalid expression, assumed zero
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1387) : warning 215: expression has no effect
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1391) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: i need help with /admins! - arakuta - 09.04.2014

The errors aren't just on /admins...

This is the correct way to use a function.

pawn Код:
SendClientMessage(i,COLOR_GREEN, string);
You did this:

pawn Код:
SendClientMessage, COLOR_GREEN, string);



Re: i need help with /admins! - JackieJ - 09.04.2014

I know

Im just a beginner did this command self


Re: i need help with /admins! - Stanford - 09.04.2014

The string should be something like this:-
(according to your getplayername)

pawn Код:
format(string, 128, "Online Admins: %s", sendername);



Re: i need help with /admins! - JackieJ - 09.04.2014

I got this error
Код HTML:
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(869) : warning 217: loose indentation
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1017) : warning 204: symbol is assigned a value that is never used: "rand"
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1388) : error 001: expected token: ";", but found "}"
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1391) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: i need help with /admins! - Bingo - 09.04.2014

Quote:
Originally Posted by JackieJ
Посмотреть сообщение
I know

Im just a beginner did this command self
Yes, It shows.

OFFTOPIC:-

Anyway when you learn scripting make sure, Every parameter is placed correctly if you have any doubts just ****** your function .

Small parameters mistake is also noted as well as Pawno is case-sensitive.


Re: i need help with /admins! - JackieJ - 09.04.2014

How can i fix this one?
Quote:

C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(869) : warning 217: loose indentation
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1017) : warning 204: symbol is assigned a value that is never used: "rand"
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(138 : error 001: expected token: ";", but found "}"
C:\Users\Jacob\Desktop\Roleplay Base Script\gamemodes\hrp.pwn(1391) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.




Re: i need help with /admins! - Dignity - 09.04.2014

We can't fix it if you don't show us your code.


Re: i need help with /admins! - JackieJ - 09.04.2014

Код HTML:
CMD:admins(playerid, params[])
{
   new sendername[MAX_PLAYER_NAME],string[64 + MAX_PLAYER_NAME];
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
      if(IsPlayerConnected(i))
	  {
		 if(IsPlayerAdmin(i))
                {
		   GetPlayerName(i, sendername, sizeof(sendername));
		   format(string, 100, "Online Admins: %i", IsPlayerAdmin(i));
		   SendClientMessage, COLOR_GREEN, string);
                }
         }
  }
  return 1;
}



Re: i need help with /admins! - Dignity - 09.04.2014

EDIT:

Quote:
Originally Posted by arakuta
Посмотреть сообщение
This is the correct way to use a function.

pawn Код:
SendClientMessage(i,COLOR_GREEN, string);
You did this:

pawn Код:
SendClientMessage, COLOR_GREEN, string);
Quote:
Originally Posted by Stanford
Посмотреть сообщение
The string should be something like this:-
(according to your getplayername)

pawn Код:
format(string, 128, "Online Admins: %s", sendername);
Exactly what arakuta and Standford said.

Fixed code:
pawn Код:
CMD:admins(playerid, params[])
{
    new sendername[MAX_PLAYER_NAME],string[64 + MAX_PLAYER_NAME];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerAdmin(i))
            {
                GetPlayerName(i, sendername, sizeof(sendername));
                format(string, 100, "Online Admins: %s", sendername);
                SendClientMessage(playerid, COLOR_GREEN, string);
            }
        }
    }
    return 1;
}