SAMP Text Draw

ELTacoBanido

Новичок
Автор темы
29
1
Версия MoonLoader
.025-beta
35960

The server creates this text draw with 4 slots, one has a rock, i need to click on the rock to continue
I need to detect the rock on the screen and send a click on it using https://blast.hk/wiki/lua:sampsendclicktextdraw, but the problem lies on how to detect wich is the rock slot

if i return the model ID on every render i get this:
35992


So they made a sort of a anti bot system here, but i got their server source, and this is the related function (iam not much of a pwn coder)

the command is /dejar roca
so, /dejar and the argument is roca >

JavaScript:
CMD:dejar(playerid,params[])
{
    new item[32],ID,Trabajo,TrabajoVip,TrabajoN[32],TrabajoVipN[32],string[128];
    if(!sscanf(params,"s[32]", item))
    {

        if(strcmp(item, "roca",true)==0)
        {
            if(!IsPlayerInRangeOfPoint(playerid, 10.0, -548.2949,2336.7649,83.4777)) return SCM(playerid, -1, "No estas en el lugar adecuado.");
            new rocas[5];
            rocas[0] = rocajugador[playerid];
            rocas[1] = 11392;
            rocas[2] = 11392;
            rocas[3] = 11392;
            ShowModelSelectionMenuEx2(playerid, rocas, 4, "Selecciona la roca", OBJETIVOROCA, 16.0, 0.0, -55.0, 1.0, 0x000000FF, 0x000000FF);
        }


the OBJETIVOROCA function >
JavaScript:
if(extraid == OBJETIVOROCA)
    {
        if(response)
        {
            switch(modelid)
            {
                case 897: // ROCA
                {
                    new string[128], Query[200], ganancias;
                    switch(PlayerInfo[playerid][pNivelMinero])
                    {
                        case 1:
                        {
                            new intento = random(3);
                            switch(intento)
                            {
                                case 0: {    ganancias=148;    }
                                case 1: {    ganancias=150;    }
                                case 2: {    ganancias=146;    }
                            }
                        }
                        case 2:
                        {
                            new intento = random(3);
                            switch(intento)
                            {
                                case 0: {    ganancias=200;    }
                                case 1: {    ganancias=210;    }
                                case 2: {    ganancias=207;    }
                            }
                        }
                        case 3..100:
                        {
                            new intento = random(3);
                            switch(intento)
                            {
                                case 0: {    ganancias=240;    }
                                case 1: {    ganancias=255;    }
                                case 2: {    ganancias=247;    }
                            }
                        }
                    }
                    format(string, sizeof(string), "%s tira una roca a la procesadora.", NombreJugador(playerid));
                    ProxDetector(15.0, playerid, string, COLOR_VERDECLARO,COLOR_VERDECLARO,COLOR_VERDECLARO,COLOR_VERDECLARO,COLOR_VERDECLARO);
                    new exp = random(3);
                    switch(exp)
                    {
                        case 0: { SCM(playerid,-1,"Esta vez no ganaste habilidad."); }
                        case 1: { SCM(playerid,-1,"Esta vez no ganaste habilidad."); }
                        case 2:
                        {
                            if(PlayerInfo[playerid][pExpPescador] < 49)
                            {
                                SCM(playerid,0x0080C2FF,"Has aumentado tu experiencia con +1 punto de habilidad");
                                PlayerInfo[playerid][pExpMinero]++;
                                format(Query, 200, "UPDATE `usuarios` SET `ExpMinero`='%d' WHERE `Username`='%s'",PlayerInfo[playerid][pExpMinero],NombreJugador(playerid));
                                mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 0, playerid);
                            }
                            else if(PlayerInfo[playerid][pExpPescador] >= 49)
                            {
                                SCM(playerid,-1,"Felicidades, has aumentado tu nivel en este trabajo");
                                PlayerInfo[playerid][pExpMinero] = 0;
                                PlayerInfo[playerid][pNivelMinero]++;
                                format(Query, 200, "UPDATE `usuarios` SET `ExpMinero`='%d',`NivelMinero`='%d' WHERE `Username`='%s'",PlayerInfo[playerid][pExpMinero],PlayerInfo[playerid][pNivelMinero],NombreJugador(playerid));
                                mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii", 0, playerid);
                            }
                        }
                    }
                    format(string, sizeof(string), "¡Buen trabajo!, tus ganancias son {00CC00}$%d", ganancias);
                    DarDinero(playerid, ganancias);
                    SCM(playerid, -1, string);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
                    RemovePlayerAttachedObject(playerid,2);
                    rocajugador[playerid] = 11392;
                }
            }
        }
    }
    return 1;
}

If anyone can help me find a solution to that, thanks anyway!!
 

Rei

Известный
Друг
1,610
1,666
i m too not a pawn coder and i just don’t know espanol :D

alright, if there is only one clickable textdraw you can get "selectable" param, idk how to do it with default moonloader functions, but u can get samp.lua https://www.blast.hk/threads/14624/ install it to lib then use this code
Lua:
local sampev = require 'lib.samp.events'

function sampev.onShowTextDraw(id, data)
 if data.modelId == 896 and data.selectable == 1 then
  sampSendClickTextdraw(id)
 end
end
 

ELTacoBanido

Новичок
Автор темы
29
1
i m too not a pawn coder and i just don’t know espanol :D

alright, if there is only one clickable textdraw you can get "selectable" param, idk how to do it with default moonloader functions, but u can get samp.lua https://www.blast.hk/threads/14624/ install it to lib then use this code
Lua:
local sampev = require 'lib.samp.events'

function sampev.onShowTextDraw(id, data)
if data.modelId == 896 and data.selectable == 1 then
  sampSendClickTextdraw(id)
end
end

