/admins problems :\
#1

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
Reply
#2

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;
}
Reply
#3

hmm sec let me try
Reply
#4

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;
}
Reply
#5

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;
}
Reply
#6

.. All it was was sending the message in the loop.
Reply
#7

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)