Raised This Month: $12 Target: $400
 3% 

Unban without message ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StrikerM
BANNED
Join Date: Nov 2019
Old 04-04-2021 , 09:25   Unban without message ?
Reply With Quote #1

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;
}

Last edited by StrikerM; 04-04-2021 at 09:31.
StrikerM is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-04-2021 , 10:21   Re: Unban without message ?
Reply With Quote #2

remove the return line from the for loop
jimaway is offline
StrikerM
BANNED
Join Date: Nov 2019
Old 04-04-2021 , 10:39   Re: Unban without message ?
Reply With Quote #3

Quote:
Originally Posted by jimaway View Post
remove the return line from the for loop
Still the same.
StrikerM is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-04-2021 , 10:54   Re: Unban without message ?
Reply With Quote #4

what did you test it with? the code you posted wont probably even compile
jimaway is offline
StrikerM
BANNED
Join Date: Nov 2019
Old 04-04-2021 , 11:21   Re: Unban without message ?
Reply With Quote #5

Quote:
Originally Posted by jimaway View Post
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.
StrikerM is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-04-2021 , 11:33   Re: Unban without message ?
Reply With Quote #6

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;

Last edited by jimaway; 04-04-2021 at 12:55.
jimaway is offline
StrikerM
BANNED
Join Date: Nov 2019
Old 04-04-2021 , 12:01   Re: Unban without message ?
Reply With Quote #7

Quote:
Originally Posted by jimaway View Post
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.
StrikerM is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-04-2021 , 12:56   Re: Unban without message ?
Reply With Quote #8

add SQL_NextRow to the for loop. i edited my last post
jimaway is offline
StrikerM
BANNED
Join Date: Nov 2019
Old 04-04-2021 , 13:37   Re: Unban without message ?
Reply With Quote #9

Quote:
Originally Posted by jimaway View Post
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;
}

Last edited by StrikerM; 04-04-2021 at 13:54.
StrikerM is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-04-2021 , 14:04   Re: Unban without message ?
Reply With Quote #10

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.
__________________

Last edited by Napoleon_be; 04-04-2021 at 14:05.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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