Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dof2>
- #include <zcmd>
- #if !defined MAX_TEXT
- #define MAX_TEXT ( 99 )
- #endif
- #if !defined MAX_STRING
- #define MAX_STRING ( 1024 )
- #endif
- #define FileLoad "3DTexts/%d.ini"
- #define cPadrao 0xE9433FFF
- #define DIALOG_MAKE_LABEL 777
- #define DIALOG_MAKE_LABEL1 778
- #define DIALOG_MAKE_LABEL2 779
- #define DIALOG_MAKE_LABEL3 800
- #define DIALOG_MAKE_LABEL4 801
- #define DIALOG_EDIT_LABEL 802
- #define DIALOG_EDIT_LABELDESC 803
- #define DIALOG_EDIT_LABELDIST 804
- #define DIALOG_EDIT_LABELCOR 805
- new dStr[500];
- enum Params
- {
- Float:X,
- Float:Y,
- Float:Z,
- Float:DD,
- Text[128],
- VirtualW,
- bool:Loaded
- };
- new TextInfo[MAX_TEXT][Params];
- new Text3D:label[MAX_TEXT];
- new labelid[MAX_PLAYERS],
- Float: nX[MAX_PLAYERS],
- Float: nZ[MAX_PLAYERS],
- Float: nY[MAX_PLAYERS],
- nDD[MAX_PLAYERS],
- nText[MAX_PLAYERS][128],
- nColor[MAX_PLAYERS][128],
- bool:Editando[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- LoadTexts();
- return 1;
- }
- public OnFilterScriptExit()
- {
- UnLoadSaveTexts();
- return 1;
- }
- CMD:makelabel(playerid)
- {
- if ( !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, cPadrao, "Você não tem permissão para isso.");
- new Str[500];
- GetPlayerPos(playerid, nX[playerid], nY[playerid], nZ[playerid]);
- format ( Str, sizeof ( Str ), "{FFFFFF}Olá, bem vindo ao assiste de 3DLabel\n\nPos X: {E9433F}%f\n{FFFFFF}Pos Y: {E9433F}%f\n{FFFFFF}Pos Z: {E9433F}%f\n\n{FFFFFF}Deseja criar uma label neste local ?", nX, nY, nZ);
- ShowPlayerDialog(playerid, DIALOG_MAKE_LABEL, DIALOG_STYLE_MSGBOX, "{FFFFFF}Label Create", Str, "Sim", "Não");
- return 1;
- }
- CMD:editlabel(playerid)
- {
- for ( new t; t < MAX_TEXT; t++)
- {
- if ( TextInfo[t][Loaded] == true)
- {
- if ( IsPlayerInRangeOfPoint(playerid, 1.0, TextInfo[t][X], TextInfo[t][Y], TextInfo[t][Z]))
- {
- ShowPlayerDialog(playerid, DIALOG_EDIT_LABEL, DIALOG_STYLE_LIST, "{FFFFFF}Edit Label", "{FFFFFF}- Deletar\n- Alterar Texto\n- Alterar Distância\n- Alterar Cor\n- Alterar Posição", "Selecionar", "Sair");
- labelid[playerid] = t;
- }
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if ( dialogid == DIALOG_MAKE_LABEL)
- {
- if ( response )
- {
- ShowPlayerDialog(playerid, DIALOG_MAKE_LABEL1, DIALOG_STYLE_INPUT, "{FFFFFF}Label Create", "{FFFFFF}Vamos em frente!\n\nPor favor, nos informe o texto a ser exibido:", "Proximo", "Sair");
- }
- else
- {
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- if ( dialogid == DIALOG_MAKE_LABEL1)
- {
- if ( response )
- {
- new deStr[MAX_STRING];
- format ( nText[playerid], 128, "%s" ,inputtext);
- format ( deStr, MAX_STRING, "{FFFFFF}Precesso Atual:\n\nTexto: {E9433F}%s{FFFFFF}\n\n Agora nos informe uma distancia para a label ser exibida:", nText[playerid]);
- ShowPlayerDialog(playerid, DIALOG_MAKE_LABEL2, DIALOG_STYLE_INPUT, "{FFFFFF}Label Create", deStr, "Proximo", "Sair");
- }
- else
- {
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- if ( dialogid == DIALOG_MAKE_LABEL2)
- {
- if ( response )
- {
- new deStr[MAX_STRING];
- nDD[playerid] = strval(inputtext);
- format ( deStr, MAX_STRING, "{FFFFFF}Precesso Atual:\n\nTexto: {E9433F}%s\n{FFFFFF}Distância: {E9433F}%d{E9433F}\n\n Insira uma cor:", nText[playerid], nDD[playerid]);
- ShowPlayerDialog(playerid, DIALOG_MAKE_LABEL3, DIALOG_STYLE_INPUT, "{FFFFFF}Label Create", deStr, "Proximo", "Sair");
- }
- else
- {
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- if ( dialogid == DIALOG_MAKE_LABEL3)
- {
- if ( response )
- {
- new deStr[MAX_STRING];
- format ( nColor[playerid], 128, "%s", inputtext);
- format ( deStr, MAX_STRING, "{FFFFFF}Precesso Atual:\n\nTexto: {E9433F}%s\n{FFFFFF}Distância: {E9433F}%d{FFFFFF}\nCor: {E9433F}%s{FFFFFF}\n\n Deseja criar ?", nText[playerid], nDD[playerid], nColor[playerid]);
- ShowPlayerDialog(playerid, DIALOG_MAKE_LABEL4, DIALOG_STYLE_MSGBOX, "{FFFFFF}Label Create", deStr, "Criar", "Sair");
- }
- else
- {
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- if ( dialogid == DIALOG_MAKE_LABEL4)
- {
- if ( response )
- {
- Make3DText(nText[playerid], nColor[playerid], nX[playerid], nY[playerid], nZ[playerid], nDD[playerid], 0);
- }
- else
- {
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- if ( dialogid == DIALOG_EDIT_LABEL)
- {
- if ( response )
- {
- if ( listitem == 0 )
- {
- new deStr[128], lid = labelid[playerid];
- format ( deStr, 128, FileLoad, lid);
- TextInfo[lid][Loaded] = false;
- DOF2::RemoveFile(deStr);
- Delete3DTextLabel(label[lid]);
- UnLoadSaveTexts();
- LoadTexts();
- }
- if ( listitem == 1 )
- {
- new deStr[MAX_STRING], lid = labelid[playerid];
- format ( deStr, MAX_STRING, "Descrição atual: {E9433F}%s{FFFFFF}\n\nInsira uma nova descrição:", TextInfo[lid][Text]);
- ShowPlayerDialog(playerid, DIALOG_EDIT_LABELDESC, DIALOG_STYLE_INPUT, "Edit Label", deStr, "Editar", "Sair");
- }
- if ( listitem == 2 )
- {
- new xStr[128], deStr[MAX_STRING], lid = labelid[playerid];
- format (xStr, 128, FileLoad, lid);
- format ( deStr, MAX_STRING, "Distância atual: %s\n\nInsira uma nova distãncia:", DOF2::GetString(xStr, "TEXT3D_DrawDistance"));
- ShowPlayerDialog(playerid, DIALOG_EDIT_LABELDIST, DIALOG_STYLE_INPUT, "Edit Label", deStr, "Editar", "Sair");
- }
- if ( listitem == 3 )
- {
- new xStr[128], deStr[MAX_STRING], lid = labelid[playerid];
- format (xStr, 128, FileLoad, lid);
- format ( deStr, MAX_STRING, "Cor atual: %s\n\nInsira uma nova cor:", DOF2::GetString(xStr, "TEXT3D_COLOR"));
- ShowPlayerDialog(playerid, DIALOG_EDIT_LABELCOR, DIALOG_STYLE_INPUT, "Edit Label", deStr, "Editar", "Sair");
- }
- if ( listitem == 4 )
- {
- SendClientMessage(playerid, cPadrao, "Dirija-se ao novo local e pressione ' y '");
- Editando[playerid] = true;
- }
- }
- else
- {
- labelid[playerid] = INVALID_3DTEXT_ID;
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- if ( dialogid == DIALOG_EDIT_LABELDESC)
- {
- if ( response )
- {
- new lid = labelid[playerid];
- format ( TextInfo[lid][Text], 128, "%s", inputtext);
- UnLoadSaveTexts();
- LoadTexts();
- }
- else
- {
- labelid[playerid] = INVALID_3DTEXT_ID;
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- if ( dialogid == DIALOG_EDIT_LABELDIST)
- {
- if ( response )
- {
- new xStr[128], lid = labelid[playerid];
- format (xStr, 128, FileLoad, lid);
- TextInfo[lid][DD] = strval(inputtext);
- UnLoadSaveTexts();
- LoadTexts();
- }
- else
- {
- labelid[playerid] = INVALID_3DTEXT_ID;
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- if ( dialogid == DIALOG_EDIT_LABELCOR)
- {
- if ( response )
- {
- new xStr[128], lid = labelid[playerid];
- format (xStr, 128, FileLoad, lid);
- DOF2::SetString(xStr, "TEXT3D_COLOR", inputtext);
- UnLoadSaveTexts();
- LoadTexts();
- }
- else
- {
- labelid[playerid] = INVALID_3DTEXT_ID;
- nX[playerid] = 0;
- nZ[playerid] = 0;
- nY[playerid] = 0;
- nDD[playerid] = 0;
- nColor[playerid] = "";
- nText[playerid] = "";
- }
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if ( newkeys == 65536)
- {
- if ( Editando[playerid] == true)
- {
- new textt = labelid[playerid];
- GetPlayerPos(playerid, nX[playerid], nY[playerid], nZ[playerid]);
- TextInfo[textt][X] = nX[playerid];
- TextInfo[textt][Y] = nY[playerid];
- TextInfo[textt][Z] = nZ[playerid];
- UnLoadSaveTexts();
- LoadTexts();
- return 1;
- }
- }
- return 1;
- }
- LoadTexts()
- {
- for ( new t = 0; t < MAX_TEXT; t++)
- {
- format ( dStr, sizeof ( dStr ), FileLoad, t);
- if ( DOF2::FileExists(dStr))
- {
- TextInfo[t][Loaded] = DOF2::GetBool(dStr, "TEXT3D_Created");
- TextInfo[t][X] = DOF2::GetFloat(dStr, "TEXT3D_PosX");
- TextInfo[t][Y] = DOF2::GetFloat(dStr, "TEXT3D_PosY");
- TextInfo[t][Z] = DOF2::GetFloat(dStr, "TEXT3D_PosZ");
- TextInfo[t][DD] = DOF2::GetFloat(dStr, "TEXT3D_DrawDistance");
- TextInfo[t][VirtualW] = DOF2::GetInt(dStr, "TEXT3D_VirtualW");
- format ( TextInfo[t][Text], 128, "%s", DOF2::GetString(dStr, "TEXT3D_STRING"));
- label[t] = Create3DTextLabel(TextInfo[t][Text], DOF2::GetHex(dStr, "TEXT3D_COLOR"), TextInfo[t][X], TextInfo[t][Y], TextInfo[t][Z], TextInfo[t][DD], TextInfo[t][VirtualW], 0);
- }
- }
- }
- UnLoadSaveTexts()
- {
- for ( new t = 0; t < MAX_TEXT; t++)
- {
- format ( dStr, sizeof ( dStr ), FileLoad, t);
- if ( !DOF2::FileExists(dStr) && TextInfo[t][Loaded] == true) DOF2::CreateFile(dStr);
- if ( TextInfo[t][Loaded] == true )
- {
- DOF2::SetBool(dStr, "TEXT3D_Created", TextInfo[t][Loaded]);
- DOF2::SetFloat(dStr, "TEXT3D_PosX", TextInfo[t][X]);
- DOF2::SetFloat(dStr, "TEXT3D_PosY", TextInfo[t][Y]);
- DOF2::SetFloat(dStr, "TEXT3D_PosZ", TextInfo[t][Z]);
- DOF2::SetFloat(dStr, "TEXT3D_DrawDistance", TextInfo[t][DD]);
- DOF2::SetInt(dStr, "TEXT3D_VirtualW", TextInfo[t][VirtualW]);
- DOF2::SetString(dStr, "TEXT3D_STRING", TextInfo[t][Text]);
- DOF2::SaveFile();
- TextInfo[t][Loaded] = false;
- Delete3DTextLabel(label[t]);
- }
- }
- return 1;
- }
- Make3DText(text[], dcolor[], Float: dX, Float: dY, Float: dZ, Float: Distance, VW)
- {
- for ( new t = 0; t < MAX_TEXT; t++)
- {
- if ( TextInfo[t][Loaded] == false)
- {
- format ( dStr, sizeof ( dStr ), FileLoad, t);
- DOF2::CreateFile(dStr);
- if ( !DOF2::FileExists(dStr)) return printf ("O 3DText %d não foi criado", t);
- TextInfo[t][Loaded] = true;
- TextInfo[t][X] = dX;
- TextInfo[t][Y] = dY;
- TextInfo[t][Z] = dZ;
- TextInfo[t][DD] = Distance;
- TextInfo[t][VirtualW] = VW;
- format ( TextInfo[t][Text], 128, "%s", text);
- DOF2::SetString(dStr, "TEXT3D_COLOR", dcolor);
- DOF2::SaveFile();
- label[t] = Create3DTextLabel(TextInfo[t][Text], DOF2::GetHex(dStr, "TEXT3D_COLOR"), TextInfo[t][X], TextInfo[t][Y], TextInfo[t][Z], TextInfo[t][DD], TextInfo[t][VirtualW], 0);
- UnLoadSaveTexts();
- LoadTexts();
- break;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment