SQLITE is not Saving Bans *Help*
#1

Hi. i Own a Server Called _ Extreme Freeroam _ And when my admins go to ban ppl. the accounts dont save

Код:
CMD:ban(playerid, params[])
{
	LoginCheck(playerid);
	if(User[playerid][accountAdmin] >= 2)
	{
	    new
			string[150],
			id,
			reason[128],
			when[128],
			ban_hr, ban_min, ban_sec, ban_month, ban_days, ban_years
		;

		gettime(ban_hr, ban_min, ban_sec);
		getdate(ban_years, ban_month, ban_days);

	    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ban [playerid] [reason]");
		if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "» "red"Player not connected.");
		if(User[playerid][accountAdmin] < User[id][accountAdmin])
		{
			SendClientMessage(playerid, -1, "» "red"You cannot use this command on high ranking admin.");
			format(string, sizeof(string), "[NOTIFY] "white"%s has attempted to banned you with the reason %s.", GetName(playerid), reason);
			SendClientMessage(id, COLOR_ORANGE, string);
			
			format(string, sizeof(string), "%s has attempted to banned %s but failed for %s", GetName(playerid), GetName(id), reason);
			Log("admin.txt", string);
			return 1;
		}

		format(when, 128, "%02d/%02d/%d %02d:%02d:%02d", ban_month, ban_days, ban_years, ban_hr, ban_min, ban_sec);

	    format(sInfo[last_bperson], 256, "%s", GetName(id));
	    format(sInfo[last_bwho], 256, "%s", reason);
		savestatistics();
		AddBan(User[id][accountIP], 1);
		BanAcc(id, GetName(playerid), reason);
		ShowBan(id, GetName(playerid), reason, when);
		format(string, sizeof(string), ""red"%s %s has banned %s from the server! [Reason: %s]", alvl(playerid),GetName(playerid), GetName(id),reason);
		SendClientMessageToAll(-1, string);
		format(string, sizeof(string), "[BANNED] %s has been banned by %s for %s.", GetName(id), GetName(playerid), reason);
		Log("ban.txt", string);
		
		KickDelay(id);
	}
	else
	{
	    SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
	}
	return 1;
}
and i had this log from my admin banning said player

Код:
(02/13/2016 | 04:23:51) [BANNED] eFBloodyAlboz has been banned by eFL.K. for abuse admin power.
Screenshots:


But if the player Posts A Unban. when say me. the owner. or my managers (Level 6-7)

cmd:unban - The Player Account doesn't get added to the database automaticly
i have to go into the logs (Ban.cfg) Then Restart the Server...

How do i fix this for future. to prevent Loads of restarts?
Reply
#2

Where is your SQLite query? I cannot see anything releated to SQLite in this command.
Reply
#3

Quote:
Originally Posted by PawnHunter
Посмотреть сообщение
Where is your SQLite query? I cannot see anything releated to SQLite in this command.
Exactly same here...
Reply
#4

Код:
	format(bQuery, 600, "SELECT * FROM `bans` WHERE `username` = '%q'", GetName(playerid));
	jResult = db_query(Database, bQuery);

	if(db_num_rows(jResult))
	{
	    db_get_field_assoc(jResult, "banby", admin, 128);
	    db_get_field_assoc(jResult, "banreason", reason, 128);
	    db_get_field_assoc(jResult, "banwhen", when, 128);

		format(string, sizeof(string), "%s has connected to the server, Got kicked for being banned.", GetName(playerid));
		Log("finn.txt", string);

		AddBan(User[playerid][accountIP], 1);

		ShowBan(playerid, admin, reason, when);
		
		KickDelay(playerid);
	    return 1;
	}
that's sqlite query. do i need to add this to the ban command

its listed as unban already
Код:
format(Query, 129, "SELECT FROM `bans` WHERE `username` = '%q'", Account);
		Result = db_query(Database, Query);

		if(db_num_rows(Result))
		{
        	db_get_field_assoc(Result, "ip", fIP, 30);
			if(CheckBan(fIP))
			{
				RemoveBan(fIP);
			}
	        format(Query, 129, "DELETE FROM `bans` WHERE `username` = '%q'", Account);
		    Result = db_query(Database, Query);
	        db_free_result(Result);
Reply
#5

You need to make a query command that inserts the new ban into the SQLite db.

Just use normal sql syntax for that
Reply
#6

Код:
stock BanAcc(playerid, admin[], reason[])
{
	new
		Query[500],
		DBResult:result,
		ban_hr, ban_min, ban_sec, ban_month, ban_days, ban_years, when[128]
	;
	
	gettime(ban_hr, ban_min, ban_sec);
	getdate(ban_years, ban_month, ban_days);
	
	format(when, 128, "%02d/%02d/%d %02d:%02d:%02d", ban_month, ban_days, ban_years, ban_hr, ban_min, ban_sec);
	format(sInfo[last_bwhen], 256, "%s", when);
	savestatistics();
	
	format(Query, 600, "SELECT * FROM `bans` WHERE `username` = '%q'", GetName(playerid));
	result = db_query(Database, Query);
	if(!db_num_rows(result))
	{
		format(Query, 500, "INSERT INTO `bans` (`username`, `ip`, `banby`, `banreason`, `banwhen`) VALUES ('%q', '%s', '%s', '%s', '%s')", GetName(playerid), User[playerid][accountIP], admin, reason, when);
		result = db_query(Database, Query);
	}
	db_free_result(result);
	return 1;
}
i added the query. but it's still not saving any ban... what do i do here
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)