- Регистрация
- 16 Сен 2017
- Сообщения
- 1,327
- Лучшие ответы
- 0
- Репутация
- 241
Привет!
Ловите систему captch'i.
Textdraw каптчи:
Редактор, в котором я делал каптчу:
Исходник каптчи (для этого редактора):
Начнем:
Вариант оптимизации от ihNNNNNify:
Ловите систему captch'i.
- Сама каптча на TD.
- Разброс букв и размер Вы можете сделать сами, но делайте все в правильном порядке: с лево, на право. Сами буквы и числа определяются кодом.
- Чтобы вшить Ваши символы в функцию, используйте пример, данный в ней.
- Чтобы создать каптчу игроку, используйте CreateCaptchaForPlayer. Чтобы удалить - DestroyCaptchaForPlayer.
Textdraw каптчи:
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
.Редактор, в котором я делал каптчу:
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
.Исходник каптчи (для этого редактора):
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
Чтобы видеть скрытое содержание Зарегистрируйтесь на форуме!
.Начнем:
PHP:
// Начало мода
new
Text: Captcha_TD[10], // Textdraw по ссылке ниже
PlayerText: Captcha_PTD[MAX_PLAYERS][6],
PlayerCaptcha[MAX_PLAYERS][7];
#define dialog_captcha 1024
// Конец мода
CreateCaptchaForPlayer(playerid, dialogid)
{
format(PlayerCaptcha[playerid], 7, "");
new
captcha_mes[6],
captcha_random = random(2);
static const
Float: captcha_pos[][][] =
{
{
{ 284.0000, 123.0000 },
{ 291.0000, 129.0000 },
{ 298.5999, 118.0999 },
{ 323.0000, 132.0000 },
{ 329.0000, 141.0000 },
{ 333.0000, 123.0000 }
},
{
{ 277.0000, 123.0000 },
{ 281.0000, 125.0000 },
{ 288.0000, 122.0000 },
{ 303.0000, 133.0000 },
{ 308.0000, 131.0000 },
{ 311.0000, 136.0000 }
}
// Пример, чтобы добавить свои координаты CreatePlayerTextDraw:
/*
{ // Создаем новую секцию (это другой вариант выставления букв)
{ CreatePlayerTextDraw } // Создаем новую подсекцию в новой секции: эта 1 буква
}
*/
},
Float: captcha_letter[][][] =
{
{
{ 0.2415, 2.1537 },
{ 0.4750, 2.5333 },
{ 0.3390, 2.0480 },
{ 0.2355, 1.3760 },
{ 0.3725, 1.8364 },
{ 0.2339, 2.4400 }
},
{
{ 0.2415, 2.1537 },
{ 0.4750, 2.5333 },
{ 0.3390, 2.0480 },
{ 0.2355, 1.3760 },
{ 0.3725, 1.8364 },
{ 0.2339, 2.4400 }
}
// Пример, чтобы добавить свои координаты PlayerTextDrawLetterSize:
/*
{ // Создаем новую секцию (это другой вариант выставления букв)
{ PlayerTextDrawLetterSize } // Создаем новую подсекцию в новой секции (это первая буква)
}
*/
},
big_letters[][] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" },
small_letters[][] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" },
numbers[][] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
for(new i; i < 10; i ++) TextDrawShowForPlayer(playerid, Captcha_TD[i]);
for(new i; i < 6; i ++)
{
switch(random(3))
{
case 0: strmid(captcha_mes[i], big_letters[random(26)], 0, strlen(big_letters[random(26)]), 2);
case 1: strmid(captcha_mes[i], small_letters[random(26)], 0, strlen(small_letters[random(26)]), 2);
case 2: strmid(captcha_mes[i], numbers[random(10)], 0, strlen(numbers[random(10)]), 2);
}
Captcha_PTD[playerid][i] = CreatePlayerTextDraw(playerid, captcha_pos[captcha_random][i][0], captcha_pos[captcha_random][i][1], captcha_mes[i]);
PlayerTextDrawLetterSize(playerid, Captcha_PTD[playerid][i], captcha_letter[captcha_random][i][0], captcha_letter[captcha_random][i][1]);
PlayerTextDrawAlignment(playerid, Captcha_PTD[playerid][i], 1);
PlayerTextDrawColor(playerid, Captcha_PTD[playerid][i], -1);
PlayerTextDrawFont(playerid, Captcha_PTD[playerid][i], 1);
PlayerTextDrawSetProportional(playerid, Captcha_PTD[playerid][i], 1);
PlayerTextDrawSetShadow(playerid, Captcha_PTD[playerid][i], 0);
PlayerTextDrawShow(playerid, Captcha_PTD[playerid][i]);
strcat(PlayerCaptcha[playerid], captcha_mes[i]);
}
ShowPlayerDialog(playerid, dialogid, 1, "Captcha", "Введите сюда то, что видите на экране:", "Ввел", "Закрыть");
return true;
}
DestroyCaptchaForPlayer(playerid)
{
for(new i; i < 10; i ++) TextDrawHideForPlayer(playerid, Captcha_TD[i]);
for(new i; i < 6; i ++) PlayerTextDrawDestroy(playerid, Captcha_PTD[playerid][i]);
return true;
}
// OnPlayerDialogResponse
case dialog_captcha:
{
DestroyCaptchaForPlayer(playerid);
if(!response)return true;
if(!strcmp(inputtext, PlayerCaptcha[playerid], false))
{
SendClientMessage(playerid, -1, "Вы правильно ввели капчу!");
// Сюда вставляется код, если каптча введена правильно
}
else SendClientMessage(playerid, -1, "Вы не правильно ввели капчу!");
}
Вариант оптимизации от ihNNNNNify:
PHP:
// В CreateCaptchaForPlayer заменить
big_letters[][] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" },
small_letters[][] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" },
numbers[][] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
// на...
chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
// Там же, заменить
switch(random(3))
{
case 0: strmid(captcha_mes[i], big_letters[random(26)], 0, strlen(big_letters[random(26)]), 2);
case 1: strmid(captcha_mes[i], small_letters[random(26)], 0, strlen(small_letters[random(26)]), 2);
case 2: strmid(captcha_mes[i], numbers[random(10)], 0, strlen(numbers[random(10)]), 2);
}
// на...
strmid(captcha_mes[i], chrs[random(63)], 0, strlen(chrs[random(63)]), 2);
Последнее редактирование: