Ban Checking
#1

Hello i made a /ban command which is this

pawn Код:
CMD:ban(playerid, params[])
{
    new string[128], id, msg[250], reason[30], ip[16], year, month, day, sec, hrs, mins, File:BanLog;
    if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
    if(pData[playerid][Admin] < 2) return SendClientMessage(playerid, COLOR_RED, "*** You are not Administrator ***");
    if(sscanf(params, "us[30]", id, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ban [playerid] [reason]");
    GetPlayerIp(id, ip, sizeof(ip));
    getdate(year, month, day);
    gettime(hrs, mins, sec);
    if(!strlen(reason)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Put a Reason don't leave the Reason Blank!");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
    format(string, sizeof(string), "%s(%d) has been banned by Administrator %s(%d) for %s", GetpName(id), id, GetpName(playerid), playerid, reason);
    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
    pData[id][Banned] = 1;
    dini_Set(DataPath(id), "Reason", reason);
    dini_Set(DataPath(id), "BanBy", GetpName(playerid));
    format(string, sizeof(string),"banip %s", ip[id]);
    SendRconCommand(string);
    SendRconCommand("reloadbans");
    BanLog = fopen("Clan/Log/BanLog.txt", io_append);
    format(msg, sizeof(msg), "[%02d/%02d/%02d | %02d/%02d/%02d] %s(%d) has been banned by Administrator %s(%d) for %s [IP: %s]", month, day, year, hrs, mins, sec, GetpName(id), id, GetpName(playerid), playerid, reason, ip);
    fwrite(BanLog, msg);
    fclose(BanLog);
    format(string, sizeof(string), "*** You banned %s(%d) for %s ***", GetpName(id), id, reason);
    SendClientMessage(playerid, COLOR_RED, string);
    SendClientMessage(playerid, COLOR_RED, "Note: "white"Your banning to the player will be save in BanLog in DataBase!");
    for(new i = 0; i < 100; i++)
    SendClientMessage(id, -1," ");
    format(string, sizeof(string), "*** You are banned by Administrator %s(%d) for %s ***", GetpName(playerid), playerid, reason);
    SendClientMessage(id, COLOR_RED, string);
    SendClientMessage(id, -1, " ");
    SendClientMessage(id, -1, "Goto "red"www.impactplayers.smf2hosting.com - Impact Player - Ban Appeal");
    SendClientMessage(id, -1, "And create your ban appeal, Don't try to ban evade or else");
    SendClientMessage(id, -1, "Your chance being unban will decrease to 50 percent!");
    SendClientMessage(id, -1, " ");
    SendClientMessage(id, COLOR_RED, "*** You are banned from [iP] clan SERVER ***");
    Kick(id);
    return 1;
}
Its working fine it ban me.
I add a ban checking which checks if player has Ban=1 in DataBase he will get this

pawn Код:
if(dini_Int(DataPath(playerid), "Ban") == 1)
{
    new string[128], banby[24], reason[92];
    for(new i = 0; i < 100; i++)
    SendClientMessage(playerid, -1, " ");
    SendClientMessage(playerid, COLOR_RED, "*** You are banned from [iP] clan SERVER ***");
    SendClientMessage(playerid, -1, " ");
    format(reason, 92, "%s", dini_Get(DataPath(playerid), "Reason"));
    format(banby, 24, "%s", dini_Get(DataPath(playerid), "BanBy"));
    format(string, sizeof(string), "You are banned by "white"%s | "red"Reason: "white"%s", banby, reason);
    SendClientMessage(playerid, COLOR_RED, string);
    Kick(playerid);
}
but instead i'm stuck in

Код:
Connecting to [iP] offical clan server
and here is what i got in server log

Код:
[19:52:15] Incoming connection: 192.168.1.100:2056
[19:52:15] [join] Romel has joined the server (0:192.168.1.100)
[19:52:20] [part] Romel has left the server (0:2) - Remember 0:2 means Kick/Ban
It is working fine in server console but the question is why the code i wrote is not showing?
it just kick me.

so thats why i move the Ban Checking in OnPlayerSpawn but this time after the kick it crash my game.

Any idea how to solve this i did all i can to solve it.

and one question how to check if my ip is banned from database

Example:

Код:
IP=192.168.1.100 (this is banned ip in /ban)
when he connects again he cannot pass the server
Reply
#2

pawn Код:
if(dini_Int(DataPath(playerid), "Ban") == 1)
{
    new string[128], banby[24], reason[92];
    for(new i = 0; i < 64; i++)
    {
        SendClientMessage(playerid, -1, " ");
        SendClientMessage(playerid, COLOR_RED, "*** You are banned from [iP] clan SERVER ***");
        SendClientMessage(playerid, -1, " ");
    }
    format(reason, 92, "%s", dini_Get(DataPath(playerid), "Reason"));
    format(banby, 24, "%s", dini_Get(DataPath(playerid), "BanBy"));
    format(string, sizeof(string), "You are banned by "white"%s | "red"Reason: "white"%s", banby, reason);
    SendClientMessage(playerid, COLOR_RED, string);
    Kick(playerid);
}
Reply
#3

Didn't work i move the code to OnPlayerConnect again now i'm stuck again in

Код:
Connecting to...
Reply
#4

Up Up
Reply
#5

You do realize kicking in OnPlayerConnect has been a reported bug for quite some time now.

Check this thread out maybe. That one's just the tip of the iceberg

https://sampforum.blast.hk/showthread.php?tid=323853
Reply
#6

i don't find any useful tips

i found one (Setting a timer) but it didn't work it just reconnects me after the timer call
Reply
#7

I don't see OnPlayerConnect as an option.

You said you used the ban check under OnPlayerSpawn, but your server crashed. Care to elaborate on that?
Reply
#8

Quote:
Originally Posted by Romel
Посмотреть сообщение
Didn't work i move the code to OnPlayerConnect again now i'm stuck again in

Код:
Connecting to...
didn't not notice this VincentDunn?
Reply
#9

I'm talking about OnPlayerSpawn.

That bug pertains to OnPlayerConnect afaik.
Reply
#10

OnPlayerConnect reconnect issue solve by setting settimerex to 7000ms.

now can someone tell me how to check if my ip is ban

Ex.

i use /ban 0 test to myself
it will create Bans.ini in /Log/

now i want to check if the ip is listed in /Log/Ban.ini he will get kicked

How to do that

i use the normal #include <file> to create Bans.ini
Reply


Forum Jump:


Users browsing this thread: