Ban Name
#1

So I'm trying to get a script going that bans a person's account if they're offline. However, I do not know what to put for the name of the account to edit. Let me show you.

pawn Код:
command(banname,playerid,params[])
{
    if(Stats[playerid][AdminLevel] >= 5) {
        new name, namestring[24], string[128], sendername[MAX_PLAYER_NAME];
        if(unformat(params,"s[24]",name)) return SendClientMessage(playerid, COLOR_WHITE,"{777777}[SYNTAX]{FFFFFF} /BanName [Player Name]");
        format(namestring, sizeof(string), "%s", name);
        if(dini_Exists(namestring)) {
            Stats[namestring][Banned] = 1;
            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);
        } 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;
}
See, on the Stats[?][Banned] = 1;, I don't know what to put for the ?. Any help would be, well, helpful.
Reply
#2

Thats kind of useless, considering they have to be online to set a variable to someone.

Just make it so when you do that, it goes into there account and changes the current Banned variable in it to 1.

Quote:
Originally Posted by Mr_DjolE
Посмотреть сообщение
Yeah make Banned variable, and add something like this in onplayerconnect
pawn Код:
if (PlayerInfo[playerid][pBanned]>=1)
    {
        new string[254];
        format(string, sizeof(string), "You are currently banned for: %s", PlayerInfo[playerid][pBanReason]);
        Kick(playerid);
Why would you make one when he already has one? I'm saying, he should go into the players file and change the value of pBanned.
Reply
#3

Yeah make Banned variable, and add something like this in onplayerconnect
pawn Код:
if (PlayerInfo[playerid][pBanned]>=1)
    {
        new string[254];
        format(string, sizeof(string), "You are currently banned for: %s", PlayerInfo[playerid][pBanReason]);
        Kick(playerid);
Reply
#4

That's what I'm trying to do, make it to where if the account exists, set its banned account variable to 1. I don't see any other logical way of doing this with them being offline besides getting their IP address on their account and then RCON command sending banip.
Reply
#5

Quote:
Originally Posted by TyThaBomb
Посмотреть сообщение
That's what I'm trying to do, make it to where if the account exists, set its banned account variable to 1. I don't see any other logical way of doing this with them being offline besides getting their IP address on their account and then RCON command sending banip.
So you want ban command for offline players ?
Reply
#6

That's correct, basically, let's say Bob starts causing trouble, then when he sees an admin join, he /q's. I want the admin to be able to /banname Bob and then it goes into the account files, and sets Bobs Banned variable to 1, banning him.
Reply
#7

Try something like this:

pawn Код:
command(banname,playerid,params[])
{
    if(Stats[playerid][AdminLevel] >= 5) {
        new name, namestring[24], string[128], sendername[MAX_PLAYER_NAME];
        if(unformat(params,"s[24]",name)) return SendClientMessage(playerid, COLOR_WHITE,"{777777}[SYNTAX]{FFFFFF} /BanName [Player Name]");
        format(namestring, sizeof(string), "%s", 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, "pBanned", 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;
}
Change "pBanned" on dini_IntSet to the name of the variable that is in the file.

So if you load it like this:

pawn Код:
dini_Int(file, "PlayerBanned");
Your going to have to change pBanned to PlayerBanned, and so forth.

EDIT: Plus, why don't you have an extra folder for scriptfiles? You're just checking for the players name in scriptfiles. What if you want a business system or a vehicle saving system? It's not recommended to save them in the same spot or it will look bad and will be hard to find certain files.
Reply
#8

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Try something like this:

pawn Код:
command(banname,playerid,params[])
{
    if(Stats[playerid][AdminLevel] >= 5) {
        new name, namestring[24], string[128], sendername[MAX_PLAYER_NAME];
        if(unformat(params,"s[24]",name)) return SendClientMessage(playerid, COLOR_WHITE,"{777777}[SYNTAX]{FFFFFF} /BanName [Player Name]");
        format(namestring, sizeof(string), "%s", 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, "pBanned", 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;
}
Change "pBanned" on dini_IntSet to the name of the variable that is in the file.

So if you load it like this:

pawn Код:
dini_Int(file, "PlayerBanned");
Your going to have to change pBanned to PlayerBanned, and so forth.

EDIT: Plus, why don't you have an extra folder for scriptfiles? You're just checking for the players name in scriptfiles. What if you want a business system or a vehicle saving system? It's not recommended to save them in the same spot or it will look bad and will be hard to find certain files.
Exactly what I needed, I appreciate it, thanks for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)