Database Help
#1

Hello all.I got a RP GM from internet and want to use it for my server but I have a problem with it.It use a ban system based on mysql and when a player get banned,ban get saved on database.The problem is i dont have the ban table created and i dont know to to create it because i dont know much on mysql and databases.So i want from you guys to help me create that table(.sql file) then i will upload it to database.

Here is code:

Here it checks the database for bans:
Код HTML:
Public OnPlayerConnect(playerid)
          CheckDatabase(playerid);
CheckDatabase define:

Код HTML:
CheckDatabase(playerid)
{
		new q[200];
		new playername[24];
		GetPlayerName(playerid,playername,sizeof(playername));

		format(q, 200, "SELECT * FROM bans WHERE name = '%s' ORDER BY id DESC LIMIT 1", playername);
		mysql_query(q,THREAD_BAN_CHECK_NAME,playerid);

		new ip[16];
		GetPlayerIp(playerid, ip, sizeof(ip));
		format(q, 200, "SELECT * FROM bans WHERE ip = '%s' ORDER BY id DESC LIMIT 1", ip);
		mysql_query(q,THREAD_BAN_CHECK_IP,playerid);
}
And here is how it inserts the "logs" on the datebase(from here you can see how to create table):

Код HTML:
stock BanPlayer(playerid, giveplayerid, time, reason[])
{
	new name[24], namegive[24];
	if(playerid == 501) format(name, sizeof(name), "Squidward (Anti-Cheat)");
	else GetPlayerName(playerid, name, sizeof(name));
	GetPlayerName(giveplayerid, namegive, sizeof(namegive));
	new curtime = gettime();
	new expire;
	if(!time)
	{
		expire = 1577836800;
	}
	else
	{
		new Float:banminutes = time * 24 * 60 * 60;
		new bantime = floatround(banminutes);
		expire = curtime + bantime;
	}
	new q[400];
	new ip[16];
	GetPlayerIp(giveplayerid, ip, sizeof(ip));
	//AddBan(ip);
	format(q, sizeof(q), "INSERT INTO bans (name, reason, ban_time, issue_time, expiry_time, admin, ip) VALUES ('%s', '%s', %d, %d, %d, '%s', '%s')", namegive, reason, time, curtime, expire, name, ip);
	mysql_query(q, THREAD_INSERT_BAN);
	new banid = mysql_insert_id();
	new string[128];
	if(time)
	format(STRING, "AdmCmd: %s was banned for %d days by %s: %s", GetPlayerNameEx(giveplayerid), time, GetPlayerNameEx(playerid), reason);
	else
	format(STRING, "AdmCmd: %s was banned permanently by %s: %s", GetPlayerNameEx(giveplayerid), name, reason);
	SendClientMessageToAllEx(COLOR_LIGHTRED, string);
	if(time)
	format(STRING, "You were banned by Admin %s for %d days: %s", GetPlayerNameEx(playerid), time, reason);
	else
	format(STRING, "You were banned permanently by Admin %s: %s", name, reason);
	SendClientMessage(giveplayerid, 0x00FF00FF, string);
	new dialogstring[512];
	format(dialogstring, sizeof(dialogstring), "You have been banned from this server for the following reason:\n\n%s\n\nIf you think that this ban was in error, please go to http://Coming Soon! and appeal it.\nYou will need the following info to appeal the ban:\n\nBan ID: %d\nAdmin that banned you: %s\nReason of the ban: %s\n\n{00ff00}PLEASE TAKE A SCREENSHOT USING F8 RIGHT NOW, AND INCLUDE IT IN YOUR BAN APPEAL!", reason, banid, name, reason);
	ShowPlayerDialog(giveplayerid, 4564, DIALOG_STYLE_MSGBOX, "Banned!", dialogstring, "Close", "");
	SetTimerEx("SendToKick", 1500, 0, "i", giveplayerid);
	return 1;
}
Here it tells that you are banned:
Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
	new string2[164];
	switch(resultid)
	{
		case THREAD_BAN_CHECK_NAME:
		{
			mysql_store_result();
			if(mysql_num_rows() == 1)
			{
				if(mysql_retrieve_row())
				{
					new banid, expiry, reason[64], admin[32], tmp[64];
					GET_INT(banid, "id");
					//GET_INT(bantime, "issue_time");
					//GET_INT(length, "ban_time");
					GET_INT(expiry, "expiry_time");
					GET_STR(reason, "reason");
					GET_STR(admin, "admin");
					new curtime = gettime();
					if(curtime < expiry)
					{
						new ip[32];
						GetPlayerIp(extraid, ip, 32);
						format(ToBeKickedString[extraid], 512, "You have been banned from this server for the following reason:\n\n%s\nIf you believe this is a bug, simply relog and rejoin the server.\nIf you think that this ban was in error, please go to http:\\website here and appeal it.\nYou will need the following info to appeal the ban:\n\nBan ID: %d\nAdmin that banned you: %s\nReason of the ban: %s\nBan expiration: %s", reason, banid, admin, reason, expiry);
						format(string2, sizeof(string2), "{AA3333}AdmWarning{FFFF00}: %s (IP:%s) tried to login whilst banned and has been auto-banned.", GetPlayerNameEx( extraid ), ip);
						ABroadCast(COLOR_YELLOW, string2, 2);
      					ToBeKicked[extraid] = 1;
					}
				}
			}
			mysql_free_result();
		}
I created a table on the databse,it saves the bans there but it wont check when a banned player login.So the ban system is not working.Hope you can help me.
Thank You!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)