The problem is, if i send a click to 896, it will not click on the correct one, as i said, i think they may be overlaping the rocks.
 

Rei

Известный
Друг
1,610
1,666
yes, otherwise it wouldnt fail
hm... maybe parse and render to chat all textdraws and try to find different in chatlog.txt?
Lua:
function sampev.onShowTextDraw(txid, data)
    if txid == 21290 then
        for key, val in pairs(data) do
            tval = tostring(val)
            tip = type(val)
            sampAddChatMessage(key.." : "..tval.. "   type - "..tip, - 1)
        end
    end
end
 
  • Влюблен
Реакции: ELTacoBanido

ELTacoBanido

Новичок
Автор темы
29
1
hm... maybe parse and render to chat all textdraws and try to find different in chatlog.txt?
Lua:
function sampev.onShowTextDraw(txid, data)
    if txid == 21290 then
        for key, val in pairs(data) do
            tval = tostring(val)
            tip = type(val)
            sampAddChatMessage(key.." : "..tval.. "   type - "..tip, - 1)
        end
    end
end

Nice, it outputed this
JavaScript:
 boxColor : -16777216   type - number
outline : 0   type - number
modelId : 0   type - number
color : -1   type - number
style : 1   type - number
backgroundColor : -16777216   type - number
lineWidth : 27   type - number
zoom : 1   type - number
position : table: 0x0017d610   type - table
selectable : 0   type - number
letterWidth : 0.31999999284744   type - number
text : Selecione a rocha   type - string
lineHeight : 178   type - number
flags : 25   type - number
rotation : table: 0x0017d698   type - table
letterHeight : 1   type - number
letterColor : -1   type - number
shadow : 1   type - number
----------------------------
boxColor : -16777216   type - number
outline : 0   type - number
modelId : 0   type - number
color : -1   type - number
style : 1   type - number
backgroundColor : -16777216   type - number
lineWidth : 27   type - number
zoom : 1   type - number
position : table: 0x0017e128   type - table
selectable : 0   type - number
letterWidth : 0.31999999284744   type - number
text : _   type - string
lineHeight : 178   type - number
flags : 25   type - number
rotation : table: 0x0017e1b0   type - table
letterHeight : 21.10000038147   type - number
letterColor : -1   type - number
shadow : 1   type - number
----------------------------
boxColor : -16777216   type - number
outline : 0   type - number
modelId : 0   type - number
color : -1   type - number
style : 1   type - number
backgroundColor : -1727329525   type - number
lineWidth : 9   type - number
zoom : 1   type - number
position : table: 0x0017e9c0   type - table
selectable : 1   type - number
letterWidth : 0.28999999165535   type - number
text : X   type - string
lineHeight : 9   type - number
flags : 9   type - number
rotation : table: 0x0017ea10   type - table
letterHeight : 1   type - number
letterColor : -16776961   type - number
shadow : 1   type - number
----------------------------
boxColor : -16777216   type - number
outline : 0   type - number
modelId : 896   type - number
color : -1   type - number
style : 5   type - number
backgroundColor : -1727329525   type - number
lineWidth : 87   type - number
zoom : 100   type - number
position : table: 0x0017f3b8   type - table
selectable : 1   type - number
letterWidth : 0.27000001072884   type - number
text : sd   type - string
lineHeight : 93   type - number
flags : 9   type - number
rotation : table: 0x0017f440   type - table
letterHeight : 8.8000020980835   type - number
letterColor : -1   type - number
shadow : 0   type - number
----------------------------
boxColor : -16777216   type - number
outline : 0   type - number
modelId : 896   type - number
color : -1   type - number
style : 5   type - number
backgroundColor : -1727329525   type - number
lineWidth : 87   type - number
zoom : 100   type - number
position : table: 0x0017fe68   type - table
selectable : 1   type - number
letterWidth : 0.27000001072884   type - number
text : sd   type - string
lineHeight : 93   type - number
flags : 9   type - number
rotation : table: 0x0017fef0   type - table
letterHeight : 8.8000020980835   type - number
letterColor : -1   type - number
shadow : 0   type - number
----------------------------
boxColor : -16777216   type - number
outline : 0   type - number
modelId : 896   type - number
color : -1   type - number
style : 5   type - number
backgroundColor : -1727329525   type - number
lineWidth : 87   type - number
zoom : 1   type - number
position : table: 0x0017d480   type - table
selectable : 1   type - number
letterWidth : 0.27000001072884   type - number
text : sd   type - string
lineHeight : 93   type - number
flags : 9   type - number
rotation : table: 0x0017d4d0   type - table
letterHeight : 8.8000020980835   type - number
letterColor : -1   type - number
shadow : 0   type - number
----------------------------
boxColor : -16777216   type - number
outline : 0   type - number
modelId : 896   type - number
color : -1   type - number
style : 5   type - number
backgroundColor : -1727329525   type - number
lineWidth : 87   type - number
zoom : 100   type - number
position : table: 0x0ffb5eb0   type - table
selectable : 1   type - number
letterWidth : 0.27000001072884   type - number
text : sd   type - string
lineHeight : 93   type - number
flags : 9   type - number
rotation : table: 0x0ffb5f00   type - table
letterHeight : 8.8000020980835   type - number
letterColor : -1   type - number
shadow : 0   type - number
----------------------------

In wich the first 3 seems to be only the top of the menu
and the other 4 ones the selectables itself
the only difference between those is one wich has a zoom of 1 type - number while others have zoom of 100 type - number

Well, i selected that one and boom, it worked!!

heres the code:
Lua:
function sampev.onShowTextDraw(txid, data)
    if data.zoom == 1 and data.text == "sd" then
        sampSendClickTextdraw(txid)
    end
end

Thanks!!!
 
Последнее редактирование: