Offline Ban
#1

Hello again
i wanna make my ban command to offline ban which ban offline player

also cant ban other admin blah blah

my ban cmd

PHP код:
CMD:ban(playerid,params[]) {
    if(
PlayerInfo[playerid][LoggedIn] == 1) {
        if(
PlayerInfo[playerid][Level] >= 4) {
            new 
tmp[128], tmp2[128], Index;        tmp strtok(params,Index), tmp2 strtok(params,Index);
            if(
isnull(params)) return SendClientMessage(playeridred"USAGE: /ban [playerid] [reason]");
            if(
isnull(tmp2)) return SendClientMessage(playeridred"ERROR: You must give a reason");
            new 
player1playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
            
player1 strval(tmp);
             if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (PlayerInfo[player1][Level] != ServerInfo[MaxAdminLevel]) ) {
                
GetPlayerName(player1playernamesizeof(playername)); GetPlayerName(playeridadminnamesizeof(adminname));
                new 
year,month,day,hour,minuite,secondgetdate(yearmonthday); gettime(hour,minuite,second);
                
CMDMessageToAdmins(playerid,"BAN");
                
format(string,sizeof(string),"%s has been banned by Administrator %s [Reason: %s] [Date: %d/%d/%d] [Time: %d:%d]",playername,adminname,params[2],day,month,year,hour,minuite);
                
SendClientMessageToAll(grey,string);
                
SaveToFile("BanLog",string);
                
aresetpall(player1);
                print(string);
                if(
udb_Exists(PlayerName2(player1)) && PlayerInfo[player1][LoggedIn] == 1dUserSetINT(PlayerName2(player1)).("banned",1);
                
format(string,sizeof(string),"banned by Administrator %s. Reason: %s"adminnameparams[2] );
                return 
BanEx(player1string);
            } else return 
SendClientMessage(playeridred"Player is not connected or is yourself or is the highest level admin");
        } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
    } else return 
SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");

Reply
#2

Awful indentation bro, I can't read shit from here. I suggest you to use y_ini first.
Reply
#3

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
Awful indentation bro, I can't read shit from here. I suggest you to use y_ini first.
why! doesn't dini work fine !
Reply
#4

bump . anyone
Reply
#5

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
Awful indentation bro, I can't read shit from here. I suggest you to use y_ini first.
He is true. Your intendation must be more clear for a better comprehension of you want help.
And can you tell me what is the problem here ? The command doesn't ban the player ?
Reply
#6

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
He is true. Your intendation must be more clear for a better comprehension of you want help.
And can you tell me what is the problem here ? The command doesn't ban the player ?
He wants it to ban them after they've left (aka 'offline'), which so far his command

1) only bans connected players
2) only bans connected players who are 'loggedin' to his account system

In order for this to be effective, he will have to set up his own ban list w/ IPs that runs concurrent to the official samp.ban. IPs for each player will need to be logged to their player file, and if someone does /offlineban it will HAVE to be by name. The system will then check the last recorded IP for that player, and then copy it to the secondary ban list.

This is the only way I can see it being done without it being easy to defeat. If the last recorded IP isnt used in a secondary ban list, he'll be banning by name....which you can get around by rejoining with a different name.

(not that changing your IP is rocket science, but you get my drift)
Reply
#7

Well, your command ain't gonna ban offline player because from what we all can see on it (and not too much tbh) you actually ban the certain playerid which already means the player is supposed to be online. Use the string sscanf parameter to get the nick and look for that through your files or database (wchich is actually more prefered).
Reply
#8

wait let me post my unban cmd it works but i wanna add reason and cant ban if player is admin
Reply
#9

I did a command who bans an offline player. I'm using zcmd - sscanf2 - YINI.
How does that work? I type the command /offban [Name] [Reason]
If the name of the player isn't REGISTERED on the 'database', an error message is returned.
If the player is already banned, an error message is returned to.
When a player is banned, a file is created with the date, name who banned the player and the reason.
If the player connects with this banned file, he will be kicked.
My English is bad as you can see, I hope you understood all what I wrote. xD

Checking if the player is ban.
PHP код:
    #OnPlayerConnect - Checking if the player is banned or not.
    
