[FilterScript] [MYSQL R41-2] Ban / Unban System
#1

Note

I would recommend to add the systems from this filterscript into your gamemode since it doesn't save accounts or load anything, only has commands & callbacks and fuctions.

Introduction

Ban / Unban system with the latest MySQL version.
Screenshots

I took 2 screenshots in-game, when the player uses /ban, /unban and when the player connects the dialog pops up telling him the ban information.



Commands

/ban - RCON Admins
/unban - RCON Admins
/baninfo - RCON Admins
/oban - RCON Admins
Version

This is the first version which is 0.1, i'll keep updating the filterscript by adding /oban(Already added), /tempban and /baninfo(Already added) (for admins only)
Bugs

Well, there was no bugs while i was testing this. I tested this in localhost with sandbox, so if you find any bug please let me know by PMs or by posting here, doesn't matter.
Credits

SA:MP Team for a_samp
maddinat0r - BlueG for a_mysql
Zeex - zcmd
Y_Less - sscanf2
Emmet - easyDialog
Download

And here comes the download:
Github
Pastebin
Reply
#2

Updated - added /baninfo command (admins will be able to check ban information if the player is banned)

Screenshot:
Reply
#3

Nice bro, would be also nice if you add commands like:

- /owarn (warn an offline player)
- /checkwarns (will check the amount of warns of an offline or online player)
- /removewarn (will remove a warn id of X player)

A suggestion:

- Be able to also unban a player by typing the ban ID
Reply
#4

Really Nice. BRO but I was looking for R41-4
Reply
#5

Great job!
Reply
#6

Quote:
Originally Posted by ZigGamerx
View Post
Really Nice. BRO but I was looking for R41-4
Oh wow lol! Didn't even notice R41-4 was released.. Will update it as soon as i get home
Reply
#7

Quote:
Originally Posted by ZJK
View Post
Nice bro, would be also nice if you add commands like:

- /owarn (warn an offline player)
- /checkwarns (will check the amount of warns of an offline or online player)
- /removewarn (will remove a warn id of X player)

A suggestion:

- Be able to also unban a player by typing the ban ID
Will create a new filterscript for the warn system, this is a ban system.

Quote:
Originally Posted by ZigGamerx
View Post
Really Nice. BRO but I was looking for R41-4
You can now use this on R41-4.
Reply
#8

- Updated to V0.2, added /oban. I can't really post screenshots now as i'm not on my PC but will post a screenshot later.
Reply
#9

You should include the CREATE database if not exists query. Btw good job.
Reply
#10

Quote:
Originally Posted by KinderClans
View Post
You should include the CREATE database if not exists query. Btw good job.
Ah yes, updated. Forgot about that.
Reply
#11

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
Reply
#12

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
Does it show you that error? Because it compiles fine for me...

EDIT: Try now, i've tried changing something but even before it was compiling fine.
Reply
#13

Quote:
Originally Posted by willbedie
Посмотреть сообщение
Does it show you that error? Because it compiles fine for me...

EDIT: Try now, i've tried changing something but even before it was compiling fine.
He means the table creation query. If you make a column auto_increment you must defined it as PRIMARY KEY or to add an index to it(in this case PRIMARY KEY will be perfect)
Reply
#14

Quote:
Originally Posted by Banditul18
Посмотреть сообщение
He means the table creation query. If you make a column auto_increment you must defined it as PRIMARY KEY or to add an index to it(in this case PRIMARY KEY will be perfect)
Now i get it, updated once again.
Reply
#15

Sorry to say but this script is just full of bugs and mistakes.

This check in offline ban command:

pawn Код:
if(!rows)
    {
        SCM(playerid, COLOR_RED, "* That name does not exist or there is no ban under that name.");
    }
Why? Why do you check if a name exists if im offline banning someone and not retrieving their ban info?

OnPlayerConnect check:

pawn Код:
mysql_format(g_SQL, query, sizeof(query), "SELECT * FROM `bans` WHERE (`Username`='%e')", ReturnPlayerName(playerid));
Must be:

