03.06.2012, 20:06
(
Последний раз редактировалось Jigsaw`; 04.06.2012 в 02:04.
)
Olб a todos, estou aqui para fazer meu primeiro release no fуrum sa-mp, espero que gostem.
Introduзгo:
Trata-se de um sistema onde pode-se banir e cancelar o banimento de jogadores, com 2 comandos.
Lembrando que й necessбrio ter o mнnimo de conhecimento sobre MySQL para se usar este sistema (criar as tabelas etc...).
Comandos:
/ban - Bane um jogador
/desban - Cancela o banimento
Source - FilterScript
Source - DB (tem tag pra MySQL aqui?)
Download
FilterScript: http://pastebin.com/jj8ft2Gq
DB: http://pastebin.com/TPsin5n4
Espero que gostem
Introduзгo:
Trata-se de um sistema onde pode-se banir e cancelar o banimento de jogadores, com 2 comandos.
Lembrando que й necessбrio ter o mнnimo de conhecimento sobre MySQL para se usar este sistema (criar as tabelas etc...).
Comandos:
/ban - Bane um jogador
/desban - Cancela o banimento
Source - FilterScript
pawn Код:
#include <a_samp>
#include <a_mysql>
#include <zcmd>
#include <sscanf2>
#define UNBAN_TYPE_ACCOUNT (1)
#define UNBAN_TYPE_IP (2)
new
jDB,
jString[200],
jData[MAX_PLAYERS][2][24],
bool:jBlock[MAX_PLAYERS]
;
forward @banPlayer(playerid, adminname[], reason[]);
forward @checkBan(playerid);
forward @checkForUnban(playerid, type, value[]);
forward @submitUnban(playerid, type, value[]);
public OnFilterScriptInit() {
jDB = mysql_connect("localhost", "root", "jigBanSystem", "");
if(mysql_ping(jDB) < 1)
return SendRconCommand("unloadfs jigBan");
print("\n------------------------------");
print(" Ban System");
print(" Copyright © 2012 Jigsaw`");
print("------------------------------\n");
return 1;
}
public OnFilterScriptExit() {
mysql_close(jDB);
return 1;
}
public OnPlayerConnect(playerid) {
GetPlayerName(playerid, jData[playerid][0], 24);
GetPlayerIp(playerid, jData[playerid][1], 24);
checkBan(playerid);
return 1;
}
public OnPlayerSpawn(playerid) {
if(jBlock[playerid])
return Kick(playerid);
return 1;
}
stock banPlayer(playerid, adminname[], reason[]) {
if(strlen(reason) > 64)
return 0;
getdate(jString[2], jString[1], jString[0]);
gettime(jString[3], jString[4], jString[5]);
format(jString, 32, "%02d/%02d/%d - %02d:%02d:%02d", jString[0], jString[1], jString[2], jString[3], jString[4], jString[5]);
mysql_format(jDB, jString, "INSERT INTO `jigBan` (`Name`,`Admin`,`Reason`,`DateAndHour`,`IP`) VALUES ('%s','%s','%s','%s','%s')",
jData[playerid][0],
adminname,
reason,
jString,
jData[playerid][1]
);
mysql_function_query(jDB, jString, false, "@banPlayer", "iss", playerid, adminname, reason);
return 1;
}
public @banPlayer(playerid, adminname[], reason[]) {
format(jString, sizeof jString, "%s{FFFFFF} foi banido por {1E90FF}%s {E31919}(%s)", jData[playerid][0], adminname, reason);
SendClientMessageToAll(0x1E90FFFF, jString);
Kick(playerid);
return 1;
}
stock checkBan(playerid) {
mysql_format(jDB, jString, "SELECT * FROM `jigBan` WHERE `Name` = '%s' OR `IP` = '%s'", jData[playerid][0], jData[playerid][1]);
mysql_function_query(jDB, jString, true, "@checkBan", "i", playerid);
return 1;
}
public @checkBan(playerid) {
new
jRows,
jFields
;
cache_get_data(jRows, jFields, jDB);
if(!jRows)
return 1;
SendClientMessage(playerid, 0xE31919FF, "(!) Vocк possui registros de banimento!");
cache_get_field_content(0, "Name", jString, jDB);
format(jString, sizeof jString, "Conta: {1E90FF}%s", jString);
SendClientMessage(playerid, 0xFFFFFFFF, jString);
cache_get_field_content(0, "Admin", jString, jDB);
format(jString, sizeof jString, "Admin: {1E90FF}%s", jString);
SendClientMessage(playerid, 0xFFFFFFFF, jString);
cache_get_field_content(0, "Reason", jString, jDB);
format(jString, sizeof jString, "Motivo: {1E90FF}%s", jString);
SendClientMessage(playerid, 0xFFFFFFFF, jString);
cache_get_field_content(0, "DateAndHour", jString, jDB);
format(jString, sizeof jString, "Data - Hora: {1E90FF}%s", jString);
SendClientMessage(playerid, 0xFFFFFFFF, jString);
cache_get_field_content(0, "IP", jString, jDB);
format(jString, sizeof jString, "IP: {1E90FF}%s", jString);
SendClientMessage(playerid, 0xFFFFFFFF, jString);
jBlock[playerid] = true;
return 1;
}
stock checkForUnban(playerid, type, value[]) {
switch(type) {
case UNBAN_TYPE_ACCOUNT: {
mysql_format(jDB, jString, "SELECT * FROM `jigBan` WHERE `Name` = '%s'", value);
mysql_function_query(jDB, jString, true, "@checkForUnban", "iis", playerid, type, value);
}
case UNBAN_TYPE_IP: {
mysql_format(jDB, jString, "SELECT * FROM `jigBan` WHERE `IP` = '%s'", value);
mysql_function_query(jDB, jString, true, "@checkForUnban", "iis", playerid, type, value);
}
}
return 1;
}
public @checkForUnban(playerid, type, value[]) {
new
jRows,
jFields
;
cache_get_data(jRows, jFields, jDB);
if(jRows > 0) {
mysql_format(jDB, jString, "DELETE FROM `jigBan` WHERE `%s` = '%s'", (type == 1) ? ("Name") : ("IP"), value);
mysql_function_query(jDB, jString, false, "@submitUnban", "iis", playerid, type, value);
return 1;
}
SendClientMessage(playerid, 0xF6F600FF, "(!) Nenhum registro de banimento encontrado.");
return 1;
}
public @submitUnban(playerid, type, value[]) {
format(jString, sizeof(jString), "O %s {1E90FF}%s{FFFFFF} foi desbanido por {1E90FF}%s.", (type == 1) ? ("jogador") : ("ip"), value, jData[playerid][0]);
SendClientMessageToAll(0xFFFFFFFF, jString);
return 1;
}
// Comandos
CMD:ban(playerid, params[]) {
if(!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, 0xFFFFFFFF, "(!) Somente admins rcon.");
new
jBanID,
jBanReason[64]
;
if(sscanf(params, "us[64]", jBanID, jBanReason))
return SendClientMessage(playerid, 0xFFFFFFFF, "(!) Use /ban <ID/Nome> <Motivo>");
if(!IsPlayerConnected(jBanID) || jBanID == INVALID_PLAYER_ID)
return SendClientMessage(playerid, 0xFFFFFFFF, "(!) Jogador inativo.");
if(isnull(jBanReason))
return SendClientMessage(playerid, 0xFFFFFFFF, "(!) Por favor especifique o motivo pelo qual estб banindo este jogador.");
banPlayer(jBanID, jData[playerid][0], jBanReason);
return 1;
}
CMD:desban(playerid, params[]) {
if(!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, 0xFFFFFFFF, "(!) Somente admins rcon.");
new
jBanType,
jBanValue[24]
;
if(sscanf(params, "is[24]", jBanType, jBanValue))
return SendClientMessage(playerid, 0xFFFFFFFF, "(!) Use /desban <Tipo [1 = Conta] [2 = IP]> <Nome ~ IP>");
if(UNBAN_TYPE_ACCOUNT < jBanType > UNBAN_TYPE_IP)
return 1;
if(isnull(jBanValue))
return SendClientMessage(playerid, 0xFFFFFFFF, "(!) Especifique o Nome/IP");
checkForUnban(playerid, jBanType, jBanValue);
return 1;
}
Код:
drop table if exists `jigBan`; create table if not exists `jigBan` ( `Name` varchar(24) NOT NULL, `Admin` varchar(24) NOT NULL, `Reason` varchar(64) NOT NULL, `DateAndHour` varchar(32) NOT NULL, `IP` varchar(16) NOT NULL );
FilterScript: http://pastebin.com/jj8ft2Gq
DB: http://pastebin.com/TPsin5n4
Espero que gostem