- 24
- 1
Код:
#include <a_samp>
#include <a_mysql>
#include <fix>
#include <streamer>
#include <crashdetect>
#include <Pawn.CMD>
#include <Pawn.Regex>
#include <sscanf2>
#include <foreach>
#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_PASS "root"
#define MYSQL_BASE "bdm"
#define SCM SendClientMessage
#define SCMTA SendClientMessageToALL
#define SPD ShowPlayerDialog
#define DEFAULT_SPAWN_X 1759.0189
#define DEFAULT_SPAWN_Y -1898.1260
#define DEFAULT_SPAWN_Z 13.5622
#define DEFAULT_SPAWN_ANGLE 266.4503
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFF0000FF
main()
{
print("\n----------------------------------");
print("Bloody DeatMatch - NEW PROJECT");
print("----------------------------------\n");
}
//---------------------- IA?AIAIA? ---------------------
new MySQL:dbHandle;
new bool:isPlayerLogged[MAX_PLAYERS];
//---------------------------------------------------------
enum player
{
ID,
NAME[MAX_PLAYER_NAME],
PASSWORD[32],
}
new player_info[MAX_PLAYERS][player];
enum dialogs
{
DLG_NONE,
DLG_REG,
DLG_REGEMAIL,
DLG_LOG,
}
public OnGameModeInit()
{
AddPlayerClass(14,DEFAULT_SPAWN_X, DEFAULT_SPAWN_Y, DEFAULT_SPAWN_Z, DEFAULT_SPAWN_ANGLE,-1,-1,-1,-1,-1,-1);
AddPlayerClass(15,DEFAULT_SPAWN_X, DEFAULT_SPAWN_Y, DEFAULT_SPAWN_Z, DEFAULT_SPAWN_ANGLE,-1,-1,-1,-1,-1,-1);
AddPlayerClass(101,DEFAULT_SPAWN_X, DEFAULT_SPAWN_Y, DEFAULT_SPAWN_Z, DEFAULT_SPAWN_ANGLE,-1,-1,-1,-1,-1,-1);
AddPlayerClass(183,DEFAULT_SPAWN_X, DEFAULT_SPAWN_Y, DEFAULT_SPAWN_Z, DEFAULT_SPAWN_ANGLE,-1,-1,-1,-1,-1,-1);
AddPlayerClass(184,DEFAULT_SPAWN_X, DEFAULT_SPAWN_Y, DEFAULT_SPAWN_Z, DEFAULT_SPAWN_ANGLE,-1,-1,-1,-1,-1,-1);
AddPlayerClass(14,DEFAULT_SPAWN_X, DEFAULT_SPAWN_Y, DEFAULT_SPAWN_Z, DEFAULT_SPAWN_ANGLE,-1,-1,-1,-1,-1,-1);
SetGameModeText("Blank Script");
ConnectMySQL();
return 1;
}
stock ConnectMySQL()
{
dbHandle = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_BASE);
switch(mysql_errno())
{
case 0: print("Iiaee??aiea e MySQL oniaoii");
default: print("MySQL error!");
}
mysql_log(ERROR | WARNING);
mysql_set_charset("cp1251");
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(isPlayerLogged[playerid]) return SpawnPlayer(playerid); // ???? ????? ????? F4, ?? ??? ???????????, ?? ????? ??? ??????? ????????? ??? ???
SetPlayerInterior(playerid,11); // ???????? ????
SetPlayerPos(playerid, 508.7362,-87.4335,998.9609); // ??????? ??????
SetPlayerFacingAngle(playerid, 0); // ???? ???????? ??????
SetPlayerCameraPos(playerid, 508.7362,-83.4335,998.9609); // ??????? ??????
SetPlayerCameraLookAt(playerid, 508.7362,-87.4335,998.9609); // ??????????, ?? ??????? ????? ???????? ??????
SetPlayerVirtualWorld(playerid, playerid+1); // ????????? ??????????? ??? ? ID ?????? ID ?????? + 1, ???? ??????? ????? ???
return 1;
}
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, player_info[playerid][NAME], MAX_PLAYER_NAME);
static const fmt_query[] = "SELECT id FROM users WHERE name = '%s'";
new query[sizeof(fmt_query)+(-2+MAX_PLAYER_NAME)];
format(query, sizeof(query), fmt_query, player_info[playerid] [NAME]);
mysql_tquery(dbHandle, query, "CheckRegistration", "i", playerid);
return 1;
}
forward CheckRegistration(playerid);
public CheckRegistration(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows) ShowLogin(playerid);
else ShowRegistration(playerid);
}
stock ShowLogin(playerid)
{
new dialog[183+(-2+MAX_PLAYER_NAME)];
format(dialog, sizeof(dialog),
"{FFFFFF}Oaa?aaiue {594de1}%s{FFFFFF}, iu ?aau niiaa aeaaou aan ia {594de1}Bloody DeatMatch{FFFFFF}\n\
Aeeaoio n oaeei ieeii ca?aaeno?e?iaai\n\n\
Aey i?iaie?aiey aaaaeoa naie ia?ieu ie?a:",
player_info[playerid] [NAME]
);
SPD(playerid, DLG_LOG, DIALOG_STYLE_INPUT, "{e743e4}Aaoi?ecaoey{FFFFFF}", dialog, "Aaeaa", "Auoia");
}
stock ShowRegistration(playerid)
{
new dialog[410+(-2+MAX_PLAYER_NAME)];
format(dialog, sizeof(dialog),
"{FFFFFF}Oaa?aaiue {594de1}%s{FFFFFF}, iu ?aau aeaaou aan ia {594de1}Bloody DeatMatch{FFFFFF}\n\
Aeeaoio n oaeei ieeii ia ca?aaeno?e?iaai\n\
{594de1}Aey ia?aea ea?u au aie?iu i?eaoiaou nei?iue ia?ieu\n\
{FF0000}-I?iaa?uoa ycue aaiaa\n\
{ff0000}-I?e iioa?e ia?iey nay?eoanu n aaieieno?aoi?ii\n\n\
{594de1} Bloody DeatMatch | https://vk.com/quwin_cln",
player_info[playerid] [NAME]
);
SPD(playerid, DLG_REG, DIALOG_STYLE_INPUT, "{e743e4}?aaeno?aoey{FFFFFF}", dialog, "Aaeaa", "Auoia");
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
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)
{
isPlayerLogged[playerid] = true;
SendClientMessage(playerid, -1, "Ana oi?ioi. I?eyoiie ea?u.");
SetPlayerVirtualWorld(playerid, 0);
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 DLG_REG:
{
if(response)
{
if(!strlen(inputtext))
{
ShowRegistration(playerid);
return SCM(playerid, COLOR_RED, "[Ioeaea] {FFFFFF}Aaaaeoa a iiea ie?a e ia?ieoa \"Aaeaa\"");
}
if(!(8 <= strlen(inputtext) <= 24))
{
ShowRegistration(playerid);
return SCM(playerid, COLOR_RED, "[Ioeaea] {FFFFFF}Aeeia ia?iey aie?ia auou io 8-ie ai 24-oo neiaieia");
}
new regex:rg_passwordcheck = regex_new("[a-zA-Z0-9]{1,}");
if(regex_check(inputtext, rg_passwordcheck))
{
ShowRegistration(playerid);
regex_delete(rg_passwordcheck);
return SCM(playerid, COLOR_RED, "[Ioeaea] {FFFFFF}Ia?ieu aie?ai ninoiyou ec oeo? e eaoeineeo neiaieia e?aiai ?aaeno?a");
}
}
else
{
SCM(playerid, COLOR_RED, "Eniieucoeoa \"/q\" ?oiau iieeioou na?aa?");
SPD(playerid, -1, 0, "", "", "", "");
return Kick(playerid);
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}