CMD To Ban someone that isn't connected.
#1

Is it possible to ban a player that isn't connected?
If so can you tell me how using strcmp


++Rep if you do
Reply
#2

To manage to do that, you have to use file functions. It's almost like registering a player.
Reply
#3

You can make something that opens the user's file and writes in for example "Banned = 1" and then under OnPlayerConnect you check if "Banned = 1" if that is true you ban the player.
Reply
#4

I see. Thanks
Reply
#5

PHP код:
if(strcmp(cmd,"/oban",true)==0)
{
    new 
string[124],string1[124], giveplayerid;
    
tmp strtok(cmdtext,idx);
    if(!
strlen(tmp))
    {   
         
SendClientMessage(playerid, -1"/oban [playername]");
    }
    
format(string,sizeof(string),"Users/%s.ini",params);
    if(
fexist(string))
    {
        new 
INI:file INI_Open(string);
        
INI_WriteInt(file,"Banned",1);
        
INI_Close(file);
        
format(string1,sizeof(string1),"AdmCmd: %s was banned when he isn't in game by %s.",GetPlayerName(giveplayerid), GetPlayerName(playerid));
        
SendClientMessage(playerid,-1,string1);
    }
    else 
SendClientMessage(playerid,-1,"Account not found");
    return 
1;

Reply
#6

Quote:
Originally Posted by RenSoprano
Посмотреть сообщение
PHP код:
if(strcmp(cmd,"/oban",true)==0)
{
    new 
string[124],string1[124];
    
tmp strtok(cmdtext,idx);
    if(!
strlen(tmp))
    {   
         
SendClientMessage(playerid, -1"/oban [playername]");
    }
    
format(string,sizeof(string),"Users/%s.ini",params);
    if(
fexist(string))
    {
        new 
INI:file INI_Open(string);
        
INI_WriteInt(file,"Banned",1);
        
INI_Close(file);
        
format(string1,sizeof(string1),"You have banned %s.",params);
        
SendClientMessage(playerid,-1,string1);
    }
    else 
SendClientMessage(playerid,-1,"Account not found");
    return 
1;

It depends on what file include/plugin he is using.
Reply
#7

If he use mysql or dini I will edit it
Reply
#8

I'll give you a short code of my made script, in this case, I'm using both dini as a file reader, and dcmd and a command processor.

pawn Код:
dcmd_oban(playerid, params[])
{
    new accountname[MAX_PLAYER_NAME], reason[256], string[256], string2[256];
    if(sscanf( params, "sds", accountname, reason))
    {
        if(PlayerInfo[playerid][pAdminLevel] >= 2)
        {
            SendClientMessage( playerid, COLOR_WHITE, "{00E6E6}* Correct Usage: {FFFFFF}/oban [account name - case sensative] [reason]");
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "[ERROR] You are not authorized to use this command.");
        }
    }
    else
    {
        if(PlayerInfo[playerid][pAdminLevel] >= 2)
        {
            format(string, sizeof(string), "accounts/%s.ini", accountname);
            if(dini_Exists(string))
            {
                new tmp[MAX_PLAYER_NAME];
                format(tmp, sizeof(tmp), "%s", PlayerName(playerid));
                if(strcmp(accountname, tmp, true) != -1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] You cannot offline-ban yourself.");
                }
                else if(dini_Int(string, "AdminLevel") > PlayerInfo[playerid][pAdminLevel])
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] You cannot offline-ban higher-level administrators.");
                }
                else if(dini_Int(string, "Banned") == 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] That player account is already banned.");
                }
                else if(strlen(reason) > 128)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] Ban reason should not exceed 128 characters in length.");
                }
                else
                {
                    dini_IntSet(string, "Banned", 1);
                    dini_Set(string, "BanReason", reason);
                    dini_Set(string, "BannedBy", PlayerName(playerid));
                    format(string, sizeof(string2), "AdmCmd: %s has been offline-banned by %s, reason: %s", accountname, PlayerName(playerid), reason);
                    SendClientMessageToAll(COLOR_LIGHTRED, string2);
                    Log("logs/bans.log", string2);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "[ERROR] That player account does not exist.");
            }
        }
    }
    return 1;
}
As this isn't the right place to explain, sort the things you need and the things you don't need out. Otherwise, hit me up with a PM and I'll help you.
Reply
#9

Here is an example (taken from my script)

PHP код:
CMD:banofflineplayer(playerid,params[])
{
    new 
string[90],tname[200];
    if(
sscanf(params"s[200]"tname)) return SendClientMessage(playerid,Yellow,"Correct Usage: /banofflineplayer [Player Name]");
    new 
filestring[128];
    
format(filestringsizeof(filestring), "/Users/%s.ini"tname);
     if(!
fexist(filestring)) return SendClientMessage(playerid,Lime"That name doesn't exist");
    else
    {
          new 
INI:File INI_Open(filestring);
        
INI_SetTag(File"data");
        
INI_WriteInt(File"Banned",1);
        
INI_Close(File);
        
format(stringsizeof(string),"Success! You have banned %s"tname);
        
SendClientMessage(playeridLime,string);
    }
    return 
1;

Using YINI + ZCMD.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)