[Help]Dcmd & sscanf errors
#1

Can Someone fix this please?
I get these errors

pawn Код:
TestLogin.pwn(155) : warning 211: possibly unintended assignment
TestLogin.pwn(155) : error 022: must be lvalue (non-constant)
TestLogin.pwn(155) : error 029: invalid expression, assumed zero
TestLogin.pwn(155) : warning 215: expression has no effect
TestLogin.pwn(155) : error 029: invalid expression, assumed zero
TestLogin.pwn(155) : fatal error 107: too many error messages on one line
pawn Код:
dcmd_makeadmin(playerid, params[])
{
    if (strlen(params))
    {
        if(pAdmin =< 2)
        {
            new
                pID,
                level;
            if (!sscanf(params, "ii", pID, level)
            {
                if (pID != INVALID_PLAYER_ID)
                {
                    new msg;
                    INI_WriteInt(File,"Admin",level);
                    SendClientMessage(playerid, COLOR_WHITE, "You have been promoted");
                }
                else SendClientMessage(playerid, COLOR_WHITE, "Player not connected");
            }
            else SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /makeadmin <playerid> <level>");
        }
        else SendClientMessage(playerid, COLOR_WHITE, "You need to be at least level 2 for this command")
    }
    return 1;
}
Reply
#2

You're missing a bracket on the 'sscanf' if line. Put a bracket at the end.
Reply
#3

Try this.

pawn Код:
dcmd_makeadmin(playerid, params[])
{
    if (strlen(params))
    {
        if(pAdmin =< 2)
        {
            new
                pID,
                level;
            if (!sscanf(params, "ii", pID, level)) // Add a ")" at the end.
            {
                if (pID != INVALID_PLAYER_ID)
                {
                    new msg;
                    INI_WriteInt(File,"Admin",level);
                    SendClientMessage(playerid, COLOR_WHITE, "You have been promoted");
                }
                else SendClientMessage(playerid, COLOR_WHITE, "Player not connected");
            }
            else SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /makeadmin <playerid> <level>");
        }
        else SendClientMessage(playerid, COLOR_WHITE, "You need to be at least level 2 for this command")
    }
    return 1;
}
Reply
#4

Thanks.. I cant believe I missed that but I still get some problems

pawn Код:
TestLogin.pwn(155) : warning 213: tag mismatch
TestLogin.pwn(155) : warning 206: redundant test: constant expression is non-zero

pawn Код:
dcmd_makeadmin(playerid, params[])
{
    if (strlen(params))
    {
        if(pAdmin <= 2) //Line 155
        {
            new
            pID,
            level;
            if (!sscanf(params, "ii", pID, level)) // Line 160            
            {
                    if (pID != INVALID_PLAYER_ID)
                    {
                        new INI:File = INI_Open(UserPath(pID));
                        INI_WriteInt(File,"Admin",level);
                        SendClientMessage(playerid, COLOR_WHITE, "You have been promoted");
                    }
                    else SendClientMessage(playerid, COLOR_WHITE, "Player not connected");
            }
            else SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /makeadmin <playerid> <level>");
        }
        else SendClientMessage(playerid, COLOR_WHITE, "You need to be at least level 2 for this command");
    }
    return 1;
}
Reply
#5

Can you show us where you declare 'pAdmin'?

Also, you haven't included the sscanf include. Assuming you have the necessary files, you need:
pawn Код:
#include <sscanf>
at the top of your script (but under the inclusion of a_samp).
Reply
#6

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Can you show us where you declare 'pAdmin'?

Also, you haven't included the sscanf include. Assuming you have the necessary files, you need:
pawn Код:
#include <sscanf>
at the top of your script (but under the inclusion of a_samp).
pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
I hope thats what you mean
Reply
#7

Quote:
Originally Posted by Jagofr
Посмотреть сообщение
pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
I hope thats what you mean
Dont worry I got it.. Just needed to change
pawn Код:
if(pAdmin <= 2)
to
pawn Код:
if(PlayerInfo[playerid][pAdmin] <= 2)
I hope thiis was nt mch of a bother
Reply
#8

New problem
I get no errors; or so I thought but I get this in my server_log:

"sscanf warning: Format specifier does not match parameter count."

And in-game if I do
/makeadmin 0
It does
pawn Код:
else if (PlayerInfo[playerid][pAdmin] <= 3)
    {
        new INI:File = INI_Open(UserPath(pID));
        INI_WriteInt(File,"Admin",level);
        SendClientMessage(pID, COLOR_WHITE, "Level changed!");
        SendClientMessage(playerid, COLOR_WHITE, "Player level changed!");
    }
or if I do
/makeadmin 0 5
it does
pawn Код:
else if (PlayerInfo[playerid][pAdmin] <= 3)
    {
        new INI:File = INI_Open(UserPath(pID));
        INI_WriteInt(File,"Admin",level);
        SendClientMessage(pID, COLOR_WHITE, "Level changed!");
        SendClientMessage(playerid, COLOR_WHITE, "Player level changed!");
    }
but no change in the .ini file
Help!!
Here is the dcmd code


pawn Код:
dcmd_makeadmin(playerid, params[])
{
    new pID,
        level;
    if (sscanf(params, "u", pID, level)) SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: \"/makeadmin <playerid> <level>\"");
    else if (pID == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_WHITE, "No such player!");
    else if (PlayerInfo[playerid][pAdmin] <= 3)
    {
        new INI:File = INI_Open(UserPath(pID));
        INI_WriteInt(File,"Admin",level);
        SendClientMessage(pID, COLOR_WHITE, "Level changed!");
        SendClientMessage(playerid, COLOR_WHITE, "Player level changed!");
    }
    else SendClientMessage(playerid, COLOR_WHITE, "Need to be at least Admin Level 3 to use this command");
    return 1;
}
Reply
#9

You're only giving sscanf on specifier in your last example, though are telling sscanf you're expecting two variables (pID, level). Add another specifier for "level" (probably 'i' if it's an integer).
Reply
#10

Can I ask you one more question?

I fixed the integer problem but it still doesnt change anything in the .ini file and completley ignores the level setting when I use the command in-game

Anything else im doing wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)