Advanced Player Ban
#1

For whatever reason, this just doesn't work, it doesn't send any of the messages, nor updates the SQL database.

pawn Код:
BanPlayer(playerid, reason[], adminid)
{
    new String[500], PlayerName[MAX_PLAYER_NAME], AdminName[MAX_PLAYER_NAME], IP[32], Date[3], Time[3];
    getdate(Date[0], Date[1], Date[2]);
    gettime(Time[0], Time[1], Time[2]);
   
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    GetPlayerIp(playerid, IP, 32);
    GetPlayerName(adminid, AdminName, MAX_PLAYER_NAME);
    if(adminid == -1) { AdminName = "Server"; }
    format(String, sizeof(String), "AdmCmd: %s Has been banned by %s. Reason: %s", PlayerName, AdminName, reason);
    SendClientMessageToAll(COLOR_RED, String);
    SendClientMessage(playerid, COLOR_AAC, "You have been banned from the server.");
    SendClientMessage(playerid, COLOR_RED, "If you feel this ban is unfair, please Screen Shot the below information.");
    format(String, sizeof(String), "BanInfo: Date: %d:%d:%d || Time: %d:%d || Admin Name: %s || Reason: %s", Date[0], Date[1], Date[2], Time[0], Time[1], AdminName, reason);
    SendClientMessage(playerid, COLOR_RED, String);
    format(String, sizeof(String), "BanInfo: IP: %s || Player Name : %s || Admin Name: %s || Reason: %s", IP, PlayerName, AdminName, reason);
    Log("Logs/BanInfo.log", String);
    format(String, sizeof(String), "INSERT INTO `BanInfo`(Username, IPAddress, Reason, AdminName) VALUES (%s, %s, %s, %s)", DB_Escape(PlayerName), IP, reason, DB_Escape(AdminName));
    db_query(Database, String);
    Kick(playerid);
}
The only thing that works is kicking and logging.

Thanks.
Reply
#2

Use a timer to send that messages.

http://forum.sa-mp.com/showpost.php?...70&postcount=9
Reply
#3

Quote:
Originally Posted by Edvin
Посмотреть сообщение
And to debug the MySQL query issues, you may use:

pawn Код:
public OnGameModeInit( )
{
    mysql_debug( 1 ); // makes a file in root of the server about the queries and all mysql functions

// other stuff

    return 1;
}
After doing that please open the file Debug.txt and let us know where the query is being stopped.

Regards FalconX
Reply
#4

Sorry mate, I'm using SQLite not Mysql. Is there anything similar for SQLite?
Reply
#5

Quote:
Originally Posted by MikeLovesToHelp
Посмотреть сообщение
Sorry mate, I'm using SQLite not Mysql. Is there anything similar for SQLite?
I thought that Kick( playerid ); function maybe it's called first of the messages can send and also faster than SQLite can write into the database.

Try this:
Код:
BanPlayer(playerid, reason[], adminid)
{
    new String[500], PlayerName[MAX_PLAYER_NAME], AdminName[MAX_PLAYER_NAME], IP[32], Date[3], Time[3];
    getdate(Date[0], Date[1], Date[2]);
    gettime(Time[0], Time[1], Time[2]);
    
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    GetPlayerIp(playerid, IP, 32);
    GetPlayerName(adminid, AdminName, MAX_PLAYER_NAME);
    if(adminid == -1) { AdminName = "Server"; }
    format(String, sizeof(String), "AdmCmd: %s Has been banned by %s. Reason: %s", PlayerName, AdminName, reason);
    SendClientMessageToAll(COLOR_RED, String);
    SendClientMessage(playerid, COLOR_AAC, "You have been banned from the server.");
    SendClientMessage(playerid, COLOR_RED, "If you feel this ban is unfair, please Screen Shot the below information.");
    format(String, sizeof(String), "BanInfo: Date: %d:%d:%d || Time: %d:%d || Admin Name: %s || Reason: %s", Date[0], Date[1], Date[2], Time[0], Time[1], AdminName, reason);
    SendClientMessage(playerid, COLOR_RED, String);
    format(String, sizeof(String), "BanInfo: IP: %s || Player Name : %s || Admin Name: %s || Reason: %s", IP, PlayerName, AdminName, reason);
    Log("Logs/BanInfo.log", String);
    format(String, sizeof(String), "INSERT INTO `BanInfo`(Username, IPAddress, Reason, AdminName) VALUES ('%s', '%s', '%s', '%s')", DB_Escape(PlayerName), IP, reason, DB_Escape(AdminName));
    db_query(Database, String);
    SetTimerEx( "KickPlayer", 1000, 0, "i", playerid );
}

forward KickPlayer( playerid );
public KickPlayer( playerid )
    return Kick( playerid );
This should work.
Reply
#6

Alright, however I have a crash issue right now, I'm not sure what's causing it. Would you mind helping me on that?
Reply
#7

Quote:
Originally Posted by MikeLovesToHelp
Посмотреть сообщение
Alright, however I have a crash issue right now, I'm not sure what's causing it. Would you mind helping me on that?
Sure, but first of all, use Crashdetect to see what kind of errors do you receive.
Reply
#8

I've done that, all I receive is:
Код:
 [11:58:57] [debug] Server crashed while executing DM_Server.amx
