Вопросы

tivan666ban
Активный

Подскажите, пожалуйста, как в Pawn/SAMP реализовать возможность вводить текст в TextDraw при нажатии на него?

Поделиться сообщением


Ссылка на сообщение

5 ответов на этот вопрос

  • 0
tivan666ban
Активный

@Cawfee Я хотел бы систему, которая используется на успешных проектах, таких как Radmir RP CRMP

Поделиться сообщением


Ссылка на сообщение
  • 0
sinvays
Завсегдатый

Можете для этого использовать TextDrawSetString и настроить его так чтобы при нажатии на него можно менять текст. Используй диалоговое окно для обработки текста, можешь использовать пример ниже:

 

Создаёте new:

 

new Text:MyTextDraw;

 

Создаёте Текстдрав и вставляете в любое удобное место


 

    MyTextDraw = TextDrawCreate(320.0240.0"Click me to enter text");
    TextDrawBackgroundColor(MyTextDraw, 0x000000FF);
    TextDrawFont(MyTextDraw, 3);
    TextDrawLetterSize(MyTextDraw, 0.51.0);
    TextDrawColor(MyTextDraw, 0xFFFFFFFF);
    TextDrawSetProportional(MyTextDraw, 1);
    TextDrawSetSelectable(MyTextDraw, 1);
    TextDrawShowForAll(MyTextDraw);

 

Ну и делаете например если он нажмёт по текстдраву, он будет открывать диалог.

 

#define DIALOG_INPUT 1