if(PlayerInfo[playerid][pBan] >= || fexist(UserPathB(playerid)))
    {
        new 
str[150], str2[120], str3[150], strBan[300];
        if(
PlayerInfo[playerid][pBan] == 0)
        {
            
PlayerInfo[playerid][pBan]++;
        }
        
INI_ParseFile(UserPathB(playerid), "LoadUserB_%s", .bExtra true, .extra playerid);
        
SendClientMessage(playeridred"[SYSTEM] Vous кtes banni du serveur.");
        
SendClientMessage(playeridred"[SYSTEM] Si vous pensez que c'est un erreur prenez un screenshoot [F8] et envoyй un message au fondateur "blancU"| James_Steven |");
        
format(strBansizeof(strBan),rougeUC" » Vous кtes banni.\n » Banni par "blancU"%s\t"rougeUC"» Raison : "blancU"%s\n "rougeUC"» Date : "blancU"%02i/%02i/%02i - %02ih%02im%02is"PlayerBanned[playerid][pAdmin], PlayerBanned[playerid][pRaison], PlayerBanned[playerid][pJour], PlayerBanned[playerid][pMois], PlayerBanned[playerid][pAnne], PlayerBanned[playerid][pHeure], PlayerBanned[playerid][pMinute], PlayerBanned[playerid][pSeconde]);
        
ShowPlayerDialog(playeridDIALOG_BANDIALOG_STYLE_MSGBOX"You are banned from this server"strBan"OK""");
        
format(strsizeof(str), rougeUC"[SYSTEM] » Date : "blancU"%02i/%02i/%02i "rougeUC"- "blancU"%02ih%02im%02is"PlayerBanned[playerid][pJour], PlayerBanned[playerid][pMois], PlayerBanned[playerid][pAnne], PlayerBanned[playerid][pHeure], PlayerBanned[playerid][pMinute], PlayerBanned[playerid][pSeconde]);
        
SendClientMessage(playeridredstr);
        
format(str3sizeof(str3), "[SYSTEM] Raison : "blancU"%s "rougeUF"- Admin qui vous a ban : "blancU"%s"PlayerBanned[playerid][pRaison], PlayerBanned[playerid][pAdmin]);
        
SendClientMessage(playeridredstr3);
        
format(str2sizeof(str2), "[SYSTEM] "blancU"%s "rougeUC"a tentй de se connecter (PERSONNE BANNI) - Autokick by System"name);
        
adminChat(str2red);
        
SetTimerEx("kick1"100false"i"playerid);
        return 
1;
    } 
/offban

PHP код:
#Ban an offline player
CMD:offban(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdminlvl] == && PlayerGod[playerid] == 2)
    {
        new 
raison[41], cible[MAX_PLAYER_NAME], string[MAX_PLAYER_NAME+200], aName[MAX_PLAYER_NAME], str[250], PathOff[50], PathBOff[50];
        if(
sscanf(params,"s[24]s[40]",cible,raison)) return SendClientMessage(playeridX11_LIGHT_BLUE_1"/offban [Name] [Raison]");
        
        
format(PathOffsizeof(PathOff), "/daday/Players/%s.ini"cible);
        if(!
fexist(PathOff)) return SendClientMessage(playeridred"[SYSTEM] "rougeUC"Impossible, joueur introuvable.");
        
format(PathBOffsizeof(PathBOff), "/daday/Ban/%s.ini"cible);
        if(
fexist(PathBOff)) return SendClientMessage(playeridred"[SYSTEM] "rougeUC"Ce joueur est dйjа ban.");
        
        
GetPlayerName(playerid,aName,sizeof(aName));
        
format(stringsizeof(string), rougeUF"[SYSTEM] "blancU"%s"rougeUC" a йtй banni offline par un administrateur. (Raison : "blancU"%s"rougeUC")"cibleraison);
        
SendClientMessageToAll(redstring);
        print(
"OFFBAN | Message de ban envoyй to all");
        
printf("\n- [ADMIN] %s a BAN OFFLINE %s"aNamecible);
        new 
strA[200];
        
format(strAsizeof(strA), "[ADMIN] "blancU"%s "rougeUC"a banni un joueur dйconnectй : "blancU"%s"aNamecible);
        
adminChat(strAred);
        new 
jourmoisheureminutesecondeanne;
        new 
File:pos=fopen("LOG_AdminCmd.txt"io_append);
        
gettime(heureminuteseconde);
        
getdate(annemoisjour);
         
format(str,sizeof(str),"\r\n[ADMIN/BAN] %s OFFLINE BANNED %s [%02i/%02i/%02i] %02i:%02i:%02i : %s"aNameciblejourmoisanneheureminuteseconderaison);
        
fwrite(pos,str);
        
fclose(pos);
        new 
INI:File INI_Open(PathBOff);
        
INI_WriteInt(File,"Jour"jour);
        
INI_WriteInt(File,"Mois"mois);
        
INI_WriteInt(File,"Anne"anne);
        
INI_WriteInt(File,"Heure"heure);
        
INI_WriteInt(File,"Minute"minute);
        
INI_WriteInt(File,"Seconde",seconde);
        
INI_WriteString(File,"Raison",raison);
        
INI_WriteString(File,"Admin",aName);
        
INI_Close(File);
        return 
1;
    }
    else return 
SendClientMessage(playeridred"[SYSTEM]"rougeUC" Vous n'кtes pas autorisй а utiliser cette commande.");

There are some useless stuffs for you, like LogCmd but it's my offban command so I need it. The whole script isn't in English, apologies. If you need some translation, say it.

NB: There is NO OPTIMIZATION HERE. I mean, this code can be really better.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)