Ban Offline Account.
#1

So, I'm working on a command here, that bans a player if they're offline, basically checks for their account and then sets their Banned variable to 1. But, unfortunately, doesn't work. Crashes my server.

Here's the code.

pawn Код:
command(banname,playerid,params[])
{
    if(Stats[playerid][AdminLevel] >= 5) {
        new name, namestring[MAX_PLAYER_NAME], string[128], sendername[MAX_PLAYER_NAME];
        if(unformat(params,"s[MAX_PLAYER_NAME]",name)) return SendClientMessage(playerid, COLOR_WHITE,"{777777}[SYNTAX]{FFFFFF} /BanName [Player Name]");
        format(namestring, sizeof(namestring), "/Users2/%s.ini", name);
        if(dini_Exists(namestring)) {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "{00FF00}[SERVER]{FFFFFF} Admin %s has banned the account named %s.", sendername, namestring);
            SendClientMessageToAll(COLOR_WHITE, string);
            dini_IntSet(namestring, "Banned", 1);
        } else {
            format(string, sizeof(string), "{FF0000}[ERROR]{FFFFFF} %s is not a registered account.", namestring);
            SendClientMessage(playerid, COLOR_WHITE, string);
        }
    } else {
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[ERROR]{FFFFFF} You can't use this command, stop trying to be cool.");
    }
    return 1;
}
Sorry if it's messy, just how I script lol.
Reply
#2

pawn Код:
command(banname,playerid,params[])
{
    if(Stats[playerid][AdminLevel] >= 5) {
        new name[MAX_PLAYER_NAME], namestring[45], string[128], sendername[MAX_PLAYER_NAME];
        if(unformat(params,"s[MAX_PLAYER_NAME]",name)) return SendClientMessage(playerid, COLOR_WHITE,"{777777}[SYNTAX]{FFFFFF} /BanName [Player Name]");
        format(namestring, sizeof(namestring), "/Users2/%s.ini", name);
        if(dini_Exists(namestring)) {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "{00FF00}[SERVER]{FFFFFF} Admin %s has banned the account named %s.", sendername, namestring);
            SendClientMessageToAll(COLOR_WHITE, string);
            dini_IntSet(namestring, "Banned", 1);
        } else {
            format(string, sizeof(string), "{FF0000}[ERROR]{FFFFFF} %s is not a registered account.", namestring);
            SendClientMessage(playerid, COLOR_WHITE, string);
        }
    } else {
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[ERROR]{FFFFFF} You can't use this command, stop trying to be cool.");
    }
    return 1;
}
Try this. Changed two things. You were using the variable name as a string, when it was an integer. I then changed the fact the namestring, of which was the location of it, had MAX_PLAYER_NAME, which is only 24 characters. So if someone were to have about 10 characters, it would cut off part of his name because it passed the limit.

Hope I helped.
Reply
#3

Can you change this to dcmd?? its very useful to some ban evader.
Reply
#4

Код:
new name[MAX_PLAYER_NAME],namestring[MAX_PLAYER_NAME+30];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)