pawn Код:
mysql_format(g_SQL, query, sizeof(query), "SELECT * FROM `bans` WHERE `Username` = '%e'", ReturnPlayerName(playerid));
The "else" in CheckPlayer is useless. As you said this is not an user system, so why i should place my login code there?

I tried placing in that else and bugged everything. So remove it and remain just:

pawn Код:
CheckPlayer(playerid)
{
    if(cache_num_rows() != 0)
    {
        new Username[24], BannedBy[24], BanReason[70];
        cache_get_value_name(0, "Username", Username);
        cache_get_value_name(0, "BannedBy", BannedBy);
        cache_get_value_name(0, "BanReason", BanReason);

        SendClientMessage(playerid, COLOR_RED, "* You are banned from this server.");
        new string[500];
        format(string, sizeof(string), "{FFFFFF}You are banned from this server\n{D93D3D}Username: {FFFFFF}%s\n{D93D3D}Banned by: {FFFFFF}%s\n{D93D3D}Ban Reason: {FFFFFF}%s", Username, BannedBy, BanReason);
        ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Ban Info", string, "Close", "");
        DelayedKick(playerid);
    }
    return 1;
}
Mysql query for creating "bans" table:

pawn Код:
Username` VARCHAR(70)
70 chars, seriously?

pawn Код:
BannedBy` VARCHAR(70) NOT NULL,
Same here.

pawn Код:
`BanReason` VARCHAR(70) NOT NULL
Must be at least 128.

pawn Код:
`IpAddress` VARCHAR(17)
If im not wrong, an IP is made by 24 chars, not 17.
Reply
#16

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Sorry to say but this script is just full of bugs and mistakes.
Quote:

OnPlayerConnect check:

pawn Код:
mysql_format(g_SQL, query, sizeof(query), "SELECT * FROM `bans` WHERE (`Username`='%e')", ReturnPlayerName(playerid));
Must be:

pawn Код:
mysql_format(g_SQL, query, sizeof(query), "SELECT * FROM `bans` WHERE `Username` = '%e'", ReturnPlayerName(playerid));
Updated

Quote:

The "else" in CheckPlayer is useless. As you said this is not an user system, so why i should place my login code there?

I tried placing in that else and bugged everything. So remove it and remain just:

pawn Код:
CheckPlayer(playerid)
{
    if(cache_num_rows() != 0)
    {
        new Username[24], BannedBy[24], BanReason[70];
        cache_get_value_name(0, "Username", Username);
        cache_get_value_name(0, "BannedBy", BannedBy);
        cache_get_value_name(0, "BanReason", BanReason);

        SendClientMessage(playerid, COLOR_RED, "* You are banned from this server.");
        new string[500];
        format(string, sizeof(string), "{FFFFFF}You are banned from this server\n{D93D3D}Username: {FFFFFF}%s\n{D93D3D}Banned by: {FFFFFF}%s\n{D93D3D}Ban Reason: {FFFFFF}%s", Username, BannedBy, BanReason);
        ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Ban Info", string, "Close", "");
        DelayedKick(playerid);
    }
    return 1;
}
That worked for me tho on my gamemode...

Quote:

Mysql query for creating "bans" table:

pawn Код:
Username` VARCHAR(70)
70 chars, seriously? It should be like 24 or something but that can't be called a bug, i've changed it.

pawn Код:
BannedBy` VARCHAR(70) NOT NULL,
Same here. // changed

pawn Код:
`BanReason` VARCHAR(70) NOT NULL
Must be at least 128.

pawn Код:
`IpAddress` VARCHAR(17)
If im not wrong, an IP is made by 24 chars, not 17.

Код:
If im not wrong, an IP is made by 24 chars, not 17.
Afaik, an IP is made by 16 or 17 characters.
Reply
#17

That's why i said "if im not wrong".
Reply
#18

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
That's why i said "if im not wrong".
I've fixed everything but i don't think anything is wrong with CheckPlayer since it worked for me, if someone else tries this please let me know if CheckPlayer works for you because it worked for me on my own gamemode.
Reply
#19

I suggest you to create mysql admin system. Use this system and add some other admin commands: warn, kick, jail, freeze etc...
Good Job anyway
Reply
#20

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
That's why i said "if im not wrong".
and that's why he corrected you.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)