02.07.2016, 15:52
hello,
I have a filterscript, whitelist sort of way, I have a database table structured this way:
PRIMARY KEY - VARCHAR(32) - VARCHAR(32)
ID (int 11) - Player - IP
when a player joins the server, the filterscript must check the table if the playername is in there, if it's not, kick the player;
the issue is that, the table is empty with no data, but when player joins with whatever name, it doesn't kick him and says that he is on the database.
Here is some code :
thank you
I have a filterscript, whitelist sort of way, I have a database table structured this way:
PRIMARY KEY - VARCHAR(32) - VARCHAR(32)
ID (int 11) - Player - IP
when a player joins the server, the filterscript must check the table if the playername is in there, if it's not, kick the player;
the issue is that, the table is empty with no data, but when player joins with whatever name, it doesn't kick him and says that he is on the database.
Here is some code :
Код:
CheckState(playerid) { if(Enabled) // { CheckMySQL(); new string[128], plrIP[16]; GetPlayerIp(playerid, plrIP, sizeof(plrIP)); format(string, sizeof(string), "SELECT * FROM acplayers WHERE Player = '%s'", GetName(playerid)); mysql_query(string); mysql_store_result(); if(!mysql_num_rows()) // Kick him + Telling him to be in whitelist { // this line should be triggered cuz there is no player on table for now.. but it doesn't. it goes to the else statement. Connected[playerid] = false; KickInTime(playerid, 1); } else { mysql_free_result(); // check if whitelisted ip is ok format(string, sizeof(string), "SELECT * FROM acplayers WHERE Player = '%s' AND IP = '%s'", GetName(playerid), plrIP); mysql_query(string); mysql_store_result(); if(!mysql_num_rows()) // Kick him if not. { Connected[playerid] = false; KickInTime(playerid, 2); } else { new row[128]; new field[4][64]; mysql_fetch_row_format(row, "|"); explode(row, field, "|"); mysql_free_result(); format(ACPlayers[playerid][PlayerIP], 16, "%s", field[1]); // Address IPs SendClientMessage(playerid, -1, ACPlayers[playerid][PlayerIP]); // This prints nothing ""; } } mysql_free_result(); } }