Вопросы

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

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


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

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

  • 0

@tivan666ban , а разве для этих целей не кастомизированные диалоговые окна использовали?

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


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

@tivan666ban playertextdrawsetstring + showplayerdialog

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


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

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

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


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

Можете для этого использовать 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

@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 пользователей онлайн

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

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

    • Sten Developer
      От Sten Developer
      Объясню всю ситуацию, пишу систему смерти игрока но она не работает. Решил по приколу написать туда обычный вывод текста SCM(playerid, COLOR_RED, "Вы умерли");
      Но однако после смерти текст не выводиться. Не работает абсолютно все. Кто знает как решить эту проблему?