Unban command with DCMD and y_ini file system.
#4

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
So I had a problem before but then got it solved but now there's a completely different problem. The command now executes, and before I posted this I done a debug and the problem is that it replies "SERVER: Unknown command" but the debug says that it did what it was meant to (Open the players file, set the banned to 0 and the banreason to None and then close the file), but it doesn't do that, except the debug says it did. Here's the code:

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 user[128], string[128];
if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", user);
if(INI_Exists(user))
    {
        new INI:File = INI_Open(user);
        printf(user);
        printf("User file opened");
        INI_SetTag(File,"Main");
        INI_WriteInt(File, "Banned", 0);
        printf("User file unbanned");
        format(string, sizeof(string), "None");
        INI_WriteString(File, "BanReason", string);
        printf("Banned reason changed");
        INI_Close(File);
        printf("File closed");
        foreach(Player ,i)
        {
            if(PlayerInfo[i][pAdmin] >= 1)
            {
                format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user);
                SendClientMessage(i, COLOR_LIGHTRED, string);
            }
        }
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
        return 1;
    }
return 1;
}
Quote:
Originally Posted by Delux13
Посмотреть сообщение
Try this:
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 user[128], string[128];
if(sscanf(params, "s[128]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", user);
if(INI_Exists(user))
    {
        new INI:File = INI_Open(user);
        printf(user);
        printf("User file opened");
        INI_SetTag(File,"Main");
        INI_WriteInt(File, "Banned", 0);
        printf("User file unbanned");
        format(string, sizeof(string), "None");
        INI_WriteString(File, "BanReason", string);
        printf("Banned reason changed");
        INI_Close(File);
        printf("File closed");
        format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
    }
    return 1;
}
He wants to send the message to all admins!
Not just everyone.
So try this
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 user[128], string[128],PlayerName[24];
if(sscanf(params, "s[128]", PlayerName)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /unban [Full Player Name]");
format(user, sizeof(user), "%s.ini", PlayerName);
if(INI_Exists(user))
    {
        new INI:File = INI_Open(user);
        printf(user);
        printf("User file opened");
        INI_SetTag(File,"Main");
        INI_WriteInt(File, "Banned", 0);
        printf("User file unbanned");
        format(string, sizeof(string), "None");
        INI_WriteString(File, "BanReason", string);
        printf("Banned reason changed");
        INI_Close(File);
        printf("File closed");
        foreach(Player ,i)
        {
            if(PlayerInfo[i][pAdmin] >= 1)
            {
                format(string, sizeof(string), "Admin %s has unbanned the account '%s'", PlayerName(playerid), user);
                SendClientMessage(i, COLOR_LIGHTRED, string);
            }
        }
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "User not found!");
        return 1;
    }
return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)