public OnPlayerClickTextDraw(playerid, clickedid)
{
    if(clickedid == MyTextDraw)
    {
        ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT, "TextDraw""Введите ваш текст:""""Submit""Cancel");
    }
    return 1;
}

 

И обрабатываете текст:

 

#define DIALOG_INPUT 1

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_INPUT)
    {
        if(response)
        {
            TextDrawSetString(MyTextDraw, inputtext);
            TextDrawShowForAll(MyTextDraw);
        }
    }
    return 1;
}

 

Не забывайте что это только пример кода вам может понадобиться настроить параметры в зависимости от ваших нужд.


 

Отредактировано пользователем angel_sinvays

Поделиться сообщением


Ссылка на сообщение
  • 0
tivan666ban
Активный

@angel_sinvays  ошибка 

Спойлер

warning 202: number of arguments does not match definition

Спойлер

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <a_actor>
#include <a_http>
#include <a_npc>
#include <a_objects>
#include <a_players>
#include <a_sampdb>
#include <a_vehicles>
#include <core>
#include <crashdetect>
#include <datagram>
#include <file>
#include <float>
#include <mxini>
#include <string>
#include <time>
#include <a_mysql>
#include <crp>

new Text:Textdraw0;
new MySQL:dbHandle;
new Text:registracia0;
new Text:registracia1;
new Text:registracia2;
new Text:registracia3;
new Text:registracia4;
new Text:registracia5;
new Text:registracia6;
new Text:registracia7;
new Text:vhod0;
new Text:vhod1;
new Text:vhod2;
new Text:vhod3;
new MySQL: g_connection_db;

#define Host "127.0.0.1"
#define User "root" // это если вы используете Denwer. Если хостинг указываете другого пользователя.
#define DataBase "samp"
#define Password_SQL ""//Если вы на хостинге ставите пароль,для Denwer пароль не требуется, чуть позже скажу как его установить

#define DIALOG_INPUT 1

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, -2245.43901825.968653.465137.0911000000);
    Textdraw0 = TextDrawCreate(527.200073407.680053"Navit Rp");
    TextDrawLetterSize(Textdraw0, 0.5859993.660799);
    TextDrawTextSize(Textdraw0, -18.39999910.453330);
    TextDrawAlignment(Textdraw0, 1);
    TextDrawColor(Textdraw0, 65535);
    TextDrawSetShadow(Textdraw0, 0);
    TextDrawSetOutline(Textdraw0, 0);
    TextDrawBackgroundColor(Textdraw0, -2139062017);
    TextDrawFont(Textdraw0, 2);
    TextDrawSetProportional(Textdraw0, 1);
    dbHandle = mysql_connect(Host,User,Password_SQL,DataBase);// В R41 поменялись местами Пароль и База
    dbHandle = mysql_connect(Host,User,DataBase,Password_SQL);
    if(mysql_errno())
    {
        printf("Подключение к базе данных %s не удалось.",DataBase); // %s означает строку. То есть будет выводить название базы данных которое указано в #define DataBase
    }
    else
    {
        printf("Подключение к базе данных %s успешно",DataBase);
    }
    registracia0 = TextDrawCreate(492.000000145.599975"Ведите пароль");
    TextDrawLetterSize(registracia0, 0.5680473.421439);
    TextDrawAlignment(registracia0, 1);
    TextDrawColor(registracia0, -65281);
    TextDrawSetShadow(registracia0, 0);
    TextDrawSetOutline(registracia0, 1);
    TextDrawBackgroundColor(registracia0, 51);
    TextDrawFont(registracia0, 1);
    TextDrawSetProportional(registracia0, 1);

    registracia1 = TextDrawCreate(641.199951187.419998"usebox");
    TextDrawLetterSize(registracia1, 0.0000002.504074);
    TextDrawTextSize(registracia1, 490.7999870.000000);
    TextDrawAlignment(registracia1, 1);
    TextDrawColor(registracia1, 0);
    TextDrawUseBox(registracia1, true);
    TextDrawBoxColor(registracia1, 102);
    TextDrawSetShadow(registracia1, 0);
    TextDrawSetOutline(registracia1, 0);
    TextDrawFont(registracia1, 0);

    registracia0 = TextDrawCreate(492.000000145.599975"Ведите пароль");
    TextDrawLetterSize(registracia0, 0.5680473.421439);
    TextDrawAlignment(registracia0, 1);
    TextDrawColor(registracia0, -65281);
    TextDrawSetShadow(registracia0, 0);
    TextDrawSetOutline(registracia0, 1);
    TextDrawBackgroundColor(registracia0, 51);
    TextDrawFont(registracia0, 1);
    TextDrawSetProportional(registracia0, 1);

    registracia1 = TextDrawCreate(641.199951187.419998"usebox");
    TextDrawLetterSize(registracia1, 0.0000002.504074);
    TextDrawTextSize(registracia1, 490.7999870.000000);
    TextDrawAlignment(registracia1, 1);
    TextDrawColor(registracia1, 0);
    TextDrawUseBox(registracia1, true);
    TextDrawBoxColor(registracia1, 102);
    TextDrawSetShadow(registracia1, 0);
    TextDrawSetOutline(registracia1, 0);
    TextDrawFont(registracia1, 0);

    registracia2 = TextDrawCreate(496.000152218.026687"муж");
    TextDrawLetterSize(registracia2, 0.4499991.600000);
    TextDrawAlignment(registracia2, 1);
    TextDrawColor(registracia2, -65281);
    TextDrawSetShadow(registracia2, 0);
    TextDrawSetOutline(registracia2, 1);
    TextDrawBackgroundColor(registracia2, 51);
    TextDrawFont(registracia2, 1);
    TextDrawSetProportional(registracia2, 1);

    registracia3 = TextDrawCreate(529.200012235.206665"usebox");
    TextDrawLetterSize(registracia3, 0.0000002.089259);
    TextDrawTextSize(registracia3, 494.7999870.000000);
    TextDrawAlignment(registracia3, 1);
    TextDrawColor(registracia3, 0);
    TextDrawUseBox(registracia3, true);
    TextDrawBoxColor(registracia3, 102);
    TextDrawSetShadow(registracia3, 0);
    TextDrawSetOutline(registracia3, 0);
    TextDrawFont(registracia3, 0);

    registracia4 = TextDrawCreate(591.999755221.760009"жен");
    TextDrawLetterSize(registracia4, 0.4499991.600000);
    TextDrawAlignment(registracia4, 1);
    TextDrawColor(registracia4, -65281);
    TextDrawSetShadow(registracia4, 0);
    TextDrawSetOutline(registracia4, 1);
    TextDrawBackgroundColor(registracia4, 51);
    TextDrawFont(registracia4, 1);
    TextDrawSetProportional(registracia4, 1);

    registracia5 = TextDrawCreate(619.599975238.939987"usebox");
    TextDrawLetterSize(registracia5, 0.0000002.089259);
    TextDrawTextSize(registracia5, 588.4000240.000000);
    TextDrawAlignment(registracia5, 1);
    TextDrawColor(registracia5, 0);
    TextDrawUseBox(registracia5, true);
    TextDrawBoxColor(registracia5, 102);
    TextDrawSetShadow(registracia5, 0);
    TextDrawSetOutline(registracia5, 0);
    TextDrawFont(registracia5, 0);

    registracia6 = TextDrawCreate(638.000000271.046691"usebox");
    TextDrawLetterSize(registracia6, 0.0000002.587036);
    TextDrawTextSize(registracia6, 495.5999750.000000);
    TextDrawAlignment(registracia6, 1);
    TextDrawColor(registracia6, 0);
    TextDrawUseBox(registracia6, true);
    TextDrawBoxColor(registracia6, 102);
    TextDrawSetShadow(registracia6, 0);
    TextDrawSetOutline(registracia6, 0);
    TextDrawFont(registracia6, 0);

    registracia7 = TextDrawCreate(542.400024274.026580"играть");
    TextDrawLetterSize(registracia7, 0.4499991.600000);
    TextDrawAlignment(registracia7, 1);
    TextDrawColor(registracia7, -65281);
    TextDrawSetShadow(registracia7, 0);
    TextDrawSetOutline(registracia7, 1);
    TextDrawBackgroundColor(registracia7, 51);
    TextDrawFont(registracia7, 1);
    TextDrawSetProportional(registracia7, 1);


    vhod0 = TextDrawCreate(492.000000145.599975"Ведите пароль");
    TextDrawLetterSize(vhod0, 0.5680473.421439);
    TextDrawAlignment(vhod0, 1);
    TextDrawColor(vhod0, -65281);
    TextDrawSetShadow(vhod0, 0);
    TextDrawSetOutline(vhod0, 1);
    TextDrawBackgroundColor(vhod0, 51);
    TextDrawFont(vhod0, 1);
    TextDrawSetProportional(vhod0, 1);

    vhod1 = TextDrawCreate(641.199951187.419998"usebox");
    TextDrawLetterSize(vhod1, 0.0000002.504074);
    TextDrawTextSize(vhod1, 490.7999870.000000);
    TextDrawAlignment(vhod1, 1);
    TextDrawColor(vhod1, 0);
    TextDrawUseBox(vhod1, true);
    TextDrawBoxColor(vhod1, 102);
    TextDrawSetShadow(vhod1, 0);
    TextDrawSetOutline(vhod1, 0);
    TextDrawFont(vhod1, 0);


    vhod2 = TextDrawCreate(638.000000271.046691"usebox");
    TextDrawLetterSize(vhod2, 0.0000002.587036);
    TextDrawTextSize(vhod2, 495.5999750.000000);
    TextDrawAlignment(vhod2, 1);
    TextDrawColor(vhod2, 0);
    TextDrawUseBox(vhod2, true);
    TextDrawBoxColor(vhod2, 102);
    TextDrawSetShadow(vhod2, 0);
    TextDrawSetOutline(vhod2, 0);
    TextDrawFont(vhod2, 0);

    vhod3 = TextDrawCreate(542.400024274.026580"играть");
    TextDrawLetterSize(vhod3, 0.4499991.600000);
    TextDrawAlignment(vhod3, 1);
    TextDrawColor(vhod3, -65281);
    TextDrawSetShadow(vhod3, 0);
    TextDrawSetOutline(vhod3, 1);
    TextDrawBackgroundColor(vhod3, 51);
    TextDrawFont(vhod3, 1);
    TextDrawSetProportional(vhod3, 1);
    return 1;
}

public OnGameModeExit()
{
    mysql_close(dbHandle);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, -2245.43901825.968653.4651);
    SetPlayerCameraPos(playerid, -2245.43901825.968653.4651);
    SetPlayerCameraLookAt(playerid, -2245.43901825.968653.4651);
    return 1;
}

public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid,Textdraw0);
    TextDrawShowForPlayer(playerid,registracia0);
    TextDrawShowForPlayer(playerid,registracia1);
    TextDrawShowForPlayer(playerid,registracia2);
    TextDrawShowForPlayer(playerid,registracia3);
    TextDrawShowForPlayer(playerid,registracia4);
    TextDrawShowForPlayer(playerid,registracia5);
    TextDrawShowForPlayer(playerid,registracia6);
    TextDrawShowForPlayer(playerid,registracia7);
    TextDrawShowForPlayer(playerid,vhod0);
    TextDrawShowForPlayer(playerid,vhod1);
    TextDrawShowForPlayer(playerid,vhod2);
    TextDrawShowForPlayer(playerid,vhod3);
    RemoveBuildingForPlayer(playerid, 6471958.7900, -2615.939910.00000.25);
    RemoveBuildingForPlayer(playerid, 6471954.1700, -2617.870110.00000.25);
    RemoveBuildingForPlayer(playerid, 6471958.0800, -2620.379910.00000.25);
    RemoveBuildingForPlayer(playerid, 6471953.3700, -2621.379910.00000.25);
    RemoveBuildingForPlayer(playerid, 6471957.4301, -2624.600110.00000.25);
    RemoveBuildingForPlayer(playerid, 6471953.1400, -2625.610110.00000.25);
    RemoveBuildingForPlayer(playerid, 6461956.9700, -2618.36019.99980.25);
    RemoveBuildingForPlayer(playerid, 6461952.8500, -2616.90999.99980.25);
    RemoveBuildingForPlayer(playerid, 6461953.0400, -2619.87999.99980.25);
    RemoveBuildingForPlayer(playerid, 6461954.8101, -2623.61019.99980.25);
    RemoveBuildingForPlayer(playerid, 6461957.0900, -2626.62019.99980.25);
    RemoveBuildingForPlayer(playerid, 6461957.6500, -2621.93999.99980.25);
    RemoveBuildingForPlayer(playerid, 17601955.8300, -2620.159910.00000.25);
    RemoveBuildingForPlayer(playerid, 17601956.9800, -2616.679910.00000.25);
    RemoveBuildingForPlayer(playerid, 17601953.3600, -2623.629910.00000.25);
    RemoveBuildingForPlayer(playerid, 17601956.1899, -2625.210010.00000.25);
    RemoveBuildingForPlayer(playerid, 17601956.8400, -2622.740010.00000.25);
    RemoveBuildingForPlayer(playerid, 17111955.2900, -2625.500015.60000.25);
    RemoveBuildingForPlayer(playerid, 17111957.4000, -2618.860115.60000.25);
    RemoveBuildingForPlayer(playerid, 24052011.0900, -2603.88999.80240.25);
    RemoveBuildingForPlayer(playerid, 24062011.0900, -2603.88999.80240.25);
    RemoveBuildingForPlayer(playerid, 24272068.1299, -2631.889910.01000.25);
    RemoveBuildingForPlayer(playerid, 24332068.1299, -2631.889910.01000.25);
    RemoveBuildingForPlayer(playerid, 17881973.1100, -2610.330122.78000.25);
    RemoveBuildingForPlayer(playerid, 17861973.1100, -2610.330112.90000.25);
    RemoveBuildingForPlayer(playerid, 17861973.1100, -2610.33012.98000.25);
    RemoveBuildingForPlayer(playerid, 17881973.5800, -2609.129925.80000.25);
    CreateObject(6000, -2234.001832.4061.00,   0.000.0030.00);
    static const fmt_str[] = "SELECT * FROM `table_accounts` WHERE `name` = '%s' LIMIT 1";
    new query[sizeof(fmt_str) + MAX_PLAYER_NAME + 2 + 1], player_name[MAX_PLAYERS][MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, player_name[playerid], MAX_PLAYER_NAME+1);
    format(query, sizeof query, fmt_str, player_name[playerid]);
    mysql_tquery(g_connection_db, query, "FindPlayerInTable""i", playerid);
    new rows;
    cache_get_row_count(rows);
    if(!rows) //если аккаунт не найден
    {

    }
    else //иначе
    {

    }
    return 1;
}

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, true10) == 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)
{
    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[])
{
    if(dialogid == DIALOG_INPUT)
    {
        if(response)
        {
            TextDrawSetString(registracia1, inputtext);
            TextDrawShowForAll(registracia1);
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(clickedid == registracia1)
    {
        ShowPlayerDialog(playerid, DIALOG_INPUT, DIALOG_STYLE_INPUT, "TextDraw""Введите ваш текст:""""Submit""Cancel");
    }
    return 1;
}

 

 

