// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <fix>
#include "streamer"
#include "a_actor"
#include "a_mysql"
#include "dc_cmd"
#include "sscanf2"
#include <mxdate>
#include <foreach>
//=======================================[ Дефайны ]========================================================================
//--------------База данных-------------
#define SQL_HOST "localhost"
#define SQL_USER "root"
#define SQL_PASS "mypw"
#define SQL_DB "mydb"
//-------------Дефайны функций----------
#define SCM SendClientMessage
#define SCMTA SendClientMessageToAll
#define SPD ShowPlayerDialog
//-------------Дефайны цвета------------
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_YELLOW 0xF7FF00FF
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xF0320CFF
#define COLOR_ORANGEYELLOW 0xFFDF0FFF
#define COLOR_LIGHTRED 0xFF4530FF
#define COLOR_LIGHTGREY 0xD1D1D1FF
#define COLOR_BLUE 0x3657FFFF
#define COLOR_SALAD 0xA0FF33FF
#define COLOR_GREEN 0x4BCC2BFF
#define COLOR_ORANGE 0xFF7A05FF
#define SERVER_NAME "Dawn RolePlay"//㡭饠?池
//----------------------аᣨ젠?池-------------------
new rules[] =
"{FFDA1F}1. ϱ{FFFFFF}\n"\
"-Ƞ? 鲯לּ询 쿡?鳻, ??糧 鬨 CLEO ?\n"\
"-Ƞ?DeathMatch (DM) - ?? 衭ᮥ?塢? 餰졡槠౨��\n"\
"-Ƞ? ? 餰⡭ࡱࡢ(�?䥥 ﮨ 㬿�� ⡨䱥)\n"\
"-Ƞ? ?? ല欠襠 쨠?콡? ᣲ"\
"-Ƞ? ?鳼 ࡳ賠⡶欿��Ქ ﲠᥠ��\n"\
"-Ƞ? 鲯לּ询ᮨ塢館吝ﲲ橠?池 嬿 ?ᮨ��??屳䩬 餰흮",
rules_1[] =
"{FFDA1F}2. а?⺥{FFFFFF}\n"\
"-Ƞ?�, ﲪﱡ즭饠屳䩵 餰㝮"\
"-Ƞ? ?軠屳䩬 餰젨ﳭﲿ?��餰�౮��?"\
"-Ƞ? ੱ ??ﬠ(??ya zawel na server"")\n"\
"-Ƞ? 쿡ῠ?᭠ ?ﮭ鵠??\n"\
"-Ƞ? ��鳼 (��ﱿ?婭㼥 ��?쨠��?硱�쯢褐?誜n",
rules_2[] =
"{FFDA1F}3. d�鲲?��FFFF}\n"\
"-Υ泌�?? ᥬ鮨?��?池 �� ?‵ ?鿠塭 ౠ㩫\n"\
"-d�鲲?���?欼㼡鱠沠?�� ?��嬿 롦寣ﮪ?冷 ?“n"\
"-Ҡ騠�??��????鿠鬨 ��硢? (??௱쥥?衯ﲲ? 硫)\n"\
"-Ʊ쨠?�� ?��⼫?ࡪ 㡬 ﹨⯷ ?鳥? ᥬ鮨?��";
enum player
{
ID[6],
NAME[MAX_PLAYER_NAME +1],
MONEY[128],
LEVEL[4],
}
new pInfo[MAX_PLAYERS][player];
new query[256];
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
//new MySQL: sql;
new MySQL: cHandle;
public OnGameModeInit()
{
//=======================================[ Ү楨饠?诩 塭 ]==================================================
new MySQLOpt: option_id = mysql_init_options(); // ϯ��MySQL
mysql_set_option(option_id, AUTO_RECONNECT, true); // b?汥묾��半 cHandle = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB, option_id); // ԭ��嫫��鿍
if(cHandle == MYSQL_INVALID_HANDLE || mysql_errno(cHandle) != 0) // ??묾��塪 ⡧塤ᮭ? {
print("[MySQL] Υ ?ﲼ ?鳼 ?鮥 ?诩 塭."); // û㯤 ??��믭?
SendRconCommand("exit"); // ϱ?㫠 ?池
return 1;
}
print("[MySQL] Ү楨饠?诩 塭 ???즭");
//mysql_log(ERROR | WARNING);
mysql_log(ERROR | WARNING);
DisableInteriorEnterExits();
EnableStuntBonusForAll(0);
SetGameModeText("test");
SendRconCommand("hostname "SERVER_NAME"");
rules[sizeof(rules)-1] = '\n';
rules_1[sizeof(rules_1)-1] = '\n';
rules_2[sizeof(rules_2)-1] = '\0';
AddPlayerClass(0,1755.1631,-1894.1062,13.5568,268.8526,0,0,0,0,0,0);
return 1;
}
public OnGameModeExit()
{
mysql_close(); // Ƞ뱻㡥족捻鮥 ?诩 塭
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, pInfo[playerid][NAME], MAX_PLAYER_NAME);
SetTimerEx("CheckPlayerExistance", 1000, 0, "i", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
//save_account(playerid);
mysql_close();
return 1;
}
public OnPlayerSpawn(playerid)
{
clear_player(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("/test", cmdtext, true, 10) == 0)
{
GivePlayerMoney(playerid, 50000);
// 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:
{
if(!response)
{
SPD(playerid, 35, DIALOG_STYLE_MSGBOX, "{FFEF0D}ϸ颪ࢬ "01", "Ƞ뱻? "");
SCM(playerid, COLOR_RED, "â楨?q(/quit) ��?골.");
Kick(playerid);
return 1;
}
else
{
if(!strlen(inputtext) || strlen(inputtext) < 8 || strlen(inputtext) > 16)
{
SCM(playerid, COLOR_RED, "[Ҩ?ᝠϸ颪ຠͨᬼ 嬨 ࡰ 8 ?אַ⬠�?콭ῠ16.");
}
else
{
new Characters[][2] = {"1","2","3","4","5","6","7","8","9"};
for(new i=0; i<sizeof(Characters); i++)
{
if(strfind(pInfo[playerid][NAME], Characters[i], true) != -1)
{
{
SPD(playerid, 35, DIALOG_STYLE_MSGBOX, "{FFEF0D}ϸ颪ࢬ "à?ꡭ塤ﬦ歠??���� ɧ�鳥 椮 衯ﱨ?椨?��, "Ƞ뱻? "");
SCM(playerid, COLOR_RED, "â楨?q(/quit) ��?골.");
Kick(playerid);
return 1;
}
}
}
SetPVarString(playerid, "reg_pass", inputtext);
SPD(playerid, 2, DIALOG_STYLE_INPUT, "{1472FF}ѥ䲲?��ޫ櫲?ῠ௷? "{FFFFFF}â楨?履??��? ௷?ɱ௫�� 椮, 㻠?泥 㯱??ﲲ? ᴭ?⡱촷ᥠ㨫ﭠ 鬨 沫衧ᢳ妲塯ᱮ켮\n\nΠ email �㼸즬 ?볮 ? 14 宥顂?禲杮র檲衯橠嬿 ?祥 ௷?n\nԡ楨? ⡯?콭ﲲ衢㯤ࡨ �塜"Š즥\"", "Š즥", "");
}
}
}
case 2:
{
if(!response)
{
}
else
{
SPD(playerid, 3, DIALOG_STYLE_INPUT, "{1472FF}ѥ䩱?鿠- ѥ��뢬 "{FFFFFF}Ʊ쨠㻠?쨠ṥ족汢汥 ﲠ?䮠屳䡜n믲ﱻ顲?䱠沬 ?鳥 椮 ⡯ﬥ 杮\n{C3FF1F}а衤ﲲ駥 㡬蠴-䮠?㻠 ௫?衢鶴ᤰ᧤殨墬 "Š즥", "аﰳ?��
SetPVarString(playerid, "email", inputtext);
}
}
case 3:
{
if(!response)
{
SCM(playerid, COLOR_GREY, "Υ?��젢);
SetPVarString(playerid, "referal" , "");
SPD(playerid, 4, DIALOG_STYLE_MSGBOX, "{1472FF}ѥ䩱?鿠- Ю뢬 "û⦰鳥 ௫ 㡸椮 র?砢, "ͳ粪謁, "ǥ驢);
}
else
{
SetPVarString(playerid, "referal" , inputtext);
SCM(playerid, COLOR_GREY, "Ʊ?浥?);
SPD(playerid, 4, DIALOG_STYLE_MSGBOX, "{1472FF}ѥ䩱?鿠- Ю뢬 "û⦰鳥 ௫ 㡸椮 র?砢, "ͳ粪謁, "ǥ驢);
}
}
case 4:
{
if(!response)
{
SetPVarInt(playerid, "sex", 2);
SCM(playerid, COLOR_GREY, "û 㼡? ǥ驠௫.");
SPD(playerid, 5, DIALOG_STYLE_INPUT, "{1472FF}ѥ䩱?鿠- î豠? "Ԫ᧨?侮Ჲ 㡸椮 র?硜nϲ 18 宠50 ̥?"Š즥", "");
}
else
{
SetPVarInt(playerid, "sex", 1);
SCM(playerid, COLOR_GREY, "û 㼡? ͳ粪褐௫.");
SPD(playerid, 5, DIALOG_STYLE_INPUT, "{1472FF}ѥ䩱?鿠- î豠? "Ԫ᧨?侮Ჲ 㡸椮 র?硜nϲ 18 宠50 ̥?"Š즥", "");
}
}
case 5:
{
if(!response)
{
}
else
{
new reg_age = strval(inputtext);
SetPVarInt(playerid, "age", reg_age);
SPD(playerid, 6, DIALOG_STYLE_INPUT, "{1472FF}ѥ䩱?鿠- Π?", "Ԫ᧨?ᱳ ? 㮸졯汱ﮠ禜nà箮! ɭ��ᷨ��??孨?馩.", "Š즥", "");
}
}
case 6:
{
if(!response)
{
}
else
{
SPD(playerid, 7, DIALOG_STYLE_MSGBOX, "{1472FF}ѥ䩱?鿠- ϯ?䱻","{FFFFFF}û 㰥? 餰ᦲ塢 GTA San Andreas Multiplayer (SAMP)?\nͻ ௪᧥졢ᬠ寯שּׂ鳥콭?辰롧먠嬿 㡱.", "ή㩷甆, "Ԧ塨䱠뢩;
SetPVarString(playerid, "about", inputtext);
}
}
case 7:
{
if(!response)
{
SetPVarInt(playerid, "newbie", 0);
SCM(playerid, COLOR_GREY, "û 㼡? - Ԧ塨䱠뢩;
SPD(playerid, 8, DIALOG_STYLE_MSGBOX, "{1472FF}ѥ䩱?鿠- аᣨ젠?池", rules, "а鮿? "ϲ�ࢩ;
}
else
{
SetPVarInt(playerid, "newbie", 1);
SCM(playerid, COLOR_GREY, "û 㼡? - ή㩷甆);
SPD(playerid, 8, DIALOG_STYLE_MSGBOX, "{1472FF}ѥ䩱?鿠- аᣨ젠?池", rules, "а鮿? "ϲ�ࢩ;
}
}
case 8:
{
if(!response)
{
SCM(playerid, COLOR_RED, "[Ҩ?ᝠϸ颪ຠū��?ṥ족汢汥 㡬 ⶮ婬狼Შ??ᣨ졬表䱻.");
Kick(playerid);
}
else
{
//new query[256];
new r_pass[32];
new r_sex;
new r_email[32];
new r_referal[32];
new r_age;
new r_about[256];
new r_newbie;
GetPVarString(playerid, "reg_pass", r_pass, sizeof(r_pass));
GetPVarString(playerid, "email", r_email, sizeof(r_email));
GetPVarString(playerid, "referal", r_referal, sizeof(r_referal));
r_sex = GetPVarInt(playerid, "sex");
r_age = GetPVarInt(playerid, "age");
GetPVarString(playerid, "about", r_about, sizeof(r_about));
r_newbie = GetPVarInt(playerid, "newbie");
format(query, sizeof(query), "INSERT INTO `accounts` (`login`,`password`,`email`,`referal`,`sex`,`age`,`about`,`newbie`) VALUES ('%s','%s','%s','%s','%d','%d','%s','%d')", pInfo[playerid][NAME],r_pass,r_email,r_referal,r_sex,r_age,r_about,r_newbie);
mysql_tquery(cHandle, query, "OnPlayerRegistered", "i", playerid);
}
}
case 9:
{
if(!response)
{
// Ʊ쨠ᬨ 㼵懶
}
else
{
SetPVarString(playerid, "l_pass", inputtext);
//new query[128];
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `login` = '%s' AND `password` = '%s' LIMIT 1",playername(playerid), inputtext);
mysql_tquery(cHandle, query, "OnPlayerLogin", "r", playername(playerid));
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
SetPlayerPos(playerid, fX, fY, fZ);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
//return 0;
}
//====================================================================
stock playername(playerid)
{
new pName[MAX_PLAYER_NAME +1];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}
stock sendername(playerid)
{
new newname[MAX_PLAYER_NAME];
GetPlayerName(playerid, newname, sizeof(newname));
return newname;
}
stock save_account(playerid)
{
new string[256];
format(string, sizeof(string), "[SAVE ACCOUNT ON EXIT] User %s Money Ammount : %d", pInfo[playerid][NAME],pInfo[playerid][MONEY]);
printf(string);
//new query[256];
format(query, sizeof(query), "UPDATE `accounts` SET `money` = '%d' WHERE `id` = '%d' LIMIT 1", pInfo[playerid][MONEY], pInfo[playerid][ID]);
mysql_query(cHandle, query);
}
stock give_money(playerid, amount)
{
pInfo[playerid][MONEY] += amount;
GivePlayerMoney(playerid, amount);
}
stock clear_player(playerid)
{
pInfo[playerid][MONEY] = 0;
pInfo[playerid][ID] = 0;
}
stock LoadPlayerData(playerid)
{
new query[256];
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `login` = '%s'", playername(playerid));
mysql_tquery(sql, query, "OnTest", "r", playerid);
cache_get_value_name_int(0, "money", pInfo[playerid][MONEY]);
}
//====================================================================
forward CheckPlayerExistance(playerid);
public CheckPlayerExistance(playerid)
{
SetPlayerCameraPos(playerid, 1027.7542, -1075.3053, 109.6629);
SetPlayerCameraLookAt(playerid, 1028.7198, -1075.5803, 109.6678);
// ⡬怜 㡰顭?᭥?? 㩤 ﲪ?⡋ﱠҠ?
//format(query, sizeof query, "SELECT * FROM `accounts` WHERE `login` = '%s'", pInfo[playerid][NAME]); // ��᳨? 衯?????鷻 accounts 衯况믬 ?ᥥ ⡯ﬥ name
//mysql_tquery(sql, query, "PlayerExists", "ii", playerid, THREAD_TESTING);
mysql_format(cHandle, query, sizeof(query), "SELECT * FROM `accounts` WHERE `login` = '%e' LIMIT 1",pInfo[playerid][NAME]);
// the variable 'query' contains now the formatted query (including the escaped string)
mysql_tquery(cHandle, query, "PlayerExists");
return 1;
}
forward PlayerExists(playerid);
public PlayerExists(playerid)
{
if (cache_num_rows() < 1) // 沫衭᪤殮 0 ?ᥥ, ?䱮ꡤﬦ歠衰椨???
{
SCM(playerid,COLOR_RED, "NOT REGISTERED");
}
else // ࡥ?妭 ᣲﱨ衶鿍
{
SCM(playerid,COLOR_GREEN, "REGISTERED");
}
return 1;
}