BanIP problem
#1

Код:
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 ?
Reply
#2

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
Reply
#3

@ 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
Reply
#4

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(..) :

pawn Код:
printf("%s", playersip);
Reply
#5

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.
Reply
#6

Weird. Why don't they fix such bugs
Reply
#7

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?
Reply
#8

Well, why did it work well before the release of 0.3e?
Reply
#9

Probably because of a change in code xD Not a clue what though.
Reply
#10

That's what I said
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)