[11:58:57] [debug] AMX backtrace:
[11:58:57] [debug] #0 native fwrite () [00405710] from samp-server.exe
[11:58:57] [debug] #1 00008798 in ?? () from DM_Server.amx
[11:58:57] [debug] #2 00009bfc in ?? () from DM_Server.amx
[11:58:57] [debug] #3 0000d93c in public UpdatePlayerEx () from DM_Server.amx
[11:58:57] [debug] Native backtrace:
[11:58:57] [debug] #0 77397ae2 in ?? () from C:\Windows\system32\ntdll.dll
[11:58:57] [debug] #1 00492860 in ?? () from C:\Users\Mike\Desktop\Scripting\DM Server\samp-server.exe
[11:58:57] [debug] #2 0040534e in ?? () from C:\Users\Mike\Desktop\Scripting\DM Server\samp-server.exe
Reply
#9

Quote:
Originally Posted by MikeLovesToHelp
Посмотреть сообщение
I've done that, all I receive is:
Код:
 [11:58:57] [debug] Server crashed while executing DM_Server.amx
[11:58:57] [debug] AMX backtrace:
[11:58:57] [debug] #0 native fwrite () [00405710] from samp-server.exe
[11:58:57] [debug] #1 00008798 in ?? () from DM_Server.amx
[11:58:57] [debug] #2 00009bfc in ?? () from DM_Server.amx
[11:58:57] [debug] #3 0000d93c in public UpdatePlayerEx () from DM_Server.amx
[11:58:57] [debug] Native backtrace:
[11:58:57] [debug] #0 77397ae2 in ?? () from C:\Windows\system32\ntdll.dll
[11:58:57] [debug] #1 00492860 in ?? () from C:\Users\Mike\Desktop\Scripting\DM Server\samp-server.exe
[11:58:57] [debug] #2 0040534e in ?? () from C:\Users\Mike\Desktop\Scripting\DM Server\samp-server.exe
To show the error lines, just create a "pawn.cfg" file in yourserver/pawno and compile & run server after.
EDIT:
I forgot to write, that you need to type "-d3 -r" in "pawn.cfg" and after to compile the gamemode.


Btw, it seems to be a problem with UpdatePlayerEx function, also post it, to see what problem it have.
Reply
#10

Nothing shows up in pawn.cfg and the UpdatePlayerEx is only UpdatePlayer which is:

pawn Код:
UpdatePlayer(playerid)
{
    // AntiCheat
    if(!JustRegistered[playerid])
    {
        new RealMoney = GetPlayerCash(playerid), String[128], PlayerName[MAX_PLAYER_NAME];
        if(GetPlayerMoney(playerid) != RealMoney)
        {
            ResetPlayerMoney(playerid);
            GivePlayerCash(playerid, RealMoney);
            GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
            format(String, sizeof(String), "AdmWarning: %s Is possibly hacking money - Cash Reset.", PlayerName);
            SendClientMessageToAdmins(COLOR_AAC, String);
            PlayerHacking[playerid]++;
            Log("Log/DebugLog.log", "Player hacking Money");
        }
        new Float: Health, Float: Armour;
        GetPlayerHealth(playerid, Health);
        GetPlayerArmour(playerid, Armour);
        if(Health == 100)
        {
            if(PlayerInfo[playerid][pAdminLevel] == 0)
            {
                SetPlayerHealth(playerid, 99.0);
                format(String, sizeof(String), "AdmWarning: %s Is possibly hacking health - Health Reset.", ReturnPlayerName(playerid));
                SendClientMessageToAdmins(COLOR_AAC, String);
                PlayerHacking[playerid]++;
                Log("Log/DebugLog.log", "Player hacking Health.");
            }
        }
        if(Armour == 100)
        {
            if(PlayerInfo[playerid][pAdminLevel] == 0)
            {
                SetPlayerArmour(playerid, 99.0);
                format(String, sizeof(String), "AdmWarning: %s Is possibly hacking armour - Armour Reset.", ReturnPlayerName(playerid));
                SendClientMessageToAdmins(COLOR_AAC, String);
                PlayerHacking[playerid]++;
                Log("Log/DebugLog.log", "Player hacking Armour.");
            }
        }
        if(PlayerHacking[playerid] == 3)
        {
            SetPlayerHealth(playerid, 0.0);
            SetPlayerArmour(playerid, 0.0);
            ResetPlayerCash(playerid);
            ResetPlayerWeapons(playerid);
            BanPlayer(playerid, "General Cheats.", -1);
            Log("Log/DebugLog.log", "Player Had Three Warnings");
        }
        if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK && PlayerInfo[playerid][pAdminLevel] <= 2)
        {
            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE); // Reset the player.
            format(String, sizeof(String), "AdmWarning: %s Is possibly jetpack hacking - Jetpack Reset.", PlayerName);
            SendClientMessageToAdmins(COLOR_AAC, String);
            PlayerHacking[playerid] ++;
            PlayerUsingJetpack[playerid] = true;
        }
        if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN && PlayerInfo[playerid][pAdminLevel] == 0)
        {
            BanPlayer(playerid, "General Cheats.", -1);
            Log("Log/DebugLog.log", "Minigun Ban");
        }

        SetPlayerScore(playerid, PlayerInfo[playerid][pKills] - PlayerInfo[playerid][pDeaths]);
        OnPlayerSave(playerid);
        OnPlayerPingUpdate(playerid);

        PlayerSeconds[playerid]++;
        if(PlayerSeconds[playerid] == 60)
        {
            PlayerMinutes[playerid]++;
            PlayerSeconds[playerid] = 0;
        }
        if(PlayerMinutes[playerid] == 60)
        {
            PlayerHours[playerid]++;
            PlayerSeconds[playerid] = 0;
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)