Errors with DCMD and y_ini
#1

So this is the first time I've ever made this type of command, and I tried doing all of it by myself so I could feel good but it didn't work out :P

pawn Код:
dcmd_unban(playerid, params[]) // Level 1
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new target, user[128], string[128];
if(sscanf(params, "s", target)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", target);
    if(INI_Exists(user))
    {
        new INI:File = INI_Open(user);
        INI_SetTag(user,"Main");
        INI_WriteInt(user, "Banned", 0);
        format(string, sizeof(string), "None");
        strmid(PlayerInfo[target][pBanReason], string, 0, strlen(string), 255);
        INI_WriteString(user, "BanReason", PlayerInfo[target][pBanReason]);
        foreach(Player, i);
        {
            if(PlayerInfo[i][pAdmin] >= 1)
            {
                format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), target);
                SendClientMessage(i, COLOR_LIGHTRED, string);
                return 1;
            }
        }
        INI_Close(target);
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
        return 1;
    }
    return 1;
}
Код:
(1204) : error 036: empty statement
(1206) : error 017: undefined symbol "i"
(1209) : error 017: undefined symbol "i"
Only error that shouldn't be there is undefined symbol "i".. because I've used foreach on every other command and it's worked fine, but yeah.

EDIT:
I fixed half the errors, "user" was meant to be "File", I knew that, just didn't realize xD Still, no idea why foreach isn't working.

EDIT2:
Fixed, had a ; at the end of the foreach, xD
Reply
#2

I'm not good with y_ini, but your foreach problem is because you have a ; at the end of it.
Reply
#3

Oh yeah, didn't see that, thanks Prawk!
Reply
#4

pawn Код:
dcmd_unban(playerid, params[]) // Level 1
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new target, user[128], string[128];
if(sscanf(params, "s", target)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", target);
    if(INI_Exists(user))
    {
        new INI:File = INI_Open(user);
        INI_SetTag(user,"Main");
        INI_WriteInt(user, "Banned", 0);
        format(string, sizeof(string), "None");
        strmid(PlayerInfo[target][pBanReason], string, 0, strlen(string), 255);
        INI_WriteString(user, "BanReason", PlayerInfo[target][pBanReason]);
for(new i = 0; i < MAX_PLAYERS; i++)
        foreach(Player, i);
        {
            if(PlayerInfo[i][pAdmin] >= 1)
            {
                format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), target);
                SendClientMessage(i, COLOR_LIGHTRED, string);
                return 1;
            }
        }
        INI_Close(target);
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
        return 1;
    }
    return 1;
}
try
Reply
#5

Thanks Venice but I already fixed it, I had "user" instead of "File" xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)