AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Unban without message ? (https://forums.alliedmods.net/showthread.php?t=331722)

StrikerM 04-04-2021 09:25

Unban without message ?
 
Hello.

I created a ban system that unbans players after theyr time has past, everything is in database mysql.

But the only problem that i have is if in structure Player 1 is id 1 in db and has 5 minutes left and Player 2 is id 2 in db and has 1 minute left if his time will past the server wont give the message about Player 2 that got unbanned because he is id 2 in db and not 1, but when Player 1 is getting unbanned the server will give a message about him that got unbanned, and if i put them both in the same time to get unban server will show only 1 player got unbanned but in db they both got unbanned.

Bad english sorry, this is my script, don't judge me about the code, help if you can, thanks.

Code:

public UnbanSystem()
{
        new string[25];
        format(string, charsmax(string), "SELECT * FROM `bans`"), SQL_ThreadQuery(Handler, "UnbanContinue", string);
        return PLUGIN_HANDLED;
}
public UnbanContinue(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
        if(SQL_NumResults(Query) > 0)
        {
                new pName[32], UnbanTime[32];
                for(new i; i < 10; i++)
                {
                        SQL_ReadResult(Query, 1, pName[i], 32), UnbanTime[i] = SQL_ReadResult(Query, 5);

                        new string[55];
                        format(string, charsmax(string), "DELETE FROM `bans` WHERE `UnbanTime` = '0'"), SQL_ThreadQuery(Handler, "IgnoreHandle", string);
                        if(UnbanTime[i] == 0)
                        {
                                SCM(0, GREEN, "%s %s got unbanned.", TAG, pName[i]);
                                return PLUGIN_HANDLED;
                        }
                }
        }
        return PLUGIN_HANDLED;
}


jimaway 04-04-2021 10:21

Re: Unban without message ?
 
remove the return line from the for loop

StrikerM 04-04-2021 10:39

Re: Unban without message ?
 
Quote:

Originally Posted by jimaway (Post 2742969)
remove the return line from the for loop

Still the same.

jimaway 04-04-2021 10:54

Re: Unban without message ?
 
what did you test it with? the code you posted wont probably even compile

StrikerM 04-04-2021 11:21

Re: Unban without message ?
 
Quote:

Originally Posted by jimaway (Post 2742973)
what did you test it with? the code you posted wont probably even compile

it is compiling.

i am using this function to ban fake ppl.

Code:

public test(id)
{
        new string[360];
        format(string, charsmax(string), "INSERT INTO `bans` (`PlayerName`, `SteamID`, `UnbanTime`) VALUES ('Batman1', 'STEAMID:0:111', '3')"),
        SQL_ThreadQuery(Handler, "IgnoreHandle", string);
        format(string, charsmax(string), "INSERT INTO `bans` (`PlayerName`, `SteamID`, `UnbanTime`) VALUES ('Batman2', 'STEAMID:0:222', '2')"),
        SQL_ThreadQuery(Handler, "IgnoreHandle", string);
        format(string, charsmax(string), "INSERT INTO `bans` (`PlayerName`, `SteamID`, `UnbanTime`) VALUES ('Batman3', 'STEAMID:0:333', '3')"),
        SQL_ThreadQuery(Handler, "IgnoreHandle", string);
        format(string, charsmax(string), "INSERT INTO `bans` (`PlayerName`, `SteamID`, `UnbanTime`) VALUES ('Batman5', 'STEAMID:0:555', '1')"),
        SQL_ThreadQuery(Handler, "IgnoreHandle", string);
        format(string, charsmax(string), "INSERT INTO `bans` (`PlayerName`, `SteamID`, `UnbanTime`) VALUES ('Batman4', 'STEAMID:0:444', '525600')"),
        SQL_ThreadQuery(Handler, "IgnoreHandle", string);
        return PLUGIN_HANDLED;
}

and then they get unban in 1, 2, 3 minutes, is working but like i said, if player 3 is unbanned the mssage wont show up, will show only ASC.

jimaway 04-04-2021 11:33

Re: Unban without message ?
 
Code:
if(SQL_NumResults(Query) > 0)     {         new pName[32], UnbanTime[32];         for(new i; i < SQL_NumResults(Query); i++)         {             SQL_ReadResult(Query, 1, pName, charsmax(pName))             UnbanTime[i] = SQL_ReadResult(Query, 5);             if(UnbanTime[i] == 0)             {                 SCM(0, GREEN, "%s %s got unbanned.", TAG, pName);             }             SQL_NextRow(Query)         }         SQL_ThreadQuery(Handler, "IgnoreHandle", "DELETE FROM `bans` WHERE `UnbanTime` = '0'");     }     return PLUGIN_HANDLED;

StrikerM 04-04-2021 12:01

Re: Unban without message ?
 
Quote:

Originally Posted by jimaway (Post 2742980)
Code:
if(SQL_NumResults(Query) > 0)     {         new pName[32], UnbanTime[32];         for(new i; i < SQL_NumResults(Query); i++)         {             SQL_ReadResult(Query, 1, pName, charsmax(pName))             UnbanTime[i] = SQL_ReadResult(Query, 5);             if(UnbanTime[i] == 0)             {                 SCM(0, GREEN, "%s %s got unbanned.", TAG, pName);             }         }         SQL_ThreadQuery(Handler, "IgnoreHandle", "DELETE FROM `bans` WHERE `UnbanTime` = '0'");     }     return PLUGIN_HANDLED;

It's the same, i have in my database first column ID being PRIMARY_KEY as AUTO_INCREMENT, maybe is from over there ?

I tested without ID without primary_key and auto_incr but still nothing, it's the same problem.

jimaway 04-04-2021 12:56

Re: Unban without message ?
 
add SQL_NextRow to the for loop. i edited my last post

StrikerM 04-04-2021 13:37

Re: Unban without message ?
 
Quote:

Originally Posted by jimaway (Post 2742989)
add SQL_NextRow to the for loop. i edited my last post

Everything works fine, you are amazing thanks.

Now i got a new problem creating the unban cmd, if i try to unban any steam id if the data base is cleared it say's 'that steamid dosen't exist in our data base' but if i want to unban a wrong steamid when i have a player banned it unbans that guy, lol.

Code:

public cmd_unban(id)
{
        new TargetSteamID[25];
        read_argv(1, TargetSteamID, sizeof(TargetSteamID)-1);

        Data[0] = id;
        new string[25];
        format(string, charsmax(string), "SELECT * FROM `bans` WHERE `SteamID` = '%s'", TargetSteamID), SQL_ThreadQuery(Handler, "UnbanCMD", string, Data, 3);
        return PLUGIN_HANDLED;
}

public UnbanCMD(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
        new pName[32], SteamID[25], sqlid, id = Data[0];
        if(SQL_NumResults(Query) > 0)
        {
                sqlid = SQL_ReadResult(Query, 0), SQL_ReadResult(Query, 1, pName[id], 32), SQL_ReadResult(Query, 3, SteamID[id], 24);
                SCM(0, GREEN, "%s You unbaned %s - SQLID: %d - Steamid: %s.", TAG, pName[id], sqlid, SteamID[id]);

                new string[55];
                format(string, charsmax(string), "DELETE FROM `bans` WHERE `SteamID` = '%s' AND `ID` = '%d'", SteamID[id], sqlid), SQL_ThreadQuery(Handler, "IgnoreHandle", string);
        }
        else SCM(0, GREEN, "%s That steamid dosen't exist in our data base.", TAG);
        return PLUGIN_HANDLED;
}


Napoleon_be 04-04-2021 14:04

Re: Unban without message ?
 
I"m not familiar with sql, but this just looks like u gotta check if the steam id is valid and if it matches with the one in the database. Make sure you format everything the same way as you do in your database.


All times are GMT -4. The time now is 03:09.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.