pawn Код:
/* *\
DIRETO DA FORJA DE GM'S FODAS...
... O LENDБRIO SANTA FARIA ROLEPLAY!
CRЙDITOS TODOS AO LELETE
GM DO ZERO!
VAMO Q VAMO
\* */
#include <a_samp>
#include <a_mysql>
//##############################################################################################
#define SERVER_NAME "Santa Faria Roleplay"
#define SERVER_VERSION "SF-RP 1.0"
#define SERVER_MAP "SF-RP 1.0"
#define SERVER_TEXT "hostname [0.3z] Santa Faria Roleplay [BR]"
#define LAST_UPDATE "13 de Fevereiro de 2014"
#define MYSQL_HOST "localhost"
#define MYSQL_USER "sfrp"
#define MYSQL_DB "sfrp"
#define MYSQL_PASS ""
#undef MAX_PLAYERS
#define MAX_PLAYERS (50)
#define DIALOG_NULL (1)
#define DIALOG_LOGIN (2)
#define COLOR_SYSTEM 0xA9C4E4FF
#define COLOR_ERROR 0xAFAFAFFF
#define COLOR_WARNING 0xFFAA00FF
//##############################################################################################
forward SendSuccessMessage(playerid, msg[]);
forward SendErrorMessage(playerid, msg[]);
forward SendSystemMessage(playerid, msg[]);
forward SendWarningMessage(playerid, msg[]);
forward SendRPMessage(playerid, msg[]);
forward OnPlayerLogin(playerid);
forward OnPlayerRegister(playerid);
forward CheckAccount(playerid);
forward CheckBan(playerid);
//##############################################################################################
new db;
//##############################################################################################
main()
{
print("[X] LeLeTe apresenta, do zero... [X]");
print(SERVER_NAME);
print(SERVER_VERSION);
printf("Atualizado em: %s", LAST_UPDATE);
print("[X] A LENDA! [X]");
}
//##############################################################################################
enum P_DATA
{
P_PASS[24],
P_NAME[24],
P_ID
}
new PlayerData[MAX_PLAYERS][P_DATA];
//##############################################################################################
stock ReturnPlayerName(playerid)
{
new string[24];
GetPlayerName(playerid, string, 24);
return string;
}
stock ReturnRPName(playerid)
{
new str, idx;
GetPlayerName(playerid, str[0], 24);
idx = strfind( str[0], "_" );
str[idx] = ' ';
return str;
}
stock StartTutorial(playerid)
{
return playerid;
}
stock BanReason(playerid, reason[])
{
new str[256], pIP[16], safereason[128];
mysql_real_escape_string(safereason, reason, db);
GetPlayerIp(playerid, pIP, 16);
format(str, 256, "INSERT INTO bans (IP, Reason) VALUES('%s', '%s')", pIP, reason);
mysql_function_query(db, str, false, "", "");
BanEx(playerid, reason);
return 1;
}
stock PlayerLog(playerid, reason[])
{
new string[384];
mysql_format(db, string, 384, "INSERT INTO playerlogs (Name, Log) VALUES('%e', '%e')", ReturnPlayerName(playerid), reason);
mysql_function_query(db, string, false, "", "");
return 1;
}
//##############################################################################################
public SendErrorMessage(playerid, msg[])
{
new lengths[128], length2[128], message[128];
strmid(lengths, msg, 0, 115);
strmid(length2, msg, 114, 256);
if(strlen(msg) > 96)
{
format(message, 128, "[ERRO] %s ...", lengths);
SendClientMessage(playerid, COLOR_ERROR, message);
PlayerLog(playerid, message);
format(message, 128, "... %s", length2);
SendClientMessage(playerid, COLOR_ERROR, message);
PlayerLog(playerid, message);
}
else
{
format(message, 128, "[ERRO] %s", msg);
SendClientMessage(playerid, COLOR_ERROR, message);
PlayerLog(playerid, message);
}
return 1;
}
public SendSystemMessage(playerid, msg[])
{
new lengths[128], length2[128], message[128];
strmid(lengths, msg, 0, 96);
strmid(length2, msg, 95, 256);
if(strlen(msg) > 91)
{
format(message, 128, "[{C2A2DA}#{A9C4E4}] %s ...", lengths);
SendClientMessage(playerid, COLOR_SYSTEM, message);
PlayerLog(playerid, message);
format(message, 128, "... %s", length2);
SendClientMessage(playerid, COLOR_SYSTEM, message);
PlayerLog(playerid, message);
}
else
{
format(message, 128, "[[{C2A2DA}#{A9C4E4}] %s", msg);
SendClientMessage(playerid, COLOR_SYSTEM, message);
PlayerLog(playerid, message);
}
return 1;
}
public SendWarningMessage(playerid, msg[])
{
new lengths[128], length2[128], message[128];
strmid(lengths, msg, 0, 118);
strmid(length2, msg, 117, 256);
if(strlen(msg) > 96)
{
format(message, 128, "[!] %s ...", lengths);
SendClientMessage(playerid, COLOR_WARNING, message);
PlayerLog(playerid, message);
format(message, 128, "... %s", length2);
SendClientMessage(playerid, COLOR_WARNING, message);
PlayerLog(playerid, message);
}
else
{
format(message, 128, "[!] %s", msg);
SendClientMessage(playerid, COLOR_WARNING, message);
PlayerLog(playerid, message);
}
return 1;
}
public SendRPMessage(playerid, msg[])
{
new lengths[128], length2[128], message[128];
strmid(lengths, msg, 0, 119);
strmid(length2, msg, 118, 256);
if(strlen(msg) > 96)
{
format(message, 128, "* %s ...", lengths);
SendClientMessage(playerid, 0xC2A2DAFF, message);
PlayerLog(playerid, message);
format(message, 128, "... %s", length2);
SendClientMessage(playerid, 0xC2A2DAFF, message);
PlayerLog(playerid, message);
}
else
{
format(message, 128, "* %s", msg);
SendClientMessage(playerid, 0xC2A2DAFF, message);
PlayerLog(playerid, message);
}
return 1;
}
public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
return printf("[MYSQL] ERRO %d - \"%s\" - \"%s\" - \"%s\" - %d", errorid, error, callback, query, connectionHandle);
public CheckAccount(playerid)
{
new rows, fields, result[24];
cache_get_data(rows, fields);
if(!rows) SetPVarInt(playerid, "AccountExists", 0);
else SetPVarInt(playerid, "AccountExists", 1);
cache_get_row(0, 0, result);
SetPVarString(playerid, "Pass", result);
return 1;
}
public CheckBan(playerid)
{
new rows, fields, string[128];
cache_get_data(rows, fields);
if(!rows) return 1;
else
{
new pIP[16], reason[128];
GetPlayerIp(playerid, pIP, 16);
cache_get_row(0, 0, reason);
format(string, 128, "Foi detectado que seu IP ({C2A2DA}%s{A9C4E4}) se encontra {FF0000}BANIDO{a9C4e4} de nosso servidor. Motivo do Ban:", pIP);
SendSystemMessage(playerid, string);
format(string, 128, "{c2a2da}%s", reason);
SendSystemMessage(playerid, string);
SendSystemMessage(playerid, "Caso seja um erro, tire um print desta mensagem e reporte no fуrum. Vocк serб desconectado imediatamente.");
BanEx(playerid, "[SISTEMA] Tentativa de evasгo de ban");
}
return 1;
}
public OnPlayerRegister(playerid)
{
PlayerData[playerid][P_ID] = mysql_insert_id();
SetPVarInt(playerid, "AccountExists", 1);
SetPVarInt(playerid, "Logged", 1);
SendSystemMessage(playerid, "Bem vindo ao tutorial do Santa Faria Roleplay. Preste atenзгo nas informaзхes na tela.");
StartTutorial(playerid);
return 1;
}
public OnPlayerLogin(playerid)
{
new tick = tickcount();
new result[128], pass[24];
GetPVarString(playerid, "Pass", pass, 24);
cache_get_row(0, 2, result);
if(!strcmp(result, pass, true, 24))
{
cache_get_row(0, 0, PlayerData[playerid][P_ID]);
cache_get_row(0, 1, PlayerData[playerid][P_NAME]);
cache_get_row(0, 2, PlayerData[playerid][P_PASS]);
printf("%d %s %s %d", PlayerData[playerid][P_ID], PlayerData[playerid][P_NAME], PlayerData[playerid][P_PASS], tickcount()-tick);
}
else
{
new la = GetPVarInt(playerid, "LoginAttempts");
SetPVarInt(playerid, "LoginAttempts", la+1);
if(la == 4)
{
SendSystemMessage(playerid, "Seu IP serб banido imediatamente por errar quatro vezes sua senha.");
BanEx(playerid, "[SISTEMA] Errou quatro vezes a senha.");
return 1;
}
return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{C2A2DA}#{A9C4E4} Santa Faria Roleplay", result, "Continuar", "Sair do Servidor");
}
return 1;
}
//##############################################################################################
public OnGameModeInit()
{
#if defined DEBUG
mysql_debug(1);
print("[DEBUG] OnGameModeInit()");
#endif
db = mysql_connect("localhost", "sprp", "sprp", "");
if(db == 0) return print("[ERRO] A conexгo com o banco de dados nгo pode ser estabelecida. Servidor desligando..."), 0;
ShowPlayerMarkers(0);
EnableStuntBonusForAll(0);
DisableInteriorEnterExits();
SetNameTagDrawDistance(15.0);
AddPlayerClass(183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
SetGameModeText(SERVER_VERSION);
SendRconCommand("mapname Santa Faria, SP");
SendRconCommand(SERVER_TEXT);
mysql_function_query(db, "SELECT * FROM playerdata", false, "", "");
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SpawnPlayer(playerid);
return 1;
}
public OnPlayerConnect(playerid)
{
new string[70], pIP[16];
GetPlayerIp(playerid, pIP, 16);
format(string, 70, "SELECT Reason FROM bans WHERE IP = '%s'", pIP);
mysql_function_query(db, string, true, "CheckBan", "i", playerid);
for(new i = 0; i < _:P_DATA; i++)
{
PlayerData[playerid][P_DATA:i] = 0;
}
SendSystemMessage(playerid, "Bem vindo ao Santa Faria Roleplay! O sistema estб carregando seus dados...");
format(string, 70, "SELECT Password FROM playerdata WHERE Name = '%s'", ReturnPlayerName(playerid));
mysql_function_query(db, string, true, "CheckAccount", "i", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
if(!GetPVarInt(playerid, "Logged"))
{
if(!GetPVarInt(playerid, "AccountExists"))
return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{C2A2DA}#{A9C4E4} Santa Faria Roleplay", "Bem vindo!\nPor favor, registre uma senha abaixo para continuar.\nATENЗГO! A senha tem um limite de 24 caracteres.", "Registrar", "Sair");
else
return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{C2A2DA}#{A9C4E4} Santa Faria Roleplay", "Bem vindo!\nPor favor, digite sua senha abaixo para continuar.", "Continuar", "Sair");
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch (dialogid)
{
case 1: return 1;
case 2:
{
if(!response) return SendSystemMessage(playerid, "Vocк serб kickado pois decidiu nгo logar no servidor."), Kick(playerid);
if(!GetPVarInt(playerid, "AccoutnExists"))
{
new string[123], safename[24], safeinput[24];
mysql_real_escape_string(ReturnPlayerName(playerid), safename, db);
mysql_real_escape_string(inputtext, safeinput, db);
format(string, 123, "INSERT INTO playerdata (Name, Password) VALUES('%s', '%s')", safename, safeinput);
mysql_function_query(db, string, true, "OnPlayerRegister", "i", playerid);
}
else
{
new string[123];
format(string, 123, "SELECT * FROM playerdata WHERE Name = '%s'", ReturnPlayerName(playerid), inputtext);
mysql_function_query(db, string, true, "OnPlayerLogin", "i", playerid);
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}