Поделиться сообщением


Ссылка на сообщение
Гость
Эта тема закрыта для публикации ответов.
  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

  • Похожий контент

    • Дебилойд
      От Дебилойд
      Здравствуйте!
      Мы ищем талантливого 3D-моделлера в команду нашего CRMP-проекта!
      Что нужно будет делать:
      Моделировать и адаптировать автомобили.
      Создавать и настраивать скины (модели персонажей).
      Большим плюсом будет:
      Умение создавать качественные и оптимизированные интерьеры.
      Если вы хотите стать частью нашей команды и развивать проект вместе с нами, пишите в ЛС. Ждем ваши портфолио!
    • LORDIKUS
      От LORDIKUS
      Уважаемые участники форума - всех приветствую, кто перешел в беседу моей темы обсуждения. В настоящее время у меня зарождается огромное желание и мысль создать собственный CR:MP проект, но столкнулся с единственной проблемой - с отсутствием команды людей, у которых будет искреннее желание ежедневно вкладывать свой труд на разработку проекта. Особого опыта в скриптинге, маппинге, дизайне или в моделировании у меня не имеется, поэтому такой критерий как опыт в определенной сфере для желающих вступить в команду я не рассматриваю. Так как проект не открыт и находится на начальной стадии создания, мое сотрудничество выстраивается на некоммерческой основе (без выплаты за проделанную работу и труд), однако я не собираюсь отрицать высокую ценность вложенного командой труд — труд, особенно на первой стадии разработки я рассматриваю превыше всего. После открытия проекта в зависимости от коммерции и чистой прибыли каждый участник будет получать настоящую выплату, однако это также может убить еще значительное время. Мне нужна команда, которая проявит искренний интерес в создании общего между командой CR:MP проекта, пожертвует свое время, а также вложит собственный труд благодаря заработанным навыкам. Если вас заинтересовала данная тема обсуждения, пожалуйста, свяжитесь со мной по любым возможным и удобным для вас контактам связи ниже. Спасибо всем, кто зашел в мою беседу!

      🔗 Спец. Связь:
      — DISCORD: https://discord.com/users/1452715348196589691 (перейти по ссылке и добавить в друзья) ИЛИ _shin833_ (ввести никнейм и отправить запрос дружбы)
      — VK: https://vk.com/shin833
      — TG: https://t.me/s_hin833
    • Korochansky
      От Korochansky
      Настало время объявить о скором выпуске первого релиза среды разработки под названием Spawn.

      В настоящее время программа находится на заключительных этапах доработки кода и локализации интерфейса.
      Таким образом, в течение следующей недели будет выпущена быстрая и современная среда разработки, обладающая следующими возможностями (о которых я расскажу сейчас, а о других — позже):
       
      Полнофункциональный локальный Git: 
      Индексирование, фиксации, индикаторы состояния и мягкий/жесткий сброс до любой точки сохранения одним щелчком мыши. Разрабатывайте свой игровой сервер, не боясь его сломать.
      Новички могут рассматривать это как историю кодовой базы вашего сервера (что и есть на самом деле).
       
      Чистый UTF-8 (без BOM): 
      Полный отказ от устаревшей кодировки Windows-1251 (CP1251) для абсолютной стабильности и идеальной совместимости с Git.
      Реализация поддержки CP1251 привела бы к нестабильному поведению программы и ухудшила бы пользовательский опыт.
       
      История изменений строк: Редактор выделяет измененные строки в реальном времени в полях рядом с номерами строк. Это позволяет мгновенно видеть границы изменений, внесенных с момента открытия файла.
       
      Сопоставление и выделение фигурных скобок: мгновенное выделение открывающих и закрывающих фигурных скобок для быстрой навигации по структуре кода и защиты от ошибок компиляции.
       
      Интеграция с SAMPCTL: готовая к использованию автоматизация процессов. Сборка, запуск сервера и менеджер зависимостей (управление библиотеками и плагинами) работают напрямую из интерфейса редактора.
       
      И многое другое...
       
      И самое главное: проект будет с открытым исходным кодом под лицензией GPLv3!
      Следите за новостями о выпуске в репозитории: https://github.com/daniilkorochansky/spawn
    • KodBi
      От KodBi
      шапка
      по одиночке работают
      нужны оба