/admins problems :\ -
Devilxz97 - 27.11.2012
hey guys , i need some help here. hmm
im trying to make /admins cmd , but its fail :\
im not scripting for a long time and now im just back , and i didnt good on scripting anymore hmm ,
gonna learn it back like a shit xD
here is my code.
pawn Код:
CMD:admins(playerid, params[])
{
new Count = 0;
for(new i = 0; i <MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin] > 0)
{
new str[1000];
new Admin[MAX_PLAYER_NAME];
GetPlayerName(i, Admin, sizeof(Admin));
format(str, sizeof(str), "[Admin]'%s - level %d", Admin, PlayerInfo[i][pAdmin]);
SendClientMessage(playerid, lightred, str);
Count++;
}
if(Count == 0)
{
SendClientMessage(playerid, lightred, "[System]: No Admin Online!");
}
}
return 1;
}
when no admin online , its spam it !
pawn Код:
[System]: No Admin Online!
[System]: No Admin Online!
[System]: No Admin Online!
[System]: No Admin Online!
[System]: No Admin Online!
[System]: No Admin Online!
[System]: No Admin Online!
[System]: No Admin Online!
[System]: No Admin Online!
[System]: No Admin Online!
idk if it show an online admin ? hmm
like a shit lol . hmm help me plss
Re: /admins problems :\ -
tyler12 - 27.11.2012
pawn Код:
CMD:admins(playerid, params[])
{
new Count = 0;
for(new i = 0; i <MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin] > 0)
{
new str[1000];
new Admin[MAX_PLAYER_NAME];
GetPlayerName(i, Admin, sizeof(Admin));
format(str, sizeof(str), "[Admin]'%s - level %d", Admin, PlayerInfo[i][pAdmin]);
SendClientMessage(playerid, lightred, str);
Count++;
}
}
if(Count == 0)
{
SendClientMessage(playerid, lightred, "[System]: No Admin Online!");
}
return 1;
}
Re: /admins problems :\ -
Devilxz97 - 27.11.2012
hmm sec let me try
Re: /admins problems :\ -
ViniBorn - 27.11.2012
Don't use str[1000] in this case...
pawn Код:
CMD:admins(playerid, params[])
{
new bool:Count;
for(new i, j = GetMaxPlayers(); i != j; i++)
if(PlayerInfo[i][pAdmin] > 0)
{
new str[45], Admin[MAX_PLAYER_NAME];
GetPlayerName(i, Admin, MAX_PLAYER_NAME);
format(str, sizeof(str), "[Admin]'%s - level %d", Admin, PlayerInfo[i][pAdmin]);
SendClientMessage(playerid, lightred, str);
Count = true;
}
if(!Count) SendClientMessage(playerid, lightred, "[System]: No Admin Online!");
return 1;
}
Re: /admins problems :\ -
CentyPoo - 27.11.2012
Shouldn't you want to be creating the 2 strings outside the loop? Or it'll be creating the same string every time an admin is detected..
pawn Код:
CMD:admins(playerid, params[])
{
new bool:Count;
new str[45], Admin[MAX_PLAYER_NAME];
for(new i, j = GetMaxPlayers(); i != j; i++)
{
if(PlayerInfo[i][pAdmin] > 0)
{
GetPlayerName(i, Admin, MAX_PLAYER_NAME);
format(str, sizeof(str), "[Admin]'%s - level %d", Admin, PlayerInfo[i][pAdmin]);
SendClientMessage(playerid, lightred, str);
Count = true;
}
}
if(!Count) SendClientMessage(playerid, lightred, "[System]: No Admin Online!");
return 1;
}
Re: /admins problems :\ -
tyler12 - 27.11.2012
.. All it was was sending the message in the loop.
Re: /admins problems :\ -
CentyPoo - 27.11.2012
Quote:
Originally Posted by tyler12
.. All it was was sending the message in the loop.
|
pawn Код:
new str[45], Admin[MAX_PLAYER_NAME];
This was inside the loop, which is creating the two string variables. Why do you need to create them more than once?