Command don't work
#1

Hey guys.. Look at this code...
pawn Код:
CMD:admins(playerid, params[])
{
    if(PlayerInfo[playerid][LoggedIn]) return SendClientMessage(playerid, COLOR_GREY, "NOTLOGGED");
    if(IsPlayerConnected(playerid))
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, " ");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "----------| Online Admins |----------");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(PlayerInfo[i][Level] > 0)
            {
            }
            if(IsPlayerConnected(i))
            {
                new aname[48], atitle[48];
                if(PlayerInfo[i][Level] == 7) { atitle = "Owner"; }
                if(PlayerInfo[i][Level] == 6) { atitle = "Moderator"; }
                if(PlayerInfo[i][Level] == 5) { atitle = "Lead Administrator"; }
                if(PlayerInfo[i][Level] == 4) { atitle = "Senior Administrator"; }
                if(PlayerInfo[i][Level] == 3) { atitle = "Administrator"; }
                if(PlayerInfo[i][Level] == 2) { atitle = "Junior Administrator"; }
                if(PlayerInfo[i][Level] == 1) { atitle = "Trial Administrator"; }
                GetPlayerName(i, aname, sizeof(aname));
/*                if(!AdminDuty[i])
                {
                    format(string, sizeof(string), "[*] [%s] %s (Admin duty: No)", atitle, aname);
                    SendClientMessage(playerid, COLOR_LBLUE, string);
                }
                else
                {
                    format(string, sizeof(string), "[*] [%s] %s (Admin duty: Yes)", atitle, aname);
                    SendClientMessage(playerid, COLOR_LBLUE, string);*/

                }
            continue;
            }
        }
    }
When i compile it here is what i get:
Quote:

E:\Desktop\SA-MP\New folder\gamemodes\SATDMv9.pwn(14674) : warning 209: function "cmd_admins" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.

And when i type /admins in game it just shows NOTLOGGED
And when i do this:
pawn Код:
CMD:admins(playerid, params[])
{
    if(PlayerInfo[playerid][LoggedIn] == 0) //this line is changed
    if(IsPlayerConnected(playerid))
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, " ");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "----------| Online Admins |----------");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(PlayerInfo[i][Level] > 0)
            {
            }
            if(IsPlayerConnected(i))
            {
                new aname[48], atitle[48];
                if(PlayerInfo[i][Level] == 7) { atitle = "Owner"; }
                if(PlayerInfo[i][Level] == 6) { atitle = "Moderator"; }
                if(PlayerInfo[i][Level] == 5) { atitle = "Lead Administrator"; }
                if(PlayerInfo[i][Level] == 4) { atitle = "Senior Administrator"; }
                if(PlayerInfo[i][Level] == 3) { atitle = "Administrator"; }
                if(PlayerInfo[i][Level] == 2) { atitle = "Junior Administrator"; }
                if(PlayerInfo[i][Level] == 1) { atitle = "Trial Administrator"; }
                GetPlayerName(i, aname, sizeof(aname));
/*                if(!AdminDuty[i])
                {
                    format(string, sizeof(string), "[*] [%s] %s (Admin duty: No)", atitle, aname);
                    SendClientMessage(playerid, COLOR_LBLUE, string);
                }
                else
                {
                    format(string, sizeof(string), "[*] [%s] %s (Admin duty: Yes)", atitle, aname);
                    SendClientMessage(playerid, COLOR_LBLUE, string);*/

                }
            continue;
            }
        }
    }
I get no error or warning but command doesn't work.
Any idea what it is or how to fix it?
Reply
#2

"cmd_admins should return a value"
"return a value"
"return"

Add return 1; to the end.
Reply
#3

Quote:
Originally Posted by Stinged
Посмотреть сообщение
"cmd_admins should return a value"
"return a value"
"return"

Add return 1; to the end.
Here is error which i get for "return 1;" line:
Quote:

E:\Desktop\SA-MP\New folder\gamemodes\SATDMv9.pwn(14675) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#4

