Толкин
Компетентный
Всем привет, друзья! Сегодня я порылся по форуму да и по гуглу и не смог найти систему pin-code, но потом решил взять ее из мода USA RP.
Дорабатывал до ума - #WH1SKEY
И так, приступим.
Сначала нам необходимо найти перечисления переменных вашего аккаунта(enum) и добавить:
Далее добавим несколько переменных new:
Теперь нам необходимо найти/создать паблик OnPlayerClickTextDraw и добавить в него следующее:
Идем в OnPlayerConnect
Теперь ищем паблик OnGameModeInit
В конец мода вставьте:
Теперь в паблик загрузки аккаунта добавьте:
Если у Вас в паблике загрузки аккаунта есть
Удалите!
Теперь сделаем сохранение pin-code(MySQL r39-4), идем в паблик загрузки аккаунта.
Теперь идем в сток сохранения аккаунта:
В конец добавляем:
Вот как это вышло у меня(ПРИМЕР!):
Ну и конечно не забудьте добавить эти переменные в вашей БД!
Теперь расскажу как сделать смену pin-code:
Для этого, в вашу систему с настройками Безопасности добавьте:
И все!
Дорабатывал до ума - #WH1SKEY
И так, приступим.
Сначала нам необходимо найти перечисления переменных вашего аккаунта(enum) и добавить:
PHP:
sec_pass,
sec_pas_status
PHP:
new Text: TD_PinCode[18];
new PlayerText: PTD_PinCode[MAX_PLAYERS];
new PinCode_Code[MAX_PLAYERS][8];
new PinCode_Mode[MAX_PLAYERS];
new SecretPassTemp[MAX_PLAYERS];
PHP:
if(PinCode_Mode[playerid] > 0)
{
if(clickedid == Text:INVALID_TEXT_DRAW)
{
for(new i = 0; i < 15; i++)
{
TextDrawShowForPlayer(playerid, TD_PinCode[i]);
}
PlayerTextDrawShow(playerid, PTD_PinCode[playerid]);
SelectTextDraw(playerid, 0xffffff88);
return 0;
}
for(new td = 3; td < 15; td++)
{
if(clickedid == TD_PinCode[td])
{
if(td == 12)
{
switch(PinCode_Mode[playerid])
{
case 1:
{
if(strval(PinCode_Code[playerid]) == /* Переменная аккаунта */[playerid][sec_pass])
{
ShowPlayerPinCode(playerid, 2);
SendClientMessage(playerid,0x15bd48FF,!"Введите новый секретный пароль.");
}
else
{
ShowPlayerPinCode(playerid, 1);
SendClientMessage(playerid, -1, !"Неверный секретный пароль.");
}
}
case 2:
{
if(strlen(PinCode_Code[playerid]) != 6)
{
ShowPlayerPinCode(playerid, 2);
SendClientMessage(playerid, -1, !"Секретный пароль должен содержать 6 цифр.");
return 1;
}
SecretPassTemp[playerid] = strval(PinCode_Code[playerid]);
SendClientMessage(playerid,0x15bd48FF, !"Введите еще раз новый секретный пароль.");
ShowPlayerPinCode(playerid, 3);
}
case 3:
{
if(strval(PinCode_Code[playerid]) != SecretPassTemp[playerid])
{
ShowPlayerPinCode(playerid, 3);
SendClientMessage(playerid, -1, !"Пароли не совпадают, попробуйте еще раз.");
return 1;
}
/* Переменная аккаунта */[playerid][sec_pass] = strval(PinCode_Code[playerid]);
new str[70];
format(str, sizeof str, "Вы установили секретный пароль. Ваш пароль: {FF0000}%s{15bd48}. Запишите его или сделайте скриншот(f8).", PinCode_Code[playerid]);
SendClientMessage(playerid,0x15bd48FF, str);
HidePlayerPinCode(playerid);
/* Сток сохранения аккаунта */(playerid);
SpawnPlayer(playerid);
}
case 4:
{
if(strval(PinCode_Code[playerid]) == /* Переменная аккаунта */[playerid][sec_pass])
{
if(/* Переменная аккаунта */[playerid][sec_pas_status] == 0) // активировать
{
/* Переменная аккаунта */[playerid][sec_pas_status] = 1;
SendClientMessage(playerid,0x15bd48FF, !"Секретный пароль активирован.");
}
else // деактивировать
{
/* Переменная аккаунта */[playerid][sec_pas_status] = 0;
SendClientMessage(playerid,0x15bd48FF, !"Секретный пароль деактивирован.");
}
HidePlayerPinCode(playerid);
}
else
{
ShowPlayerPinCode(playerid, 4);
SendClientMessage(playerid, -1, !"Неверный секретный пароль.");
}
}
case 5:
{
if(strval(PinCode_Code[playerid]) == pInfo[playerid][sec_pass])
{
HidePlayerPinCode(playerid);
SpawnPlayer(playerid);
}
else Kick(playerid);
}
}
}
else if(td == 14)
{
if(PinCode_Mode[playerid] == 5)
{
if(PinCode_Code[playerid][0] != '_')
{
new len = strlen(PinCode_Code[playerid]);
if(len == 1) UpdatePlayerPinCode(playerid, "_");
else if(len > 1)
{
strdel(PinCode_Code[playerid], len, len);
UpdatePlayerPinCode(playerid, PinCode_Code[playerid]);
}
}
else Kick(playerid);
}
else
{
if(PinCode_Code[playerid][0] != '_')
{
new len = strlen(PinCode_Code[playerid]);
if(len == 1) UpdatePlayerPinCode(playerid, "_");
else if(len > 1)
{
strdel(PinCode_Code[playerid], len, len);
UpdatePlayerPinCode(playerid, PinCode_Code[playerid]);
}
}
else HidePlayerPinCode(playerid);
}
}
else
{
if(PinCode_Code[playerid][0] == '_') PinCode_Code[playerid][0] = EOS;
if(strlen(PinCode_Code[playerid]) < 6)
{
format(PinCode_Code[playerid], 8, "%s%i", PinCode_Code[playerid], (td != 13) ? (td-2) : (0));
UpdatePlayerPinCode(playerid, PinCode_Code[playerid]);
}
}
}
}
}
PHP:
PTD_PinCode[playerid] = CreatePlayerTextDraw(playerid, 557.525939, 268.166809, "_");
PlayerTextDrawLetterSize(playerid, PTD_PinCode[playerid], 0.339560, 1.804167);
PlayerTextDrawAlignment(playerid, PTD_PinCode[playerid], 2);
PlayerTextDrawColor(playerid, PTD_PinCode[playerid], -1);
PlayerTextDrawSetShadow(playerid, PTD_PinCode[playerid], 0);
PlayerTextDrawSetOutline(playerid, PTD_PinCode[playerid], 0);
PlayerTextDrawBackgroundColor(playerid, PTD_PinCode[playerid], 255);
PlayerTextDrawFont(playerid, PTD_PinCode[playerid], 2);
PlayerTextDrawSetProportional(playerid, PTD_PinCode[playerid], 1);
PlayerTextDrawSetShadow(playerid, PTD_PinCode[playerid], 0);
PinCode_Code[playerid][0] = EOS;
PinCode_Mode[playerid] = 0;
SecretPassTemp[playerid] = 0;
PHP:
TD_PinCode[0] = TextDrawCreate(515.827758, 257.666656, "box");
TextDrawLetterSize(TD_PinCode[0], 0.000000, 16.231330);
TextDrawTextSize(TD_PinCode[0], 600.000000, 0.000000);
TextDrawAlignment(TD_PinCode[0], 1);
TextDrawColor(TD_PinCode[0], -1);
TextDrawUseBox(TD_PinCode[0], 1);
TextDrawBoxColor(TD_PinCode[0], 505290495);
TextDrawSetShadow(TD_PinCode[0], 0);
TextDrawSetOutline(TD_PinCode[0], 0);
TextDrawBackgroundColor(TD_PinCode[0], 255);
TextDrawFont(TD_PinCode[0], 1);
TextDrawSetProportional(TD_PinCode[0], 1);
TextDrawSetShadow(TD_PinCode[0], 0);
TD_PinCode[1] = TextDrawCreate(515.827514, 257.666625, "box");
TextDrawLetterSize(TD_PinCode[1], 0.000000, 0.114203);
TextDrawTextSize(TD_PinCode[1], 600.000000, 0.000000);
TextDrawAlignment(TD_PinCode[1], 1);
TextDrawColor(TD_PinCode[1], -1);
TextDrawUseBox(TD_PinCode[1], 1);
TextDrawBoxColor(TD_PinCode[1], 1468115967);
TextDrawSetShadow(TD_PinCode[1], 0);
TextDrawSetOutline(TD_PinCode[1], 0);
TextDrawBackgroundColor(TD_PinCode[1], 255);
TextDrawFont(TD_PinCode[1], 1);
TextDrawSetProportional(TD_PinCode[1], 1);
TextDrawSetShadow(TD_PinCode[1], 0);
TD_PinCode[2] = TextDrawCreate(520.512817, 269.916656, "box");
TextDrawLetterSize(TD_PinCode[2], 0.000000, 1.754027);
TextDrawTextSize(TD_PinCode[2], 595.000000, 0.000000);
TextDrawAlignment(TD_PinCode[2], 1);
TextDrawColor(TD_PinCode[2], -1);
TextDrawUseBox(TD_PinCode[2], 1);
TextDrawBoxColor(TD_PinCode[2], 1263225855);
TextDrawSetShadow(TD_PinCode[2], 0);
TextDrawSetOutline(TD_PinCode[2], 0);
TextDrawBackgroundColor(TD_PinCode[2], 255);
TextDrawFont(TD_PinCode[2], 1);
TextDrawSetProportional(TD_PinCode[2], 1);
TextDrawSetShadow(TD_PinCode[2], 0);
new PinCode_Button[12][2] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "_", "0", "_" };
for(new td = 3, Float: x = 530.351684, Float: y = 296.166503; td < 15; td++)
{
TD_PinCode[td] = TextDrawCreate(x, y, PinCode_Button[td-3]);
TextDrawLetterSize(TD_PinCode[td], 0.475899, 1.996665);
TextDrawTextSize(TD_PinCode[td], 19.000000, 19.000000);
TextDrawAlignment(TD_PinCode[td], 2);
TextDrawColor(TD_PinCode[td], -1);
TextDrawUseBox(TD_PinCode[td], 1);
TextDrawBoxColor(TD_PinCode[td], (td == 12) ? (616319231) : ((td == 14) ? (-532331009) : (1263225855)));
TextDrawSetShadow(TD_PinCode[td], 0);
TextDrawSetOutline(TD_PinCode[td], 0);
TextDrawBackgroundColor(TD_PinCode[td], 255);
TextDrawFont(TD_PinCode[td], 2);
TextDrawSetProportional(TD_PinCode[td], 1);
TextDrawSetShadow(TD_PinCode[td], 0);
TextDrawSetSelectable(TD_PinCode[td], true);
if(td == 5 || td == 8 || td == 11) x = 530.351684, y += 28.583344;
else x += 27.642822;
}
PHP:
UpdatePlayerPinCode(playerid, code[])
{
SetString(PinCode_Code[playerid], code);
PlayerTextDrawSetString(playerid, PTD_PinCode[playerid], code);
PlayerTextDrawShow(playerid, PTD_PinCode[playerid]);
return true;
}
ShowPlayerPinCode(playerid, mode_e)
{
PinCode_Mode[playerid] = mode_e;
PinCode_Code[playerid] = "_";
for(new i = 0; i < 15; i++)
{
TextDrawShowForPlayer(playerid, TD_PinCode[i]);
}
PlayerTextDrawSetString(playerid, PTD_PinCode[playerid], "_");
PlayerTextDrawShow(playerid, PTD_PinCode[playerid]);
SelectTextDraw(playerid, 0x01A9DBFF);
return true;
}
HidePlayerPinCode(playerid)
{
PinCode_Mode[playerid] = 0;
PinCode_Code[playerid] = "_";
for(new i = 0; i < 15; i++)
{
TextDrawHideForPlayer(playerid, TD_PinCode[i]);
}
PlayerTextDrawHide(playerid, PTD_PinCode[playerid]);
CancelSelectTextDraw(playerid);
return true;
}
stock SetString(string[],new_string[],size = 200)
{
strmid(string,new_string, 0, strlen(new_string), size);
}
PHP:
if(pInfo[playerid][sec_pass] != 0 && pInfo[playerid][sec_pas_status] == 1)
{
ShowPlayerPinCode(playerid, 5);
SendClientMessage(playerid,0x15bd48FF, !"Введите Ваш текущий секретный пароль.");
}
else
{
ShowPlayerPinCode(playerid, 2);
SendClientMessage(playerid,0x15bd48FF, !"Введите новый секретный пароль.");
}
PHP:
SpawnPlayer(playerid);
Теперь сделаем сохранение pin-code(MySQL r39-4), идем в паблик загрузки аккаунта.
PHP:
/* Переменная аккаунта */[playerid][sec_pass] = cache_get_field_content_int(0, "sec_pass", mysql_id);
/* Переменная аккаунта */[playerid][sec_pas_status] = cache_get_field_content_int(0, "sec_pas_status", mysql_id);
В конец добавляем:
PHP:
, `sec_pass` = '%d', `sec_pas_status` = '%d'
PHP:
, /* Переменная аккаунта */[playerid][sec_pass], /* Переменная аккаунта */[playerid][sec_pas_status],
PHP:
SaveAccount(playerid)
{
static
query [] = "UPDATE `accounts` SET `level` = '%d', `sec_pass` = '%d', `sec_pas_status` = '%d' WHERE `id` = '%d'";
new str_query[sizeof(query) - 20 + 100];
format(str_query, sizeof(str_query), query, pInfo[playerid][level], pInfo[playerid][sec_pass], pInfo[playerid][sec_pas_status], pInfo[playerid][id]);
mysql_function_query(mysql_id, str_query, false, "", "");
return true;
}
Теперь расскажу как сделать смену pin-code:
Для этого, в вашу систему с настройками Безопасности добавьте:
PHP:
if(/* Переменная аккаунта */[playerid][sec_pass] != 0)
{
ShowPlayerPinCode(playerid, 1);
SendClientMessage(playerid,0x15bd48FF, !"Введите Ваш текущий секретный пароль.");
}
else
{
ShowPlayerPinCode(playerid, 2);
SendClientMessage(playerid,0x15bd48FF, !"Введите новый секретный пароль.");
}
Последнее редактирование:
