SA-MP Forums Archive
Problem with Ban - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with Ban (/showthread.php?tid=489514)



Problem with Ban - anou1 - 22.01.2014

Hi,
I tried to make a cmd to ban someone. All work fine I think, didnt tried it yet, but I wanted to save the reason of the ban into my mysql database. But I'm blocked, I really don't know how could I do this, I tried something but I don't work at all.

Could someone help me to do this ?
When I ban someone, the reason will be saved in my sql database.

This is my cmd and what I tried:



Код:
CMD:aban(playerid, params[])
{
	if(pInfo[playerid][Admin] >= 60)
	{
		new string[128], raison[128], id;
		if(sscanf(params, "us[128]", id, raison)) return SendClientMessage(playerid, Rouge, "Utilisation: /aban [ID Joueur] [Raison]");
		if(id==INVALID_PLAYER_ID) return SendClientMessage(playerid, Rouge,"Ce joueur n'est pas connectй !");
		GetPlayerName(playerid, joueuremetteur, sizeof(joueuremetteur));
		GetPlayerName(id, joueurdestinataire, sizeof(joueurdestinataire));
		if(pInfo[playerid][Admin] < pInfo[id][Admin])
		{
			new msg[128];
			format(msg, sizeof(msg), "%s a essayй de ban l'admin %s", playerid, joueurdestinataire);
			ChannelAdmin(Rouge, msg);
			return SendClientMessage(playerid, Rouge, "Vous ne pouvez pas ban un admin de rang supйrieur au votre !");
		}
		GetPlayerName(playerid, joueuremetteur, sizeof(joueuremetteur));
		GetPlayerName(id, joueurdestinataire, sizeof(joueurdestinataire));
		format(string, sizeof(string), "%s a йtй ban par %s. Raison: %s", joueurdestinataire, joueuremetteur, raison);
		ChannelAdmin(Rouge, string);
		format(string, sizeof(string), "Vous avez йtй ban du serveur par %s. Raison: %s", joueuremetteur, raison);
		SendClientMessage(id, Rouge, string);
		pInfo[id][RaisonBan] == raison[id];
		new query[256];
		mysql_format(mysql, query, sizeof(query), "UPDATE `joueurs` SET  `Bannis`=%d, `RaisonBan`=%s WHERE `ID`=%d", 1, pInfo[id][RaisonBan], pInfo[id][ID]);
		mysql_tquery(mysql, query, "", "");
		SetTimerEx("BanJoueur", 1000, 0, "d", id);
		return 1;
	}
	return SendClientMessage(playerid, Rouge,"La commande entrйe est inconnue !");
}
I got a warning and I'm not sure that it will save the reasion

"pInfo[id][RaisonBan] == raison[id];"

warning 215: expression has no effect


Re: Problem with Ban - DobbysGamertag - 22.01.2014

use on‌e = sign

So
pawn Код:
pInfo[id][RaisonBan] = raison[id];



Re : Problem with Ban - anou1 - 22.01.2014

Thank you, this fixed the warning, but when I ban someone, the reason doesn't save into the database
I did: "printf("%s", pInfo[id][RaisonBan]);"

After the query, and It only shows the first letter of the reason.

For exemple if I ban someone for "test" it shows "t".

And It doesn't save "test" or "t" into the database.

Ideas ?

Thank you !


Re: Problem with Ban - Excelize - 22.01.2014

Hi anou1,

My advice would be to copy the command from an admin system, Learn each line of it until you know what It means, then make your own.


Re : Problem with Ban - anou1 - 22.01.2014

Did you read what I wrote ?

My ban command works well. ALL WORK.

EXCEPT for the mysql part, to save the reason.

That's why I'm asking for help.


Re: Problem with Ban - anou1 - 23.01.2014

UP please


Re: Problem with Ban - Scottas - 23.01.2014

pawn Код:
pInfo[id][RaisonBan] = raison[id];
Instead of this, do this:
pawn Код:
format(pInfo[id][RaisonBan], 128, "%s", raison);
or
pawn Код:
pInfo[id][RaisonBan][0] = 0;
strcat(pInfo[id][RaisonBan], raison);



Re : Problem with Ban - anou1 - 23.01.2014

Thank you, now it printf the good reason.

But it doesn't update the reason at all.

Anyone know what's wrong in my code ?


Re: Problem with Ban - Scottas - 23.01.2014

Take a look into mysql log, maybe you'll find why it doesn't update.


Re : Problem with Ban - anou1 - 23.01.2014

Thank you guy, an other problem solved !

My last problem is to set value of "Bannis" to 1 when I ban an ID.

So I tried to do like the Reason, I tried this:

format(pInfo[id][Bannis], 128, 1);
format(pInfo[id][Bannis], 128, "1");

But with a printf I always have "49" instead of 1.

Any idea to solve this ?
Thank you !