Try this? I didn't test it.
pawn Код:
CMD:admins(playerid, params[])
{
    if(PlayerInfo[playerid][LoggedIn]) return SendClientMessage(playerid, COLOR_GREY, "NOTLOGGED");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "----------| Online Admins |----------");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new aname[48], atitle[48];
            if(PlayerInfo[i][Level] == 7) { atitle = "Owner"; }
            else if(PlayerInfo[i][Level] == 6) { atitle = "Moderator"; }
            else if(PlayerInfo[i][Level] == 5) { atitle = "Lead Administrator"; }
            else if(PlayerInfo[i][Level] == 4) { atitle = "Senior Administrator"; }
            else if(PlayerInfo[i][Level] == 3) { atitle = "Administrator"; }
            else if(PlayerInfo[i][Level] == 2) { atitle = "Junior Administrator"; }
            else if(PlayerInfo[i][Level] == 1) { atitle = "Trial Administrator"; }
            GetPlayerName(i, aname, sizeof(aname));
            if(AdminDuty[i] == 1)
            {
                format(string, sizeof(string), "[*] [%s] %s (Admin duty: No)", atitle, aname);
                SendClientMessage(playerid, COLOR_LBLUE, string);
            }
            else
            {
                format(string, sizeof(string), "[*] [%s] %s (Admin duty: Yes)", atitle, aname);
                SendClientMessage(playerid, COLOR_LBLUE, string);*/
                return 1;
            }
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by The__
Посмотреть сообщение
Try this? I didn't test it.
pawn Код:
CMD:admins(playerid, params[])
{
    if(PlayerInfo[playerid][LoggedIn]) return SendClientMessage(playerid, COLOR_GREY, "NOTLOGGED");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "----------| Online Admins |----------");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new aname[48], atitle[48];
            if(PlayerInfo[i][Level] == 7) { atitle = "Owner"; }
            else if(PlayerInfo[i][Level] == 6) { atitle = "Moderator"; }
            else if(PlayerInfo[i][Level] == 5) { atitle = "Lead Administrator"; }
            else if(PlayerInfo[i][Level] == 4) { atitle = "Senior Administrator"; }
            else if(PlayerInfo[i][Level] == 3) { atitle = "Administrator"; }
            else if(PlayerInfo[i][Level] == 2) { atitle = "Junior Administrator"; }
            else if(PlayerInfo[i][Level] == 1) { atitle = "Trial Administrator"; }
            GetPlayerName(i, aname, sizeof(aname));
            if(AdminDuty[i] == 1)
            {
                format(string, sizeof(string), "[*] [%s] %s (Admin duty: No)", atitle, aname);
                SendClientMessage(playerid, COLOR_LBLUE, string);
            }
            else
            {
                format(string, sizeof(string), "[*] [%s] %s (Admin duty: Yes)", atitle, aname);
                SendClientMessage(playerid, COLOR_LBLUE, string);*/
                return 1;
            }
        }
    }
    return 1;
}
All same.. Btw this:
pawn Код:
if(AdminDuty[i] == 1)
            {
                format(string, sizeof(string), "[*] [%s] %s (Admin duty: No)", atitle, aname);
                SendClientMessage(playerid, COLOR_LBLUE, string);
            }
            else
            {
                format(string, sizeof(string), "[*] [%s] %s (Admin duty: Yes)", atitle, aname);
                SendClientMessage(playerid, COLOR_LBLUE, string);*/
I made it a comment because i don't need it.
Reply
#6

pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1) // By ******

CMD:admins(playerid, params[])
{
    if(!PlayerInfo[playerid][LoggedIn]) return SendClientMessage(playerid, COLOR_GREY, "NOTLOGGED");
    // How can the player that entered the command not be connected? (removed if (IsPlayerConnect(playerid)))
    SendClientMessage(playerid, COLOR_LIGHTBLUE, " ");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "----------| Online Admins |----------");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][Level] > 0)
        {
            if(IsPlayerConnected(i))
            {
                new atitle[48], string[128], pName[24];
                GetPlayerName(playerid, pName, sizeof (pName));
                switch (PlayerInfo[i][Level])
                {
                    case 1: strcpy(atitle, "Trial Administrator");
                    case 2: strcpy(atitle, "Junior Administrator");
                    case 3: strcpy(atitle, "Administrator");
                    case 4: strcpy(atitle, "Senior Administrator");
                    case 5: strcpy(atitle, "Lead Administrator");
                    case 6: strcpy(atitle, "Moderator");
                    case 7: strcpy(atitle, "Owner");
                }
                format(string, sizeof (string), "%s [level %i] [%s]", pName, PlayerInfo[playerid][Level], atitle);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
            }
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by Stinged
Посмотреть сообщение
pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1) // By ******

CMD:admins(playerid, params[])
{
    if(!PlayerInfo[playerid][LoggedIn]) return SendClientMessage(playerid, COLOR_GREY, "NOTLOGGED");
    // How can the player that entered the command not be connected? (removed if (IsPlayerConnect(playerid)))
    SendClientMessage(playerid, COLOR_LIGHTBLUE, " ");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "----------| Online Admins |----------");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][Level] > 0)
        {
            if(IsPlayerConnected(i))
            {
                new atitle[48], string[128], pName[24];
                GetPlayerName(playerid, pName, sizeof (pName));
                switch (PlayerInfo[i][Level])
                {
                    case 1: strcpy(atitle, "Trial Administrator");
                    case 2: strcpy(atitle, "Junior Administrator");
                    case 3: strcpy(atitle, "Administrator");
                    case 4: strcpy(atitle, "Senior Administrator");
                    case 5: strcpy(atitle, "Lead Administrator");
                    case 6: strcpy(atitle, "Moderator");
                    case 7: strcpy(atitle, "Owner");
                }
                format(string, sizeof (string), "%s [level %i] [%s]", pName, PlayerInfo[playerid][Level], atitle);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
            }
        }
    }
    return 1;
}
Still don't work.. Only thing that work is atitle.. When someone type /admins it shows how many admins is there and their title, but players name.
Example: There are two admins, one is level 7 (owner) and other level 4 (Senior Administrator) and there is guy named Pete who is not admin. He will get this:
Quote:

----------| Online Admins |----------
Pete [Level 7] [Senior Administrator]
Pete [Level 7] [Owner]

It happend right now in my server.
Reply
#8

Please someone help!! I need it urgent! And sorry for double posting!
I think problem is in this line:
pawn Код:
format(string, sizeof (string), "%s [level %i] [%s]", pName, PlayerInfo[playerid][Level], atitle);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
But i don't know how to fix it!
Reply
#9

GetPlayerName(playerid, pName, sizeof (pName));

It's simple really, you're returning the name of the user using the cmd

use GetPlayerName(i, pName, sizeof(pName));

and change PlayerInfo[i][pLevel], basically replace the parts with playerid with i within reason.
Reply
#10

Quote:
Originally Posted by Isolated
Посмотреть сообщение
GetPlayerName(playerid, pName, sizeof (pName));

It's simple really, you're returning the name of the user using the cmd

use GetPlayerName(i, pName, sizeof(pName));

and change PlayerInfo[i][pLevel], basically replace the parts with playerid with i within reason.
Ok, i will test it now.. Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)