offban in mysql
#1

I need help, how to make offban command, to ban player who is not online, I'm using BlueG MySQL plugin R7. I tried but after I finish my command, I can't start my gamemode. But when I comment offban command, everything works fine.
Reply
#2

Check the following points:

- Using a plugin? Make sure it's in the plugin folder and working on your host, and that you're using the right one for your OS.
- Made a command? Make sure you're using the same processor in your entire server.

Else, please post your command code so I can take a look at it.
Reply
#3

Here is my offban command:

Код:
YCMD:offban(playerid, params[])
{
	new ime[24], razlog[64];
	if(Ulogovan[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Niste ulogovani!");
	if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_RED, "(Greska!) {646464}Niste Administrator!");
	if(PlayerInfo[playerid][pAdmin] <= 4) return SendClientMessage(playerid, COLOR_RED, "(Greska!) {646464}Morate biti Admin level 1337+!");
	if(sscanf(params, "s[24]s[64]", ime, razlog)) return SendClientMessage(playerid, COLOR_GREY, "Koristite: /offban [Ime_Prezime igraca] - Unos je osjetljiv na mala i velika slova!");
	if(PlayerInfo[playerid][pAdmin] >= 1337)
	{
		new query[256];
		mysql_format(SQL_konekcija, query, sizeof query, "SELECT * FROM `korisnici` WHERE `pNick` = '%s'", ime);
		mysql_function_query(SQL_konekcija, query, false, "SendQuery", " ");
		mysql_store_result();
		if(mysql_num_rows == 0)
		{
			SendClientMessage(playerid, COLOR_RED, "(Greska!) {646464}Uneseno ime ne postoji u bazi podataka!");
			mysql_free_result();
			return 1;
		}
		else if(mysql_num_rows() != 0)
		{
			new hh, mm, gg, mj, dd, hhs[5], mms[5], dds[5], mjs[5], name[MAX_PLAYER_NAME];
			mysql_free_result();
			RPIme(playerid, name);
			gettime(hh, mm);
			getdate(gg, mj, dd);
			if(hh < 10) format(hhs, 5, "0%d", hh);
			else format(hhs, 5, "%d", hh);
			if(mm < 10) format(mms, 5, "0%d", mm);
			else format(mms, 5, "%d", mm);
			if(dd < 10) format(dds, 5, "0%d", dd);
			else format(dds, 5, "%d", dd);
			if(mj < 10) format(mjs, 5, "0%d", mj);
			else format(mjs, 5, "%d", mj);
			
			new query1[256], vrijeme[16], datum[16], stringa[128], string[128];
			format(query1, sizeof(query1), "UPDATE `korisnici` SET `pBanovan` = '1', `pBanRazlog` = '%s', `pBanVrijeme` = '%s', `pBanDatum` = '%s' WHERE `pNick` = '%s'", razlog, vrijeme, datum, ime);
			mysql_function_query(SQL_konekcija, query1, false, "SendQuery", " ");
			
			SCMF(playerid, 0xE61E00FF, "Iskljucili/banovali ste igraca %s sa servera. Razlog: %s", ime, razlog);
			SCMF(playerid, 0xE61E00FF, "Datum:{FFFFFF} %d - %d - %d{E61E00} | Vrijeme: {FFFFFF}%d:%d {E61E00}", dd, mj, gg, hh, mm);
			SendClientMessage(playerid, 0xE61E00FF, "Uslikajte ovo i postavite u temu Popis banova na {FFFFFF}"weburl"!");

			format(stringa, sizeof stringa, "BAN | %s | Admin: %s", ime, name);
			SendClientMessageToAll(0xE61E00FF, stringa);

			format(string, sizeof string, "{E61E00}|BAN| Admin:{FFFFFF} %s {E61E00}| Igrac: {FFFFFF}%s{E61E00} | Razlog: {FFFFFF}%s", name, ime, razlog);
			SendAdminMessage(0xE61E00FF, string);
		}
	}
	return 1;
}
Everything works fine without this command..
Reply
#4

You're using a threaded query on a non threaded function. That's the #1 mistake your code has.

mysql_function_query is used for threaded queries and the script only supports cached data at the R7 stage. Update to R34 if you wish to use non threaded queries, althought I recommend using threaded queries. By using "false" as the cache[] parameter in the function the result will never get stored and you will NEVER have rows. You can only use the cache result in the function that you call with the command, that's why it's called mysql_function_query.

Check the Plugin thread, there's a pretty understable tutorial on how to use threaded queries and it took me very few hours to learn only.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)