A little issue
#1

Hi so I've made this function for banning players
Код:
stock pBan(bUser, bUserBanner, bReason[], system = 0)
{
	if(system == 0)
	{
		if(IsBanned[bUser] == 0)
		{
		    IsBanned[bUser] = 1;
            new handle = SQL::Open(SQL::INSERT, SQL_BAN_TABLE);
            SQL::ToggleAutoIncrement(handle, true);
            SQL::WriteString(handle, "bUser", bNames[bUser]);
            SQL::WriteString(handle, "bUserBanner", GetAdminName(bUserBanner));
            SQL::WriteString(handle, "bReason", bReason);
            SQL::WriteString(handle, "bUserIP", bIP[bUser]);
			SQL::Close(handle);
			
			IsBanned[bUser] = 1;
			new strkick[180];
			format(strkick, sizeof(strkick), ""COLOR_RED" System has banned %s for: %s", pName(bUser), bReason);
			SendClientMessageToAll(-1, strkick);
            SendClientMessage(bUser, -1, ""COLOR_WHITE" If you feel this is a mistake please, visit "Website" ban appeal section!");
			KickEx(bUser);
		}
	}
	else
	{
		if(IsBanned[bUser] == 0)
		{
		    IsBanned[bUser] = 1;
            new handle = SQL::Open(SQL::INSERT, SQL_BAN_TABLE);
            SQL::ToggleAutoIncrement(handle, true);
            SQL::WriteString(handle, "bUser", bNames[bUser]);
            SQL::WriteString(handle, "bUserBanner", GetAdminName(bUserBanner));
            SQL::WriteString(handle, "bReason", bReason);
            SQL::WriteString(handle, "bUserIp", bIP[bUser]);
			SQL::Close(handle);

			new strkick[180];
			format(strkick, sizeof(strkick), ""COLOR_WHITE" %s %s has banned you for: %s", GetAdminName(bUserBanner), pName(bUserBanner), bReason);
			SendClientMessage(bUser, -1, strkick);
			SendClientMessage(bUser, -1, ""COLOR_ORANGE" If you feel this is a mistake please, visit "Website" ban appeal section!");
			KickEx(bUser);
		}
	}
	return 1;
}
but it doesn't save the information of the banned user it just kicks them I didn't want to do it the long way so on my ban command I would just do pBan(bUser, playerid, bReason, 0);.I thought someone here might know how to help me.
I don't see anything wrong with the code though as it compiles with no errors.
After I've banned myself I've checked the table in phpmyadmin and it came up empty also did testing with friends and same result.

Any support is appreciated.
Note: I am using easy-mysql to do this.
Reply
#2

I don't see anything wrong in your code specifically. Have you tried enabling mysql debugging?
Reply
#3

I didnt even bother checking the logs
[plugins/mysql] error #1265 while executing query "INSERT INTO `Bans` (`bUser`,`bUserBanner`,`bReason`,`bUserIP`) VALUES ('Hybris','Owner','test','127.0.0.1' );": Data truncated for column 'bUserIP' at row 1 although I don't understand how the data is truncated...
Reply
#4

Can you show your ban table's structure?
Reply
#5

Yeah here you go
Код:
	if(!SQL::ExistsTable(SQL_BAN_TABLE))
	{
	    new handle = SQL::Open(SQL::CREATE, SQL_BAN_TABLE);
	    SQL::AddTableColumn(handle, "bUID", SQL_TYPE_INT, 11, true);
	    SQL::AddTableColumn(handle, "bUser", SQL_TYPE_VCHAR, 24);
	    SQL::AddTableColumn(handle, "bUserBanner", SQL_TYPE_VCHAR, 24);
	    SQL::AddTableColumn(handle, "bReason", SQL_TYPE_VCHAR, 90);
	    SQL::AddTableColumn(handle, "bUserIP", SQL_TYPE_VCHAR, 16);
	    SQL::Close(handle);
	    
	    print("[Unix]: Successfully created ban table!");
	}
	else if(SQL::ExistsTable(SQL_BAN_TABLE))
	{
	    printf("[Unix]: Total %d bans loaded from the ban table!", SQL::CountRows(SQL_BAN_TABLE));
	}
Also first time I put the sql type integer for buserip ive changed it to vchar but still no change.
Reply
#6

try to put 'INSERT' code manually in base with SQL. (like this)

If it placed sucesfully, than problem must be in bIP[bUser], where does it takes ip?
if not, then you must ensure that your SQL is correctly configured.
Reply
#7

I've managed to fix it with help from ThePhenix and by setting the collation to utf8_general_ci.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)