CMD:tempban(playerid, params[])
{
new banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedid, reason[25], hours, string[400], secs, unbants, ip[16], query[180];
if(!IsPlayerAdmin(playerid) && pInfo[playerid][playerAdmin] < 2) return SendClientMessage(playerid, ERROR, "You do not have sufficient permissions to use this command."); //this is just my admin check, yours may be different.
if(sscanf(params, "uds[25]", bannedid, hours, reason)) return SendClientMessage(playerid, -1, "Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1, "Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1, "You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
if(strlen(reason) < 3 || strlen(reason) > 24) return SendClientMessage(playerid, -1, "Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
if(hours < 12 || hours > 720) return SendClientMessage(playerid, -1, "Ban hours are between 12 and 720 hours");
GetPlayerName(playerid, banner, sizeof(banner));
GetPlayerName(bannedid, banned, sizeof(banned));
GetPlayerIp(bannedid, ip, sizeof(ip));
secs = hours*3600
unbants = gettime()+ secs;
format(query, sizeof(query), "INSERT INTO `bans` (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES ('0', '%s', '%s', '%s', '%s', %d, %d)",
banned, ip, banner, reason, gettime(), unbants);
mysql_query(query);
format(string, sizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s", banner, reason);
ShowPlayerDialog(bannedid, 678, DIALOG_STYLE_MSGBOX, "Banned!", string, "Close", "");
format(string, sizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s", banner, playerid, banned, bannedid, hours, reason);
SendClientMessageToAll(-1, string);
SetTimerEx("KickEx", 500, false, playerid, "i");
return 1;
}
forward KickEx(playerid);
public KickEx(playerid)
{
Kick(playerid);
return 1;
}
forward OnBanCheck(playerid);
public OnBanCheck(playerid)
{
new banquery[180], ip[16];
GetPlayerIp(playerid, ip, 16);
format(banquery, sizeof(banquery), "SELECT unban_time FROM `bans` WHERE ip = '%s'", ip);
mysql_query(banquery);
mysql_store_result();
if(mysql_num_rows() != 0)
{
new unbantimestamp = mysql_fetch_int();
if(unbantimestamp > gettime())
{
SendClientMessage(playerid, -1, "You're banned from this server.");
SetTimerEx("KickEx", 500, false, playerid, "i");
}
}
return 1;
}
// MySQL connection handle
new MySQL: YOURHANDLENAME;//Your Connection Handle, can be whatever you want it to be, if you have this already, disregard this.
CMD:tempban(playerid, params[])
{
new banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedid, reason[25], hours, string[400], secs, unbants, ip[16], query[180];
if(!IsPlayerAdmin(playerid) && pInfo[playerid][playerAdmin] < 2) return SendClientMessage(playerid, ERROR, "You do not have sufficient permissions to use this command."); //this is just my admin check, yours may be different.
if(sscanf(params, "uds[25]", bannedid, hours, reason)) return SendClientMessage(playerid, -1, "Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1, "Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1, "You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
if(strlen(reason) < 3 || strlen(reason) > 24) return SendClientMessage(playerid, -1, "Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
if(hours < 12 || hours > 720) return SendClientMessage(playerid, -1, "Ban hours are between 12 and 720 hours");
GetPlayerName(playerid, banner, sizeof(banner));
GetPlayerName(bannedid, banned, sizeof(banned));
GetPlayerIp(bannedid, ip, sizeof(ip));
secs = hours*3600;
unbants = gettime()+ secs;
mysql_format(YOURHANDLENAME, query, sizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)", banned, ip, banner, reason, gettime(), unbants);
mysql_tquery(YOURHANDLENAME, query);
format(string, sizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s", banner, reason);
ShowPlayerDialog(bannedid, 678, DIALOG_STYLE_MSGBOX, "Banned!", string, "Close", "");
format(string, sizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s", banner, playerid, banned, bannedid, hours, reason);
SendClientMessageToAll(-1, string);
SetTimerEx("KickEx", 500, false, playerid, "i");
return 1;
}
forward KickEx(playerid);
public KickEx(playerid)
{
Kick(playerid);
return 1;
}
forward OnBanCheck(playerid);
public OnBanCheck(playerid)
{
new banquery[180], ip[16];
GetPlayerIp(playerid, ip, 16);
new rows;
mysql_format(YOURHANDLENAME, banquery, sizeof(banquery), "SELECT unban_time FROM `bans` WHERE `ip` = '%s'", ip);
mysql_tquery(YOURHANDLENAME, banquery);
if(cache_get_row_count(rows))
{
new unbantimestamp = mysql_fetch_int();
if(unbantimestamp > gettime())
{
SendClientMessage(playerid, -1, "You're banned from this server.");
SetTimerEx("KickEx", 500, false, playerid, "i");
return 1;
}
}
return 1;
}
CMD:tempban(playerid, params[])
{
new banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedid, reason[25], hours, string[400], secs, unbants, ip[16], query[180];
if(!pInfo[playerid][playerAdmin]) return SendClientMessage(playerid, ERROR, "You do not have sufficient permissions to use this command.");
if(sscanf(params, "uds[25]", bannedid, hours, reason)) return SendClientMessage(playerid, -1, "Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1, "Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1, "You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
if(strlen(reason) < 3 || strlen(reason) > 24) return SendClientMessage(playerid, -1, "Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
if(hours < 12 || hours > 720) return SendClientMessage(playerid, -1, "Ban hours are between 12 and 720 hours");
GetPlayerName(playerid, banner, sizeof(banner));
GetPlayerName(bannedid, banned, sizeof(banned));
GetPlayerIp(bannedid, ip, sizeof(ip));
secs = hours*3600
unbants = gettime()+ secs;
mysql_format(connectionHandle, query, sizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)", banned, ip, banner, reason, gettime(), unbants);
mysql_tquery(connectionHandle, query);
format(string, sizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s", banner, reason);
ShowPlayerDialog(bannedid, 678, DIALOG_STYLE_MSGBOX, "Banned!", string, "Close", "");
format(string, sizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s", banner, playerid, banned, bannedid, hours, reason);
SendClientMessageToAll(-1, string);
SetTimerEx("Kick", 500, false, playerid, "i");
return 1;
}
forward OnBanCheck(playerid);
public OnBanCheck(playerid)
{
new banquery[180], ip[16];
GetPlayerIp(playerid, ip, 16);
new rows;
mysql_format(connectionHandle, banquery, sizeof(banquery), "SELECT unban_time FROM `bans` WHERE `ip` = '%s'", ip);
mysql_tquery(connectionHandle, banquery);
if(cache_get_row_count(rows))
{
new unbantimestamp = mysql_fetch_int();
if(unbantimestamp > gettime())
{
SendClientMessage(playerid, -1, "You're banned from this server.");
SetTimerEx("Kick", 500, false, playerid, "i");
return 1;
}
}
return 1;
}
forward KickEx(playerid);
public KickEx(playerid)
{
Kick(playerid);
return 1;
}
(3348) : warning 213: tag mismatch
(3358) : error 001: expected token: ";", but found "-identifier-"
(3365) : error 035: argument type mismatch (argument 4)
(3378) : error 017: undefined symbol "mysql_fetch_int"
(3382) : error 035: argument type mismatch (argument 4)
unbants = gettime()+ secs; line 3358
if(!pInfo[playerid][playerAdmin]) return SendClientMessage(playerid, ERROR, "You do not have sufficient permissions to use this command."); line 3348
SetTimerEx("Kick", 500, false, playerid, "i"); line 3365
new unbantimestamp = mysql_fetch_int(); 3378 line
forward KickEx(playerid);
public KickEx(playerid)
{
Kick(playerid);
return 1;
} line 3382
PHP Code:
PHP Code:
PHP Code:
|
CMD:tempban(playerid, params[])
{
new banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedid, reason[25], hours, string[400], secs, unbants, ip[16], query[180];
if(!pInfo[playerid][playerAdmin]) return SendClientMessage(playerid, ERROR, "You do not have sufficient permissions to use this command.");
if(sscanf(params, "uds[25]", bannedid, hours, reason)) return SendClientMessage(playerid, -1, "Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1, "Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1, "You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
if(strlen(reason) < 3 || strlen(reason) > 24) return SendClientMessage(playerid, -1, "Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
if(hours < 12 || hours > 720) return SendClientMessage(playerid, -1, "Ban hours are between 12 and 720 hours");
GetPlayerName(playerid, banner, sizeof(banner));
GetPlayerName(bannedid, banned, sizeof(banned));
GetPlayerIp(bannedid, ip, sizeof(ip));
secs = hours*3600;//You were missing the ; at the end of this line
unbants = gettime()+ secs;
mysql_format(connectionHandle, query, sizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)", banned, ip, banner, reason, gettime(), unbants);
mysql_tquery(connectionHandle, query);
format(string, sizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s", banner, reason);
ShowPlayerDialog(bannedid, 678, DIALOG_STYLE_MSGBOX, "Banned!", string, "Close", "");
format(string, sizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s", banner, playerid, banned, bannedid, hours, reason);
SendClientMessageToAll(-1, string);
SetTimerEx("Kick", 500, false, playerid, "i");
return 1;
}