Ban Command
#1

Hello,

I'm trying to create admin script for my server, I tried to make ban command many times but I failed :/.
Could somebody Create Ban command for me =)
Command in zcommand

Thanks

Note : Sorry for my bad english ^^
Quote:

if(pInfo[playerid][Adminlevel] >= 1)

Edit : +repp for the helper
Reply
#2

Well, depends on the saving system. Give us more information like is the saving system MySQL or djson something like that
Reply
#3

First go to the script files and add text document named "BanLog"
And here is command:
pawn Код:
CMD:ban(playerid,params[]) {
    if(pInfo[playerid][LoggedIn] == 1) {
        if(pInfo[playerid][Adminlevel] >= 1) {
            new tmp[128], tmp2[128], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
            if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
            if(isnull(tmp2)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
            new player1, playername[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(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
                new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
                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);
                format(string,sizeof(string),"banned by Administrator %s. Reason: %s", adminname, params[2] );
                return BanEx(player1, string);
            } else return SendClientMessage(playerid, red, "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");
}
It works on my script, but if you get any errors message me or post back here..
Reply
#4

Quote:
Originally Posted by TonyNames
Посмотреть сообщение
Well, depends on the saving system. Give us more information like is the saving system MySQL or djson something like that
This is the tutorial i have followed : https://sampforum.blast.hk/showthread.php?tid=352703

Quote:
Originally Posted by LeroyII
Посмотреть сообщение
First go to the script files and add text document named "BanLog"
And here is command:
pawn Код:
CMD:ban(playerid,params[]) {
    if(pInfo[playerid][LoggedIn] == 1) {
        if(pInfo[playerid][Adminlevel] >= 1) {
            new tmp[128], tmp2[128], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
            if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
            if(isnull(tmp2)) return SendClientMessage(playerid, red, "ERROR: You must give a reason");
            new player1, playername[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(player1, playername, sizeof(playername)); GetPlayerName(playerid, adminname, sizeof(adminname));
                new year,month,day,hour,minuite,second; getdate(year, month, day); gettime(hour,minuite,second);
                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);
                format(string,sizeof(string),"banned by Administrator %s. Reason: %s", adminname, params[2] );
                return BanEx(player1, string);
            } else return SendClientMessage(playerid, red, "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");
}
It works on my script, but if you get any errors message me or post back here..
PHP код:
if(pInfo[playerid][LoggedIn] == 1
This won't work
Reply
#5

Atleast tell your enums so helpers can provide some help related to your script!
Reply
#6

Quote:
Originally Posted by Fred1993
Посмотреть сообщение
Atleast tell your enums so helpers can provide some help related to your script!
my enums
PHP код:
enum PlayerInfo
{
    
Pass[129],
    
Adminlevel,
    
Muted,
    
VIPLevel,
    
Money,
    
Scores,
    
Kills,
    
Deaths

Reply
#7

Quote:

enum PlayerInfo
{
Pass[129],
Adminlevel,
Muted,
VIPLevel,
Money,
Scores,
Kills,
ban,
Deaths
}
CMD:ban(playerid, params[]) {
new playa;
new reason[128],msg[128];
if (!sscanf(params, "ds[128]", playa, reason))
{
if(!IsPlayerConnect(playa)) {
SendClientMessage(playerid, -1 ,"User not found.");
return 1;
}
format(msg,sizeof(msg),"[AMSG] %s has been banned by %s: %s",GetPlayerName(playa),GetPlayerName(playerid),r eason);
// use your type of msg here, that you want to send
pInfo[playerid][ban] = 1; // this will add 1 in ban enum and you have to check this onplayerconnect
} else {
SendClientMessage(playerid, -1, "USAGE: /ban [playerid/name] [reason]");
}
return 1;
}

you need to edit things in your game mode if you want this code to work, there are many ways to ban a player but im telling you my way
Reply
#8

Quote:
Originally Posted by Frankin
Посмотреть сообщение
This is the tutorial i have followed : https://sampforum.blast.hk/showthread.php?tid=352703



PHP код:
if(pInfo[playerid][LoggedIn] == 1
This won't work
Then try to remove it!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)