BanIP problem - 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: BanIP problem (
/showthread.php?tid=374814)
BanIP problem -
cotyzor - 04.09.2012
Код:
public OnPlayerConnect(playerid)
{
new playersip[256];
GetPlayerIp(playerid,playersip,sizeof(playersip));
new quer[256];
format(quer, sizeof(quer), "SELECT * FROM bans WHERE TYPE=2 AND PlayerIP='%s'", playersip);
mysql_query(quer);
mysql_store_result();
if(mysql_num_rows()!=0)
{
SendClientMessage(playerid, COLOR_WHITE, "Your IP is banned.");
SendClientMessage(playerid, COLOR_WHITE, "For unban please visit forum");
Kick(playerid);
return 1;
}
}
Why this code doesn't work ?
Re: BanIP problem -
Jakku - 04.09.2012
There is an issue with GetPlayerIp under OnPlayerConnect, it does not return the IP. There is nothing wrong in your code as far as I know MySQL
EDIT: I would rather use 16 cells in the array, 256 is not really necessary
Re: BanIP problem -
doreto - 04.09.2012
@ Jakku im not sure if its real that you say about issue wich getplayerip when player connect becose its work fine for me whem im getting player ip when connect
@ cotyzor can you post your debug log that we will know if there is any problem wich query
Re: BanIP problem -
Jakku - 04.09.2012
GetPlayerIp returns null for me if I use it with OnPlayerConnect. That would simply explain his issue too.
To make sure of it, better add this debug line AFTER GetPlayerIp(..) :
Re: BanIP problem -
mamorunl - 04.09.2012
We had a similar issue in the Dutch board. This was at OnPlayerDisconnect() and there the IP returned 255.255.255.255. If you still want to call it on PlayerConnect then set a little timer to let the user initiate with the server first.
Re: BanIP problem -
Jakku - 04.09.2012
Weird. Why don't they fix such bugs
Re: BanIP problem -
mamorunl - 04.09.2012
Well, OnPlayerConnect is actually called when a player is still finishing his connecting and OnPlayerDisconnect is called when a player is already in the state of disconnecting. How would you fetch info of a player is not already there or is half gone?
Re: BanIP problem -
Jakku - 04.09.2012
Well, why did it work well before the release of 0.3e?
Re: BanIP problem -
mamorunl - 04.09.2012
Probably because of a change in code xD Not a clue what though.
Re: BanIP problem -
Jakku - 04.09.2012
That's what I said