pawn Код:
public OnPlayerConnect(playerid)
{
IsPlayerBanned(playerid);
return 1;
}
stock IsPlayerBanned(playerid);
{
new String[128], index[128], Lenght;
format(String, sizeof(String), "SELECT `Lenght` FROM `Your ban table` WHERE `username` = '%s'", PlayerName(playerid));
mysql_query(String);
mysql_store_result();
if(mysql_num_rows() != 0)
{
while(mysql_fetch_row_format(String,"|"))
{
mysql_fetch_field_row(index, "Lenght"); Lenght = strval(index);
}
if(Lenght > getdate())
{
SendClientMessage(playerid, -1, "You are banned from this server");
format(String, sizeof(String), "Your Ban expires %s, ", timec(gettime()-(gettime()-Lenght)));
SendClientMessage(playerid, -1, String);
}
else
{
SendClientMessage(playerid, -1, "You are unbanned!");
format(String, sizeof(String), "DELETE FROM `Ban table` WHERE `User` = '%s'", PlayerName(playerid));
mysql_query(String);
// Or whatever you want
}
}
mysql_free_result();
return 1;
}
//This stock is created by Blacklite
stock timec(timestamp, compare = -1)
{
if (compare == -1) {
compare = gettime();
}
new
n,
Float:d = (timestamp > compare) ? timestamp - compare : compare - timestamp,
returnstr[32];
if (d < 60) {
format(returnstr, sizeof(returnstr), "Less than a minute");
return returnstr;
} else if (d < 3600) { // 3600 = 1 hour
n = floatround(floatdiv(d, 60.5), floatround_floor);
format(returnstr, sizeof(returnstr), "minute");
} else if (d < 86400) { // 86400 = 1 day
n = floatround(floatdiv(d, 3600.5), floatround_floor);
format(returnstr, sizeof(returnstr), "hour");
} else if (d < 2592000) { // 2592000 = 1 month
n = floatround(floatdiv(d, 86400.5), floatround_floor);
format(returnstr, sizeof(returnstr), "day");
} else if (d < 31536000) { // 31536000 = 1 year
n = floatround(floatdiv(d, 2592000.5), floatround_floor);
format(returnstr, sizeof(returnstr), "month");
} else {
n = floatround(floatdiv(d, 31536000.5), floatround_floor);
format(returnstr, sizeof(returnstr), "year");
}
if (n == 1) {
format(returnstr, sizeof(returnstr), "1 %s", returnstr);
} else {
format(returnstr, sizeof(returnstr), "%d %ss", n, returnstr);
}
return returnstr;
}