#include <a_samp>
#include <a_mysql>
#include <fix>
#include <streamer>
#include <crashdetect>
#include <Pawn.CMD>
#include <Pawn.Regex>
#include <sscanf2>
#include <foreach>
#include <mxINI>
#define MYSQL_HOST "localhost"
#define MYSQL_USER "root"
#define MYSQL_PASS "root"
#define MYSQL_BASE "bloody deatmatch"
#define SCM SendClientMessage
#define SCMTA SendClientMessageToALL
#define SPD ShowPlayerDialog
#define COLOR_WHITE 0xFFFFFFFF
main()
{
print("\n----------------------------------");
print("Bloody DeatMatch - NEW PROJECT");
print("----------------------------------\n");
}
//---------------------- ÏÅÐÅÌÅÍÀß ---------------------
new MySQL:dbHandle;
new Text:Register[4];
new Text:texttext[1];
new Text:BG[4];
new Text:nosl[2];
new Text:BGG[4];
new Text:texttext1[1];
new Text:Login[2];
new Text:oppg[1];
new bool:rega[MAX_PLAYERS];
new bool:male[MAX_PLAYERS];
new bool:login[MAX_PLAYERS];
new bool:logged[MAX_PLAYERS];
new SkinM[4] = { 1, 2, 3, 4 };
new SkinF[3] = { 169, 145, 140 };
//---------------------------------------------------------
enum pInfo
{
pName[MAX_PLAYER_NAME],
pPass[16],
pMale,
pSkin
}
new Player_Info[MAX_PLAYERS][pInfo];
enum dialogs
{
DLG_NONE,
DLG_REG,
DLG_LOG,
}
public OnGameModeInit()
{
Regisster();
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("Ïîäêëþ÷åíèå ê MySQL óñïåøíî");
default: print("MySQL error!");
}
mysql_log(ERROR | WARNING);
mysql_set_charset("cp1251");
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
TogglePlayerSpectating(playerid, true);
SelectTextDraw(playerid, 0xFF0000AA);
new string[128];
format(string, sizeof(string), "users/%s.ini", PI[playerid][pName]);
if(!fexist(string))
{
rega[playerid] = false;
male[playerid] = false;
login[playerid] = false;
// ????? ????? ??????
GetPlayerName(playerid, PI[playerid][pName], 24);
format(string, sizeof(string), "%s", PI[playerid][pName]);
TextDrawSetString(Text:Register[0], string);
TextDrawShowForPlayer(playerid, Register[0]);
//
for(new i; i != 4; i++) TextDrawShowForPlayer(playerid, Register[i]);
for(new i; i != 4; i++) TextDrawShowForPlayer(playerid, BG[i]);
for(new i; i != 2; i++) TextDrawShowForPlayer(playerid, nosl[i]);
TextDrawShowForPlayer(playerid, texttext[0]);
}
else
{
// ???????????
GetPlayerName(playerid, PI[playerid][pName], 24);
format(string, sizeof(string), "%s", PI[playerid][pName]);
TextDrawSetString(Text:Register[0], string);
TextDrawShowForPlayer(playerid, Register[0]);
//
for(new i; i != 3; i++) TextDrawShowForPlayer(playerid, BGG[i]);
TextDrawShowForPlayer(playerid, oppg[0]);
for(new i; i != 2; i++) TextDrawShowForPlayer(playerid, Login[i]);
TextDrawShowForPlayer(playerid, texttext[0]);
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(logged[playerid] == true) SavePlayer(playerid);
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[])
{
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[])
{
new string[128];
if(dialogid == 1)
{
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "???? ??????", "??????? ?????????? ??????:", "????", "???????");
if(strlen(inputtext) < 6 || strlen(inputtext) > 14) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "???? ??????", "??????? ?????????? ??????:", "????", "???????");
for(new pass; pass < strlen(inputtext); pass++)
switch(inputtext[pass])
{
case '0'..'9': continue;
case 'A'..'Z': continue;
case 'a'..'z': continue;
default: return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "???? ??????", "??????? ?????????? ??????:", "????", "???????");
}
// ??????????
format(string, sizeof(string), "users/%s.ini", PI[playerid][pName]);
new iniFile = ini_createFile(string);
if(iniFile < 0) ini_openFile(string);
{
ini_setString(iniFile, "Password", inputtext);
ini_closeFile(iniFile);
}
// ----------
format(string, sizeof(string), "%s", inputtext);
TextDrawSetString(Text:nosl[1], string);
rega[playerid] = true;
}
else
{
}
}
if(dialogid == 2)
{
if(response)
{
new sex[11];
PI[playerid][pMale] = 1;
new randomM = random(sizeof(SkinM));
PI[playerid][pSkin] = SkinM[randomM];
if(PI[playerid][pMale] == 1) sex = "MEN";
format(string, sizeof(string), "%s", sex);
TextDrawSetString(Text:nosl[0], string);
male[playerid] = true;
}
else
{
new sex[11];
PI[playerid][pMale] = 2;
new randomF = random(sizeof(SkinF));
PI[playerid][pSkin] = SkinF[randomF];
if(PI[playerid][pMale] == 2) sex = "WOOMAN";
format(string, sizeof(string), "%s", sex);
TextDrawSetString(Text:nosl[0], string);
male[playerid] = true;
}
}
if(dialogid == 3)
{
if(response)
{
if(rega[playerid] == false)
{
SendClientMessage(playerid, 0xFFFFFFAA, "?? ?? ????? ??????! ?? ?? ?????? ????????????.");
return 1;
}
if(male[playerid] == false)
{
SendClientMessage(playerid, 0xFFFFFFAA, "?? ?? ??????? ??? ?????????! ?? ?? ?????? ????????????.");
return 1;
}
if(rega[playerid] == false && male[playerid] == false)
{
SendClientMessage(playerid, 0xFFFFFFAA, "?? ?? ????? / ??????? ??????");
return 1;
}
TogglePlayerSpectating(playerid, false);
for(new i; i != 4; i++) TextDrawHideForPlayer(playerid, Register[i]);
for(new i; i != 4; i++) TextDrawHideForPlayer(playerid, BG[i]);
for(new i; i != 2; i++) TextDrawHideForPlayer(playerid, nosl[i]);
TextDrawHideForPlayer(playerid, texttext[0]);
SpawnPlayer(playerid);
// ?????????? ??????
SetPlayerPos(playerid, 1154.3717,-1769.2594,16.5938);
SetPlayerFacingAngle(playerid, 0.6853);
SetCameraBehindPlayer(playerid);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
// -----------------
SetPlayerSkin(playerid, PI[playerid][pSkin]);
// -----------------
SavePlayer(playerid);
CancelSelectTextDraw(playerid);
logged[playerid] = true;
}
else { }
}
if(dialogid == 4)
{
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 4, DIALOG_STYLE_INPUT, "???????????", "??????? ?????????? ?????? ?? ????????:", "????", "???????");
format(string, sizeof(string), "users/%s.ini", PI[playerid][pName]);
new iniFile = ini_openFile(string);
ini_getString(iniFile, "Password", string);
if(!strcmp(inputtext, string, true))
{
ini_getString(iniFile, "Password", string);
ini_getInteger(iniFile, "Male", PI[playerid][pMale]);
ini_getInteger(iniFile, "Skin", PI[playerid][pSkin]);
ini_closeFile(iniFile);
format(string, sizeof(string), "%s", inputtext);
TextDrawSetString(Text:oppg[0], string);
SendClientMessage(playerid, 0xFFCC00AA, "?? ????? ????? ??????! ??????? ?? ?????? SPAWN, ????? ????????????!");
login[playerid] = true;
}
else
{
SendClientMessage(playerid, 0xFFFFFFAA, "?? ????? ??????? ??????.");
ShowPlayerDialog(playerid, 4, DIALOG_STYLE_INPUT, "???????????", "??????? ?????????? ?????? ?? ????????:", "????", "???????");
}
}
else { }
}
if(dialogid == 5)
{
if(login[playerid] == false)
{
SendClientMessage(playerid, 0xFFFFFFAA, "?? ?? ????? ?????? ?? ????????! ?? ?? ?????? ????????????!");
return 1;
}
TogglePlayerSpectating(playerid, false);
TextDrawHideForPlayer(playerid, Register[0]);
for(new i; i != 2; i++) TextDrawHideForPlayer(playerid, BGG[i]);
TextDrawHideForPlayer(playerid, oppg[0]);
for(new i; i != 2; i++) TextDrawHideForPlayer(playerid, Login[i]);
TextDrawHideForPlayer(playerid, texttext[0]);
SpawnPlayer(playerid);
// ?????????? ??????
SetPlayerPos(playerid, 1154.3717,-1769.2594,16.5938);
SetPlayerFacingAngle(playerid, 0.6853);
SetCameraBehindPlayer(playerid);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
// -----------------
SetPlayerSkin(playerid, PI[playerid][pSkin]);
// -----------------
CancelSelectTextDraw(playerid);
logged[playerid] = true;
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public OnPlayerClickTextDraw(playerid, Text: clickedid)
{
if(clickedid == Register[1])
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "???? ??????", "??????? ?????????? ??????:", "????", "???????");
}
if(clickedid == Register[2])
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_MSGBOX, "????? ????", "??????????, ???????? ??????? ??? ?????????:", "???????", "???????");
}
if(clickedid == Register[3])
{
ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "SPAWN", "?? ??????? ?????????????", "??", "???");
}
if(clickedid == Login[0])
{
ShowPlayerDialog(playerid, 4, DIALOG_STYLE_INPUT, "???????????", "??????? ?????????? ?????? ?? ????????:", "????", "???????");
}
if(clickedid == Login[1])
{
ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX, "SPAWN", "?? ??????? ?????????????", "??", "???");
}
}
stock Regisster()
{
BG[0] = TextDrawCreate(410.666625, 149.174072, "usebox");
TextDrawLetterSize(BG[0], 0.000000, 17.428190);
TextDrawTextSize(BG[0], 230.000015, 0.000000);
TextDrawAlignment(BG[0], 1);
TextDrawColor(BG[0], 0);
TextDrawUseBox(BG[0], true);
TextDrawBoxColor(BG[0], 1721355434);
TextDrawSetShadow(BG[0], 0);
TextDrawSetOutline(BG[0], 0);
TextDrawFont(BG[0], 0);
texttext[0] = TextDrawCreate(254.666656, 146.844421, "Bloody.pwn Role Play");
TextDrawLetterSize(texttext[0], 0.395333, 1.770074);
TextDrawAlignment(texttext[0], 1);
TextDrawColor(texttext[0], -1);
TextDrawSetShadow(texttext[0], 0);
TextDrawSetOutline(texttext[0], 1);
TextDrawBackgroundColor(texttext[0], 51);
TextDrawFont(texttext[0], 1);
TextDrawSetProportional(texttext[0], 1);
BG[1] = TextDrawCreate(410.666656, 166.596282, "usebox");
TextDrawLetterSize(BG[1], 0.000000, 0.697327);
TextDrawTextSize(BG[1], 230.000000, 0.000000);
TextDrawAlignment(BG[1], 1);
TextDrawColor(BG[1], 0);
TextDrawUseBox(BG[1], true);
TextDrawBoxColor(BG[1], 102);
TextDrawSetShadow(BG[1], 0);
TextDrawSetOutline(BG[1], 0);
TextDrawFont(BG[1], 0);
Register[0] = TextDrawCreate(300.666564, 164.266601, "NAME");
TextDrawLetterSize(Register[0], 0.225999, 1.102222);
TextDrawAlignment(Register[0], 1);
TextDrawColor(Register[0], -1);
TextDrawSetShadow(Register[0], 0);
TextDrawSetOutline(Register[0], 1);
TextDrawBackgroundColor(Register[0], 51);
TextDrawFont(Register[0], 2);
TextDrawSetProportional(Register[0], 1);
Register[1] = TextDrawCreate(234.666549, 178.785247, "PASSWORD:"); // REGISTER[1] - ??????
TextDrawLetterSize(Register[1], 0.272333, 1.508740);
TextDrawTextSize(Register[1], 409.000152, 8.711111);
TextDrawAlignment(Register[1], 1);
TextDrawColor(Register[1], -1);
TextDrawUseBox(Register[1], true);
TextDrawBoxColor(Register[1], 572662303);
TextDrawSetShadow(Register[1], 0);
TextDrawSetOutline(Register[1], 1);
TextDrawBackgroundColor(Register[1], 51);
TextDrawFont(Register[1], 2);
TextDrawSetProportional(Register[1], 1);
TextDrawSetSelectable(Register[1], true);
BG[2] = TextDrawCreate(410.666656, 183.188888, "usebox");
TextDrawLetterSize(BG[2], 0.000000, 0.789505);
TextDrawTextSize(BG[2], 300.666656, 0.000000);
TextDrawAlignment(BG[2], 1);
TextDrawColor(BG[2], 0);
TextDrawUseBox(BG[2], true);
TextDrawBoxColor(BG[2], 102);
TextDrawSetShadow(BG[2], 0);
TextDrawSetOutline(BG[2], 0);
TextDrawFont(BG[2], 0);
nosl[1] = TextDrawCreate(335.666748, 179.614791, "_");
TextDrawLetterSize(nosl[1], 0.192333, 1.276444);
TextDrawAlignment(nosl[1], 1);
TextDrawColor(nosl[1], -1);
TextDrawSetShadow(nosl[1], 0);
TextDrawSetOutline(nosl[1], 1);
TextDrawBackgroundColor(nosl[1], 51);
TextDrawFont(nosl[1], 2);
TextDrawSetProportional(nosl[1], 1);
Register[2] = TextDrawCreate(234.999984, 202.014801, "MALE:");
TextDrawLetterSize(Register[2], 0.321332, 1.409185);
TextDrawTextSize(Register[2], 408.000030, 15.074075);
TextDrawAlignment(Register[2], 1);
TextDrawColor(Register[2], -1);
TextDrawUseBox(Register[2], true);
TextDrawBoxColor(Register[2], 572662303);
TextDrawSetShadow(Register[2], 0);
TextDrawSetOutline(Register[2], 1);
TextDrawBackgroundColor(Register[2], 51);
TextDrawFont(Register[2], 2);
TextDrawSetProportional(Register[2], 1);
TextDrawSetSelectable(Register[2], true);
BG[3] = TextDrawCreate(410.666656, 206.833343, "usebox");
TextDrawLetterSize(BG[3], 0.000000, 0.789505);
TextDrawTextSize(BG[3], 275.666656, 0.000000);
TextDrawAlignment(BG[3], 1);
TextDrawColor(BG[3], 0);
TextDrawUseBox(BG[3], true);
TextDrawBoxColor(BG[3], 102);
TextDrawSetShadow(BG[3], 0);
TextDrawSetOutline(BG[3], 0);
TextDrawFont(BG[3], 0);
nosl[0] = TextDrawCreate(319.000000, 204.918502, "_");
TextDrawLetterSize(nosl[0], 0.216666, 1.122963);
TextDrawAlignment(nosl[0], 1);
TextDrawColor(nosl[0], -1);
TextDrawSetShadow(nosl[0], 0);
TextDrawSetOutline(nosl[0], 1);
TextDrawBackgroundColor(nosl[0], 51);
TextDrawFont(nosl[0], 2);
TextDrawSetProportional(nosl[0], 1);
Register[3] = TextDrawCreate(289.999969, 249.303771, "SPAWN");
TextDrawLetterSize(Register[3], 0.449999, 1.600000);
TextDrawTextSize(Register[3], 347.333282, 15.244444);
TextDrawAlignment(Register[3], 1);
TextDrawColor(Register[3], -1);
TextDrawUseBox(Register[3], true);
TextDrawBoxColor(Register[3], 572662303);
TextDrawSetShadow(Register[3], 0);
TextDrawSetOutline(Register[3], 1);
TextDrawBackgroundColor(Register[3], 51);
TextDrawFont(Register[3], 1);
TextDrawSetProportional(Register[3], 1);
TextDrawSetSelectable(Register[3], true);
// ??????????? -------------------------------------------------------------
BGG[0] = TextDrawCreate(410.666625, 149.174072, "usebox");
TextDrawLetterSize(BGG[0], 0.000000, 17.428190);
TextDrawTextSize(BGG[0], 230.000015, 0.000000);
TextDrawAlignment(BGG[0], 1);
TextDrawColor(BGG[0], 0);
TextDrawUseBox(BGG[0], true);
TextDrawBoxColor(BGG[0], 1721355434);
TextDrawSetShadow(BGG[0], 0);
TextDrawSetOutline(BGG[0], 0);
TextDrawFont(BGG[0], 0);
texttext1[0] = TextDrawCreate(254.666656, 146.844421, "new.pwn Role Play");
TextDrawLetterSize(texttext1[0], 0.395332, 1.770074);
TextDrawAlignment(texttext1[0], 1);
TextDrawColor(texttext1[0], -1);
TextDrawSetShadow(texttext1[0], 0);
TextDrawSetOutline(texttext1[0], 1);
TextDrawBackgroundColor(texttext1[0], 51);
TextDrawFont(texttext1[0], 1);
TextDrawSetProportional(texttext1[0], 1);
BGG[1] = TextDrawCreate(410.666656, 166.596282, "usebox");
TextDrawLetterSize(BGG[1], 0.000000, 0.697327);
TextDrawTextSize(BGG[1], 230.000000, 0.000000);
TextDrawAlignment(BGG[1], 1);
TextDrawColor(BGG[1], 0);
TextDrawUseBox(BGG[1], true);
TextDrawBoxColor(BGG[1], 102);
TextDrawSetShadow(BGG[1], 0);
TextDrawSetOutline(BGG[1], 0);
TextDrawFont(BGG[1], 0);
Login[0] = TextDrawCreate(234.666549, 178.785247, "PASSWORD:");
TextDrawLetterSize(Login[0], 0.272332, 1.508739);
TextDrawTextSize(Login[0], 409.000152, 8.711111);
TextDrawAlignment(Login[0], 1);
TextDrawColor(Login[0], -1);
TextDrawUseBox(Login[0], true);
TextDrawBoxColor(Login[0], 572662303);
TextDrawSetShadow(Login[0], 0);
TextDrawSetOutline(Login[0], 1);
TextDrawBackgroundColor(Login[0], 51);
TextDrawFont(Login[0], 2);
TextDrawSetProportional(Login[0], 1);
TextDrawSetSelectable(Login[0], true);
oppg[0] = TextDrawCreate(335.666748, 179.614791, "_");
TextDrawLetterSize(oppg[0], 0.192332, 1.276443);
TextDrawAlignment(oppg[0], 1);
TextDrawColor(oppg[0], -1);
TextDrawSetShadow(oppg[0], 0);
TextDrawSetOutline(oppg[0], 1);
TextDrawBackgroundColor(oppg[0], 51);
TextDrawFont(oppg[0], 2);
TextDrawSetProportional(oppg[0], 1);
Login[1] = TextDrawCreate(289.999969, 249.303771, "SPAWN");
TextDrawLetterSize(Login[1], 0.449999, 1.600000);
TextDrawTextSize(Login[1], 347.333282, 15.244444);
TextDrawAlignment(Login[1], 1);
TextDrawColor(Login[1], -1);
TextDrawUseBox(Login[1], true);
TextDrawBoxColor(Login[1], 572662303);
TextDrawSetShadow(Login[1], 0);
TextDrawSetOutline(Login[1], 1);
TextDrawBackgroundColor(Login[1], 51);
TextDrawFont(Login[1], 1);
TextDrawSetProportional(Login[1], 1);
TextDrawSetSelectable(Login[1], true);
}
stock SavePlayer(playerid)
{
new string[50];
format(string, sizeof(string), "users/%s.ini", PI[playerid][pName]);
new iniFile = ini_openFile(string);
if(!iniFile)
{
ini_setInteger(iniFile, "Male", PI[playerid][pMale]);
ini_setInteger(iniFile, "Skin", PI[playerid][pSkin]);
ini_closeFile(iniFile);
}
}